From f662768a04662d47ad41693973e89fab250c93b3 Mon Sep 17 00:00:00 2001 From: tiyn Date: Sat, 18 May 2024 04:27:54 +0200 Subject: [PATCH] scripts: renamed many scripts and added options; added loopback --- .config/sxhkd/sxhkdrc | 8 ++--- .config/sxiv/exec/key-handler | 2 +- .local/bin/etc/sxhkd/audio/lmc | 25 ++++++++++++++-- .local/bin/etc/sxhkd/audio/loopback | 30 +++++++++++++++++++ .local/bin/etc/sxhkd/keymap | 25 ++++++++++++++++ .local/bin/etc/sxhkd/keymap_toggle | 14 --------- .local/bin/etc/sxhkd/monitor | 23 ++++++++++++++ .local/bin/etc/sxhkd/monitor_toggle | 11 ------- .../etc/sxhkd/{screenshot_menu => screenshot} | 0 .local/bin/etc/sxhkd/touchpad | 17 +++++++++++ .local/bin/etc/sxhkd/touchpad_toggle | 7 ----- .local/bin/tools/{lock_set => lock_wallpaper} | 0 .../bin/tools/{background_set => wallpaper} | 0 .xinitrc | 2 +- 14 files changed, 124 insertions(+), 40 deletions(-) create mode 100755 .local/bin/etc/sxhkd/audio/loopback create mode 100755 .local/bin/etc/sxhkd/keymap delete mode 100755 .local/bin/etc/sxhkd/keymap_toggle create mode 100755 .local/bin/etc/sxhkd/monitor delete mode 100755 .local/bin/etc/sxhkd/monitor_toggle rename .local/bin/etc/sxhkd/{screenshot_menu => screenshot} (100%) create mode 100755 .local/bin/etc/sxhkd/touchpad delete mode 100755 .local/bin/etc/sxhkd/touchpad_toggle rename .local/bin/tools/{lock_set => lock_wallpaper} (100%) rename .local/bin/tools/{background_set => wallpaper} (100%) diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 4d361f8..cc5e31e 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -36,7 +36,7 @@ super + bracketleft dnd toggle super + shift + l - keymap_toggle + keymap toggle super + shift + r pkill -usr1 -x sxhkd ; notify-send -u low 'SXHKD' 'Reloaded config' @@ -45,15 +45,15 @@ super + Return $TERMINAL Print - screenshot_menu + screenshot super + shift + space dunstctl close-all super + F5 - monitor_toggle + monitor toggle super + F6 - touchpad_toggle + touchpad toggle super + F7 mount_menu super + F8 diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler index 67ba67e..3177025 100755 --- a/.config/sxiv/exec/key-handler +++ b/.config/sxiv/exec/key-handler @@ -2,7 +2,7 @@ while read file do case "$1" in - "w") background_set "$file" & ;; + "w") wallpaper "$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 6bc2895..b760beb 100755 --- a/.local/bin/etc/sxhkd/audio/lmc +++ b/.local/bin/etc/sxhkd/audio/lmc @@ -4,6 +4,11 @@ # Based on a script by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice # Heavily extended and updated to a pipewire system +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) + [ -z "$2" ] && num="5" || num="$2" case "$1" in @@ -54,6 +59,17 @@ case "$1" in loop) playerctl loop none sleep 1 pkill -RTMIN+9 $STATUSBAR ;; + tap) wpctl set-volume $Id 0.2 + touch ~/.local/state/loopback.lock + pw-loopback -C $Node & ;; + untap) killall pw-loopback + rm ~/.local/state/loopback.lock ;; + tap_toggle) + if [ -f ~/.local/state/loopback.lock ]; then + lmc untap + else + lmc tap + fi ;; *) cat << EOF lmc: cli music interface for pulse for those with divine intellect too grand to remember the pamixer commands. @@ -65,11 +81,16 @@ Allowed options: unmute Unmute microphone deaf Deaf sound undeaf Undeaf sound - deaf_toggle Toggle between deaf and undeaf - mute_toggle Toggle between mute and unmute + deaf_toggle Toggle between deaf and undeaf + mute_toggle Toggle between mute and unmute previous Play previous song in player playpause Toggle play or pause in player next Play next song in player + shuffle Toggle the shuffle mode + loop Toggle the loop mode + tap Start loopback for device + untap Stop all active loopbacks + tap_toggle Start or stop loopback depending if it is already running all else Print this message EOF diff --git a/.local/bin/etc/sxhkd/audio/loopback b/.local/bin/etc/sxhkd/audio/loopback new file mode 100755 index 0000000..7bab45f --- /dev/null +++ b/.local/bin/etc/sxhkd/audio/loopback @@ -0,0 +1,30 @@ +#!/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/keymap b/.local/bin/etc/sxhkd/keymap new file mode 100755 index 0000000..29e4c53 --- /dev/null +++ b/.local/bin/etc/sxhkd/keymap @@ -0,0 +1,25 @@ +#!/bin/sh +layout=$(setxkbmap -query | grep "layout" | awk '{print $NF}') #| grep -q 'ru$' && $(setxkbmap de ; notify-send -u low 'SXHKD' 'Set keymap to german') || $(setxkbmap de ru ; notify-send -u low 'SXHKD' 'Set keymap to russian') +variant=$(setxkbmap -query | grep "variant" | awk '{print $NF}') +echo $variant + +case "$1" in + toggle) if [ "$layout" = "de" -a "$variant" = "nodeadkeys" ] + then + setxkbmap de && notify-send -u low 'SXHKD' 'Set keymap to german' + elif [ "$layout" = "de" -a "$variant" = "" ] + then + setxkbmap de ru && notify-send -u low 'SXHKD' 'Set keymap to russian (german)' + elif [ "$layout" = "de" -a "$variant" = "ru" ] + then + setxkbmap de nodeadkeys && notify-send -u low 'SXHKD' 'Set keymap to german (nodeadkeys)' + fi ;; + *) cat << EOF +keymap: cli script to change the keymap quickly. + +Allowed options: + toggle Loop through the different keymaps + all else Print this message + +EOF +esac diff --git a/.local/bin/etc/sxhkd/keymap_toggle b/.local/bin/etc/sxhkd/keymap_toggle deleted file mode 100755 index 18555ad..0000000 --- a/.local/bin/etc/sxhkd/keymap_toggle +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -layout=$(setxkbmap -query | grep "layout" | awk '{print $NF}') #| grep -q 'ru$' && $(setxkbmap de ; notify-send -u low 'SXHKD' 'Set keymap to german') || $(setxkbmap de ru ; notify-send -u low 'SXHKD' 'Set keymap to russian') -variant=$(setxkbmap -query | grep "variant" | awk '{print $NF}') -echo $variant -if [ "$layout" = "de" -a "$variant" = "nodeadkeys" ] -then - setxkbmap de && notify-send -u low 'SXHKD' 'Set keymap to german' -elif [ "$layout" = "de" -a "$variant" = "" ] -then - setxkbmap de ru && notify-send -u low 'SXHKD' 'Set keymap to russian (german)' -elif [ "$layout" = "de" -a "$variant" = "ru" ] -then - setxkbmap de nodeadkeys && notify-send -u low 'SXHKD' 'Set keymap to german (nodeadkeys)' -fi diff --git a/.local/bin/etc/sxhkd/monitor b/.local/bin/etc/sxhkd/monitor new file mode 100755 index 0000000..679d67c --- /dev/null +++ b/.local/bin/etc/sxhkd/monitor @@ -0,0 +1,23 @@ +#!/bin/sh + +# toggle external monitor +# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice + +intern=LVDS1 +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 --off + wallpaper + ;; + *) cat << EOF +monitor: cli script to enable and disable monitors. + +Allowed options: + toggle Toggle the set monitor on and off + all else Print this message + +EOF +esac diff --git a/.local/bin/etc/sxhkd/monitor_toggle b/.local/bin/etc/sxhkd/monitor_toggle deleted file mode 100755 index bb8601f..0000000 --- a/.local/bin/etc/sxhkd/monitor_toggle +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# toggle external monitor -# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice - -intern=LVDS1 -extern=HDMI2 -(xrandr | grep "$extern disconnected") -(xrandr --listactivemonitors | grep $extern) || ((xrandr --output $extern --right-of $intern --auto && setbg) & exit) -(xrandr --listactivemonitors | grep $extern) && xrandr --output $extern --off -background_set diff --git a/.local/bin/etc/sxhkd/screenshot_menu b/.local/bin/etc/sxhkd/screenshot similarity index 100% rename from .local/bin/etc/sxhkd/screenshot_menu rename to .local/bin/etc/sxhkd/screenshot diff --git a/.local/bin/etc/sxhkd/touchpad b/.local/bin/etc/sxhkd/touchpad new file mode 100755 index 0000000..80646e0 --- /dev/null +++ b/.local/bin/etc/sxhkd/touchpad @@ -0,0 +1,17 @@ +#!/bin/bash + +# Toggle touchpad. Requires xf86-input-synaptics. +# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice + +case "$1" in + toggle) (synclient | grep "TouchpadOff.*1" && synclient TouchpadOff=0)>/dev/null && notify-send "TouchPad reactivated." && exit + synclient TouchpadOff=1 && notify-send "TouchPad deactivated." ;; + *) cat << EOF +touchpad: cli script to enable and disable the touchpad. + +Allowed options: + toggle Toggle the touchpad on and off + all else Print this message + +EOF +esac diff --git a/.local/bin/etc/sxhkd/touchpad_toggle b/.local/bin/etc/sxhkd/touchpad_toggle deleted file mode 100755 index cd61423..0000000 --- a/.local/bin/etc/sxhkd/touchpad_toggle +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Toggle touchpad. Requires xf86-input-synaptics. -# by lukesmithxyz, checkout github.com/lukesmithxyz/voidrice - -(synclient | grep "TouchpadOff.*1" && synclient TouchpadOff=0)>/dev/null && notify-send "TouchPad reactivated." && exit -synclient TouchpadOff=1 && notify-send "TouchPad deactivated." diff --git a/.local/bin/tools/lock_set b/.local/bin/tools/lock_wallpaper similarity index 100% rename from .local/bin/tools/lock_set rename to .local/bin/tools/lock_wallpaper diff --git a/.local/bin/tools/background_set b/.local/bin/tools/wallpaper similarity index 100% rename from .local/bin/tools/background_set rename to .local/bin/tools/wallpaper diff --git a/.xinitrc b/.xinitrc index 39a5360..6428d99 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 -background_set +wallpaper csum="" new_csum=$(sha1sum $(which dwm))