From 0ef1b107818f40547c2f9244526114a34fd8d95a Mon Sep 17 00:00:00 2001 From: tiyn Date: Sat, 18 May 2024 05:01:46 +0200 Subject: [PATCH] scripts: unified and renamed wallpaper script(s) --- .config/sxhkd/sxhkdrc | 2 ++ .config/sxiv/exec/key-handler | 3 ++- .local/bin/etc/sxhkd/audio/lmc | 6 +++-- .local/bin/etc/sxhkd/audio/loopback | 30 ------------------------ .local/bin/etc/sxhkd/monitor | 4 ++-- .local/bin/tools/lock_wallpaper | 13 ----------- .local/bin/tools/wallpaper | 36 +++++++++++++++++++++-------- .xinitrc | 2 +- 8 files changed, 38 insertions(+), 58 deletions(-) delete mode 100755 .local/bin/etc/sxhkd/audio/loopback delete mode 100755 .local/bin/tools/lock_wallpaper diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index cc5e31e..6f144bb 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -34,6 +34,8 @@ super + backslash lmc deaf_toggle super + bracketleft dnd toggle +super + apostrophe + lmc tap_toggle super + shift + l keymap toggle diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler index 3177025..520951d 100755 --- a/.config/sxiv/exec/key-handler +++ b/.config/sxiv/exec/key-handler @@ -2,7 +2,8 @@ while read file do case "$1" in - "w") wallpaper "$file" & ;; + "w") wallpaper desktop "$file" & ;; + "l") wallpaper lock "$file" & ;; "c") [ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.config/bmdirs | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")" [ -z "$destdir" ] && exit diff --git a/.local/bin/etc/sxhkd/audio/lmc b/.local/bin/etc/sxhkd/audio/lmc index b760beb..707b982 100755 --- a/.local/bin/etc/sxhkd/audio/lmc +++ b/.local/bin/etc/sxhkd/audio/lmc @@ -61,9 +61,11 @@ case "$1" in pkill -RTMIN+9 $STATUSBAR ;; tap) wpctl set-volume $Id 0.2 touch ~/.local/state/loopback.lock - pw-loopback -C $Node & ;; + pw-loopback -C $Node & + notify-send -u low 'sxhkd' "Started loopback of $Device" ;; untap) killall pw-loopback - rm ~/.local/state/loopback.lock ;; + rm ~/.local/state/loopback.lock + notify-send -u low 'sxhkd' "Stopped all loopbacks" ;; tap_toggle) if [ -f ~/.local/state/loopback.lock ]; then lmc untap diff --git a/.local/bin/etc/sxhkd/audio/loopback b/.local/bin/etc/sxhkd/audio/loopback deleted file mode 100755 index 7bab45f..0000000 --- a/.local/bin/etc/sxhkd/audio/loopback +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -Device="Audio Adapter (Unitek Y-247A) Mono" - -Name=$(wpctl status | grep "$Device") -Id=$( echo $Name | cut -d '.' -f 1 | cut -c 5-) -Node=$(wpctl inspect $Id | grep node.name | cut -d '=' -f 2) - -case "$1" in - start) wpctl set-volume $Id 0.2 - touch ~/.local/state/loopback.lock - pw-loopback -C $Node & ;; - stop) killall pw-loopback - rm ~/.local/state/loopback.lock ;; - toggle) - if [ -f ~/.local/state/loopback.lock ]; then - loopback stop - else - loopback start - fi ;; - *) cat << EOF -loopback: cli audio script for looping back pulse devices to the default output. - -Allowed options: - start Start loopback for device - stop Stop all active loopbacks - toggle Start or stop loopback depending if it is already running - -EOF -esac diff --git a/.local/bin/etc/sxhkd/monitor b/.local/bin/etc/sxhkd/monitor index 679d67c..ed5e924 100755 --- a/.local/bin/etc/sxhkd/monitor +++ b/.local/bin/etc/sxhkd/monitor @@ -8,9 +8,9 @@ extern=HDMI2 case "$1" in toggle) (xrandr | grep "$extern disconnected") - (xrandr --listactivemonitors | grep $extern) || ((xrandr --output $extern --right-of $intern --auto && wallpaper) & exit) + (xrandr --listactivemonitors | grep $extern) || ((xrandr --output $extern --right-of $intern --auto && wallpaper desktop) & exit) (xrandr --listactivemonitors | grep $extern) && xrandr --output $extern --off - wallpaper + wallpaper desktop ;; *) cat << EOF monitor: cli script to enable and disable monitors. diff --git a/.local/bin/tools/lock_wallpaper b/.local/bin/tools/lock_wallpaper deleted file mode 100755 index ca46a85..0000000 --- a/.local/bin/tools/lock_wallpaper +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -# Based on a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice - -bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/lock" - - -trueloc="$(readlink -f "$1")" && -case "$(file --mime-type -b "$trueloc")" in - image/* ) ln -f "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing lock background..." ;; - inode/directory ) ln -f "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random lock background chosen." ;; - *) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;; -esac diff --git a/.local/bin/tools/wallpaper b/.local/bin/tools/wallpaper index 49f3958..9b1d585 100755 --- a/.local/bin/tools/wallpaper +++ b/.local/bin/tools/wallpaper @@ -1,15 +1,33 @@ #!/bin/sh -# Based on a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice +# Adapted from a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice -bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/bg" +case "$1" in + desktop) bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/bg" + trueloc="$(readlink -f "$2")" && + case "$(file --mime-type -b "$trueloc")" in + image/* ) ln -f "$(readlink -f "$2")" "$bgloc" && notify-send -i "$bgloc" "Desktop wallpaper has been changed." ;; + inode/directory ) ln -f "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random desktop wallpaper chosen." ;; + *) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;; + esac + xwallpaper --zoom "$bgloc" ;; + lock) bgloc="${XDG_DATA_HOME:-$HOME/.local/share}/lock" + trueloc="$(readlink -f "$2")" && + case "$(file --mime-type -b "$trueloc")" in + image/* ) ln -f "$(readlink -f "$2")" "$bgloc" && notify-send -i "$bgloc" "Lock screen wallpaper has been changed." ;; + inode/directory ) ln -f "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random lock screen wallpaper chosen." ;; + *) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;; + esac ;; + *) cat << EOF +wallpaper: cli script to set and reset the wallpaper of the desktop and lock + screen. +Allowed options: + desktop [PATH] Set the wallpaper of the desktop to the specified path. + If no path is given reset it. + lock [PATH] Set the wallpaper of the lock screen to the specified path. + If no path is given reset it. + all else Print this message -trueloc="$(readlink -f "$1")" && -case "$(file --mime-type -b "$trueloc")" in - image/* ) ln -f "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;; - inode/directory ) ln -f "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;; - *) notify-send "🖼️ Error" "Not a valid image or directory." ; exit 1;; +EOF esac - -xwallpaper --zoom "$bgloc" diff --git a/.xinitrc b/.xinitrc index 6428d99..ec799e1 100644 --- a/.xinitrc +++ b/.xinitrc @@ -7,7 +7,7 @@ xrandr --auto [ -f "$HOME/.config/xorg/xdefaults" ] && xrdb -merge "$HOME/.config/xorg/xdefaults" # global resources [ -f "$HOME/.config/xorg/xpcspec" ] && xrdb -merge "$HOME/.config/xorg/xpcspec" # local resources -wallpaper +wallpaper desktop csum="" new_csum=$(sha1sum $(which dwm))