From a7590c1b846764405247b8c3bd89796b575245ec Mon Sep 17 00:00:00 2001 From: yage Date: Tue, 20 Feb 2024 23:08:00 -0700 Subject: [PATCH] scwrypts v4 compatibility --- scwrypts/dotwryn/desktop/backlight | 131 +++++++++--------- scwrypts/dotwryn/desktop/colorscheme/get-hex | 9 -- .../dotwryn/desktop/colorscheme/set-theme | 9 -- .../desktop/i3/create-local-font-override | 62 ++++----- scwrypts/dotwryn/desktop/i3/launch-or-show | 63 ++++----- scwrypts/dotwryn/desktop/i3/lock | 57 ++++---- scwrypts/dotwryn/desktop/i3/logout | 21 ++- scwrypts/dotwryn/desktop/i3/set-background | 38 +++-- scwrypts/dotwryn/desktop/play-sound | 9 +- .../desktop/pulse-audio/set-default-sink | 9 +- scwrypts/dotwryn/desktop/pulseaudio | 65 +++++---- scwrypts/dotwryn/desktop/screen-blank | 85 ++++++------ .../dotwryn/desktop/xrandr/disconnect-all | 9 +- scwrypts/dotwryn/home/update-all-servers | 72 +++++----- scwrypts/ssh/connect/ssh | 7 - scwrypts/ssh/connect/tmux | 7 - scwrypts/ssh/connect/xserver | 7 - scwrypts/ssh/omni/launcher | 4 - scwrypts/ssh/omni/spawn | 7 - 19 files changed, 288 insertions(+), 383 deletions(-) diff --git a/scwrypts/dotwryn/desktop/backlight b/scwrypts/dotwryn/desktop/backlight index 94731b4..921b0c9 100755 --- a/scwrypts/dotwryn/desktop/backlight +++ b/scwrypts/dotwryn/desktop/backlight @@ -1,73 +1,70 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=() - use desktop/notify --group dotwryn - -CHECK_ENVIRONMENT ##################################################################### -{ -command -v xbacklight && UTIL=xbacklight -command -v gmux_backlight && UTIL=gmux_backlight -command -v enlighten && UTIL=enlighten -} >/dev/null 2>&1 +MAIN() { + local UTIL + for UTIL in enlighten gmux_backlight xbacklight + do + command -v $UTIL >/dev/null 2>&1 && break + done -[[ $UTIL =~ ^enlighten$ ]] && { - CURRENT_PERCENT=$(enlighten | sed 's/.*(//;s/%.*//') - [[ $CURRENT_PERCENT -gt 60 ]] && DELTA=20 - [[ $CURRENT_PERCENT -le 60 ]] && DELTA=10 - [[ $CURRENT_PERCENT -le 40 ]] && DELTA=5 - [[ $CURRENT_PERCENT -le 10 ]] && DELTA=1 + [[ $UTIL =~ ^enlighten$ ]] && { + CURRENT_PERCENT=$(enlighten | sed 's/.*(//;s/%.*//') + [[ $CURRENT_PERCENT -gt 60 ]] && DELTA=20 + [[ $CURRENT_PERCENT -le 60 ]] && DELTA=10 + [[ $CURRENT_PERCENT -le 40 ]] && DELTA=5 + [[ $CURRENT_PERCENT -le 10 ]] && DELTA=1 + } + + case $1 in + up ) + case $UTIL in + xbacklight ) xbacklight + 10 ;; + gmux_backlight ) gmux_backlight +100 ;; + + enlighten ) + [[ $CURRENT_PERCENT -ge 99 ]] && NOTIFY_SEND 'at maximum brightness' && exit 0 + enlighten +${DELTA}% + ;; + esac + ;; + down ) + case $UTIL in + xbacklight ) xbacklight - 10 ;; + gmux_backlight ) gmux_backlight -100 ;; + + enlighten ) + [[ $CURRENT_PERCENT -le 1 ]] && NOTIFY_SEND 'at minimum brightness' && exit 0 + [[ $CURRENT_PERCENT -le 2 ]] && ARGS='=1%' || ARGS="-${DELTA}%" + enlighten "$ARGS" + ;; + esac + ;; + set ) + [ ! $2 ] && FAIL 1 'no value provided to set' + case $UTIL in + xbacklight ) xbacklight -set $2 ;; + gmux_backlight ) gmux_backlight $2 ;; + enlighten ) enlighten "=$2" ;; + esac + ;; + min | minimum ) + case $UTIL in + enlighten ) enlighten '=1%' ;; + esac + ;; + max | maximum ) + case $UTIL in + enlighten ) enlighten '=100%' ;; + esac + ;; + query | '' ) + case $UTIL in + enlighten ) NOTIFY_SUCCESS "current brightness : $(enlighten)" ;; + esac + ;; + + * ) NOTIFY_FAIL 1 "operation '$1' not supported" ;; + esac } - -case $1 in - up ) - case $UTIL in - xbacklight ) xbacklight + 10 ;; - gmux_backlight ) gmux_backlight +100 ;; - - enlighten ) - [[ $CURRENT_PERCENT -ge 99 ]] && NOTIFY_SEND 'at maximum brightness' && exit 0 - enlighten +${DELTA}% - ;; - esac - ;; - down ) - case $UTIL in - xbacklight ) xbacklight - 10 ;; - gmux_backlight ) gmux_backlight -100 ;; - - enlighten ) - [[ $CURRENT_PERCENT -le 1 ]] && NOTIFY_SEND 'at minimum brightness' && exit 0 - [[ $CURRENT_PERCENT -le 2 ]] && ARGS='=1%' || ARGS="-${DELTA}%" - enlighten "$ARGS" - ;; - esac - ;; - set ) - [ ! $2 ] && FAIL 1 'no value provided to set' - case $UTIL in - xbacklight ) xbacklight -set $2 ;; - gmux_backlight ) gmux_backlight $2 ;; - enlighten ) enlighten "=$2" ;; - esac - ;; - min | minimum ) - case $UTIL in - enlighten ) enlighten '=1%' ;; - esac - ;; - max | maximum ) - case $UTIL in - enlighten ) enlighten '=100%' ;; - esac - ;; - query | '' ) - case $UTIL in - enlighten ) NOTIFY_SUCCESS "current brightness : $(enlighten)" ;; - esac - ;; - - * ) NOTIFY_FAIL 1 "operation '$1' not supported" ;; -esac diff --git a/scwrypts/dotwryn/desktop/colorscheme/get-hex b/scwrypts/dotwryn/desktop/colorscheme/get-hex index 1db82ec..d96e27d 100755 --- a/scwrypts/dotwryn/desktop/colorscheme/get-hex +++ b/scwrypts/dotwryn/desktop/colorscheme/get-hex @@ -1,16 +1,7 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=() - use desktop/colorscheme --group dotwryn - -CHECK_ENVIRONMENT ##################################################################### MAIN() { - unset USAGE GET_COLORSCHEME_HEX $@ } - -##################################################################### -MAIN $@ diff --git a/scwrypts/dotwryn/desktop/colorscheme/set-theme b/scwrypts/dotwryn/desktop/colorscheme/set-theme index 6a62677..c36efb1 100755 --- a/scwrypts/dotwryn/desktop/colorscheme/set-theme +++ b/scwrypts/dotwryn/desktop/colorscheme/set-theme @@ -1,16 +1,7 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=() - use desktop/colorscheme --group dotwryn - -CHECK_ENVIRONMENT ##################################################################### MAIN() { - unset USAGE SET_THEME $@ } - -##################################################################### -MAIN $@ diff --git a/scwrypts/dotwryn/desktop/i3/create-local-font-override b/scwrypts/dotwryn/desktop/i3/create-local-font-override index 15fd59a..0b37b9d 100755 --- a/scwrypts/dotwryn/desktop/i3/create-local-font-override +++ b/scwrypts/dotwryn/desktop/i3/create-local-font-override @@ -1,45 +1,40 @@ #!/bin/zsh -DEPENDENCIES+=( - diff -) -REQUIRED_ENV+=( - I3__MODEL_CONFIG -) +DEPENDENCIES+=(diff) +REQUIRED_ENV+=(I3__MODEL_CONFIG) +##################################################################### + +USAGE=" + usage: [...options...] + + options: + -f, --force force replacement of existing i3config + -n, --no-link if output config and template are the same, don't create link + + environment: + I3__MODEL_CONFIG fully-qualified path to sourced i3config + I3__GLOBAL_FONT_SIZE global font size + I3__DMENU_FONT_SIZE (optional) font size for 'dmenu' command + I3__BORDER_PIXEL_SIZE (optional) pixel-width of window borders + + I3 provides no way to include dynamic variables in your config. + The main difference I want between my i3 configurations is font-size + to match the current monitor. Since i3-msg provides no way to change + font size, I run this command to update those variables on a local + copy of my sourced config +" -CHECK_ENVIRONMENT ##################################################################### REGEX_FONT='^\(font [^0-9]*\)\(.*\)' REGEX_DMENU="^\\(.*dmenu_run .*-fn '[^0-9]*\\)\\([0-9]*\\)'" REGEX_BORDER='^\(for_window.*border pixel \)\(.*\)' -INSTALL() { - local USAGE=" - usage: [...options...] - - options - -f, --force force replacement of existing i3config - -n, --no-link if output config and template are the same, don't create link - - -h, --help print this message and exit - - environment - I3__MODEL_CONFIG fully-qualified path to sourced i3config - I3__GLOBAL_FONT_SIZE global font size - I3__DMENU_FONT_SIZE (optional) font size for 'dmenu' command - I3__BORDER_PIXEL_SIZE (optional) pixel-width of window borders - - I3 provides no way to include dynamic variables in your config. - The main difference I want between my i3 configurations is font-size - to match the current monitor. Since i3-msg provides no way to change - font size, I run this command to update those variables on a local - copy of my sourced config - " +MAIN() { local FORCE=0 local AUTOLINK=1 while [[ $# -gt 0 ]] do - case $1 in + case $1 in -f | --force ) FORCE=1 ;; -n | --no-link ) AUTOLINK=0 ;; -h | --help ) USAGE; exit 0 ;; @@ -84,19 +79,16 @@ INSTALL() { [ -f "$CONFIG_FILE.bak" ] \ && diff "$CONFIG_FILE" "$CONFIG_FILE.bak" -q >/dev/null \ && mv "$CONFIG_FILE.bak" "$CONFIG_FILE" \ - && INFO "no changes were made" \ + && DEBUG "no changes were made" \ ; [[ $AUTOLINK -eq 1 ]] \ && diff "$CONFIG_FILE" "$I3__MODEL_CONFIG" -q >/dev/null \ && rm "$CONFIG_FILE" \ && ln -s "$I3__MODEL_CONFIG" "$CONFIG_FILE" \ - && INFO "output is the same as model, i3config has been linked to model" \ + && DEBUG "output is the same as model, i3config has been linked to model" \ ; [[ $FORCE -eq 1 ]] && rm "$CONFIG.bak" >/dev/null 2>&1 return 0 } - -##################################################################### -INSTALL $@ diff --git a/scwrypts/dotwryn/desktop/i3/launch-or-show b/scwrypts/dotwryn/desktop/i3/launch-or-show index 87391c2..ebaa5d3 100755 --- a/scwrypts/dotwryn/desktop/i3/launch-or-show +++ b/scwrypts/dotwryn/desktop/i3/launch-or-show @@ -1,45 +1,41 @@ #!/bin/zsh -DEPENDENCIES+=( - i3-msg - xdotool - xrandr -) -REQUIRED_ENV+=() - use system/desktop/notify -CHECK_ENVIRONMENT +DEPENDENCIES+=(i3-msg xdotool xrandr) ##################################################################### -LAUNCH_OR_SHOW() { - INFO $@ - local USAGE=" - usage: [client-class] [...options...] +USAGE=" + usage: [client-class] [...options...] - options - -c, --client if different from the executable name, xprop CLIENT_CLASS + options + -c, --client if different from the executable name, xprop CLIENT_CLASS - -s, --scale (default: 0.8 or 0.5 if screen width >3000px) - -x, --x-offset (default: 0.0) - -y, --y-offset (default: 0.0) + -s, --scale (default: 0.8 or 0.5 if screen width >3000px) + -x, --x-offset (default: 0.0) + -y, --y-offset (default: 0.0) - -a, --always-launch invoke executable even if client-class exists - -n, --no-resize don't resize the window (ignores -sxy flags) - -l, --no-center leave the window wherever it was last positioned + -a, --always-launch invoke executable even if client-class exists + -n, --no-resize don't resize the window (ignores -sxy flags) + -l, --no-center leave the window wherever it was last positioned - --has-statusbar-icon (default: false) use if program has a statusbar icon + --has-statusbar-icon (default: false) use if program has a statusbar icon - -h, --help print this message and exit + -h, --help print this message and exit - Makes it easy to bind appications to key shortcuts without having to - spin up redundant instances or cycle through the scratchpad queue. + Makes it easy to bind appications to key shortcuts without having to + spin up redundant instances or cycle through the scratchpad queue. - Performs a variety of tasks based on states: - 1) starts and application - 2) adds all instances of the specified application to the scratchpad - 3) (toggle) hides all visible instances - 4) (toggle) shows all scratchpad-hidden instances - " + Performs a variety of tasks based on states: + 1) starts and application + 2) adds all instances of the specified application to the scratchpad + 3) (toggle) hides all visible instances + 4) (toggle) shows all scratchpad-hidden instances +" + +##################################################################### + +MAIN() { + DEBUG $@ local APPLICATION CLIENT_CLASS local XFFSET=0.0 @@ -55,7 +51,7 @@ LAUNCH_OR_SHOW() { while [[ $# -gt 0 ]] do - case $1 in + case $1 in -c | --client ) CLIENT_CLASS="$2"; shift 1 ;; -x | --x-offset ) XFFSET=$2; shift 1 ;; -y | --y-offset ) YFFSET=$2; shift 1 ;; @@ -112,7 +108,7 @@ LAUNCH_OR_SHOW() { | awk -v f=$SCALE -v x=$XFFSET -v y=$YFFSET \ '{print int($1*f+x)," ",int($2*f+y);}'\ ) - INFO "window size: $WINDOW_SIZE" + DEBUG "window size: $WINDOW_SIZE" STATUS 'moving window to scratchpad' i3-msg "[class=$CLIENT_CLASS] move scratchpad" @@ -131,6 +127,3 @@ LAUNCH_OR_SHOW() { return 0 } - -##################################################################### -LAUNCH_OR_SHOW $@ diff --git a/scwrypts/dotwryn/desktop/i3/lock b/scwrypts/dotwryn/desktop/i3/lock index 492aa43..b51f4cb 100755 --- a/scwrypts/dotwryn/desktop/i3/lock +++ b/scwrypts/dotwryn/desktop/i3/lock @@ -1,40 +1,37 @@ #!/bin/zsh -DEPENDENCIES+=( - i3lock -) -REQUIRED_ENV+=() - use desktop/colorscheme --group dotwryn use desktop/notify --group dotwryn -CHECK_ENVIRONMENT +DEPENDENCIES+=(i3lock) ##################################################################### -ARGS=( - --ignore-empty-password - --force-clock - --pass-screen-keys - --pass-media-keys - --pass-volume-keys - --pass-power-keys - --verif-text='' - --wrong-text='' - --blur=11 - --insidever-color=$(GET_COLORSCHEME_HEX 6) - --ringver-color=$(GET_COLORSCHEME_HEX 10) - --insidewrong-color=$(GET_COLORSCHEME_HEX 1) - --ringwrong-color=$(GET_COLORSCHEME_HEX 9) - --inside-color=$(GET_COLORSCHEME_HEX 0) - --ring-color=$(GET_COLORSCHEME_HEX 2) - --time-color=$(GET_COLORSCHEME_HEX 7) - --date-color=$(GET_COLORSCHEME_HEX 15) - --keyhl-color=$(GET_COLORSCHEME_HEX 11) - --bshl-color=$(GET_COLORSCHEME_HEX 13) - ) +MAIN() { + local ARGS=( + --ignore-empty-password + --force-clock + --pass-screen-keys + --pass-media-keys + --pass-volume-keys + --pass-power-keys + --verif-text='' + --wrong-text='' + --blur=11 + --insidever-color=$(GET_COLORSCHEME_HEX 6) + --ringver-color=$(GET_COLORSCHEME_HEX 10) + --insidewrong-color=$(GET_COLORSCHEME_HEX 1) + --ringwrong-color=$(GET_COLORSCHEME_HEX 9) + --inside-color=$(GET_COLORSCHEME_HEX 0) + --ring-color=$(GET_COLORSCHEME_HEX 2) + --time-color=$(GET_COLORSCHEME_HEX 7) + --date-color=$(GET_COLORSCHEME_HEX 15) + --keyhl-color=$(GET_COLORSCHEME_HEX 11) + --bshl-color=$(GET_COLORSCHEME_HEX 13) + ) -RADIUS=$(xrandr | grep 'connected primary' | sed 's/.* \([0-9]\+\)x.*/\1/' | awk '{print int($1*0.08)}') -[ $RADIUS ] && ARGS+=(--radius=$RADIUS) + local RADIUS=$(xrandr | grep 'connected primary' | sed 's/.* \([0-9]\+\)x.*/\1/' | awk '{print int($1*0.08)}') + [ $RADIUS ] && ARGS+=(--radius=$RADIUS) -i3lock ${ARGS[@]} \ + i3lock ${ARGS[@]} \ || NOTIFY_ERROR 'i3lock-color' 'something went wrong; unable to lock' \ ; +} diff --git a/scwrypts/dotwryn/desktop/i3/logout b/scwrypts/dotwryn/desktop/i3/logout index ac9cd25..b92022e 100755 --- a/scwrypts/dotwryn/desktop/i3/logout +++ b/scwrypts/dotwryn/desktop/i3/logout @@ -1,16 +1,13 @@ #!/bin/zsh -DEPENDENCIES+=( - i3-nagbar -) -REQUIRED_ENV+=() +use desktop/notify --group dotwryn -use desktop/notify --group dotwryn - -CHECK_ENVIRONMENT +DEPENDENCIES+=(i3-nagbar) ##################################################################### -i3-nagbar \ - -t warning \ - -m 'Do you really want to exit i3?' \ - -B 'Yes' "notify-send 'system' 'exiting i3...' -i face-tired; i3-msg exit" \ - || NOTIFY_ERROR 'unable to launch i3-nagbar' +MAIN() { + i3-nagbar \ + -t warning \ + -m 'Do you really want to exit i3?' \ + -B 'Yes' "notify-send 'system' 'exiting i3...' -i face-tired; i3-msg exit" \ + || NOTIFY_ERROR 'unable to launch i3-nagbar' +} diff --git a/scwrypts/dotwryn/desktop/i3/set-background b/scwrypts/dotwryn/desktop/i3/set-background index 79b9162..bb3c1d5 100755 --- a/scwrypts/dotwryn/desktop/i3/set-background +++ b/scwrypts/dotwryn/desktop/i3/set-background @@ -1,27 +1,23 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=( - DESKTOP__WALLPAPER_PATH -) - -CHECK_ENVIRONMENT +REQUIRED_ENV+=(DESKTOP__WALLPAPER_PATH) ##################################################################### +MAIN() { + [ ! -d $WALLPAPER_PATH ] \ + && FAIL 1 "no such directory for DESKTOP__WALLPAPER_PATH='$DESKTOP__WALLPAPER_PATH'" -[ ! -d $WALLPAPER_PATH ] \ - && FAIL 1 "no such directory for DESKTOP__WALLPAPER_PATH='$DESKTOP__WALLPAPER_PATH'" + SELECTION="$1" + [ ! $SELECTION ] && SELECTION=random -SELECTION="$1" -[ ! $SELECTION ] && SELECTION=random + case $SELECTION in + random ) + feh --recursive --randomize --bg-fill $WALLPAPER_PATH + ;; + * ) + [ ! -f $DESKTOP__WALLPAPER_PATH/$SELECTION ] \ + && FAIL 2 "no such wallpaper '$SELECTION' in wallpaper path" -case $SELECTION in - random ) - feh --recursive --randomize --bg-fill $WALLPAPER_PATH - ;; - * ) - [ ! -f $DESKTOP__WALLPAPER_PATH/$SELECTION ] \ - && FAIL 2 "no such wallpaper '$SELECTION' in wallpaper path" - - feh --bg-fill $DESKTOP__WALLPAPER_PATH/$SELECTION - ;; -esac + feh --bg-fill $DESKTOP__WALLPAPER_PATH/$SELECTION + ;; + esac +} diff --git a/scwrypts/dotwryn/desktop/play-sound b/scwrypts/dotwryn/desktop/play-sound index c183759..08498f2 100755 --- a/scwrypts/dotwryn/desktop/play-sound +++ b/scwrypts/dotwryn/desktop/play-sound @@ -1,10 +1,7 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=() - use media/audio --group dotwryn - -CHECK_ENVIRONMENT ##################################################################### -MEDIA__PLAY_SFX $@ +MAIN() { + MEDIA__PLAY_SFX $@ +} diff --git a/scwrypts/dotwryn/desktop/pulse-audio/set-default-sink b/scwrypts/dotwryn/desktop/pulse-audio/set-default-sink index 0a6278d..f452e37 100755 --- a/scwrypts/dotwryn/desktop/pulse-audio/set-default-sink +++ b/scwrypts/dotwryn/desktop/pulse-audio/set-default-sink @@ -1,10 +1,7 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=() - use desktop/pulse-audio --group dotwryn - -CHECK_ENVIRONMENT ##################################################################### -PA__SET_DEFAULT_AUDIO $@ +MAIN() { + PA__SET_DEFAULT_AUDIO $@ +} diff --git a/scwrypts/dotwryn/desktop/pulseaudio b/scwrypts/dotwryn/desktop/pulseaudio index 8072e91..a9bde6e 100755 --- a/scwrypts/dotwryn/desktop/pulseaudio +++ b/scwrypts/dotwryn/desktop/pulseaudio @@ -1,46 +1,45 @@ #!/bin/zsh -source $HOME/.config/wryn/env.zsh -DEPENDENCIES+=( - pactl -) -REQUIRED_ENV+=() - use desktop/notify --group dotwryn use media/audio --group dotwryn +DEPENDENCIES+=(pactl) + +source $HOME/.config/wryn/env.zsh ##################################################################### -DEVICE="$1" -COMMAND="$2" +MAIN() { + local DEVICE="$1" + local COMMAND="$2" -case $DEVICE in - sink ) AMIXER_DEVICE=Master ;; - source ) AMIXER_DEVICE=Capture ;; - * ) NOTIFY_FAIL 1 "Unsupported device '$DEVICE'" ;; -esac + case $DEVICE in + sink ) AMIXER_DEVICE=Master ;; + source ) AMIXER_DEVICE=Capture ;; + * ) NOTIFY_FAIL 1 "Unsupported device '$DEVICE'" ;; + esac -DEFAULT_DEVICE="@DEFAULT_$(echo $DEVICE | tr '[:lower:]' '[:upper:]')@" -case $COMMAND in - up ) - pactl set-$DEVICE-volume $DEFAULT_DEVICE +10% \ - || NOTIFY_ERROR "pactl error with set-$DEVICE-volume" + local DEFAULT_DEVICE="@DEFAULT_$(echo $DEVICE | tr '[:lower:]' '[:upper:]')@" + case $COMMAND in + up ) + pactl set-$DEVICE-volume $DEFAULT_DEVICE +10% \ + || NOTIFY_ERROR "pactl error with set-$DEVICE-volume" - MEDIA__PLAY_SFX volume - ;; + MEDIA__PLAY_SFX volume + ;; - down ) - pactl set-$DEVICE-volume $DEFAULT_DEVICE -10% \ - || NOTIFY_ERROR "pactl error with set-$DEVICE-volume" + down ) + pactl set-$DEVICE-volume $DEFAULT_DEVICE -10% \ + || NOTIFY_ERROR "pactl error with set-$DEVICE-volume" - MEDIA__PLAY_SFX volume - ;; + MEDIA__PLAY_SFX volume + ;; - mute ) - pactl set-$DEVICE-mute $DEFAULT_DEVICE toggle \ - && NOTIFY_SUCCESS "default $DEVICE" "$(amixer sget $AMIXER_DEVICE | grep -q '\[on\]' && echo unmuted || echo muted)" \ - || NOTIFY_ERROR "pactl error with set-$DEVICE-mute" - MEDIA__PLAY_SFX mute - ;; + mute ) + pactl set-$DEVICE-mute $DEFAULT_DEVICE toggle \ + && NOTIFY_SUCCESS "default $DEVICE" "$(amixer sget $AMIXER_DEVICE | grep -q '\[on\]' && echo unmuted || echo muted)" \ + || NOTIFY_ERROR "pactl error with set-$DEVICE-mute" + MEDIA__PLAY_SFX mute + ;; - * ) NOTIFY_FAIL 1 "Unsupported command '$COMMAND'" ;; -esac + * ) NOTIFY_FAIL 1 "Unsupported command '$COMMAND'" ;; + esac +} diff --git a/scwrypts/dotwryn/desktop/screen-blank b/scwrypts/dotwryn/desktop/screen-blank index 56cf025..5801940 100755 --- a/scwrypts/dotwryn/desktop/screen-blank +++ b/scwrypts/dotwryn/desktop/screen-blank @@ -1,52 +1,51 @@ #!/bin/zsh -DEPENDENCIES+=(xset) -REQUIRED_ENV+=() - use desktop/notify --group dotwryn -CHECK_ENVIRONMENT +DEPENDENCIES+=(xset) ##################################################################### -case $1 in - enable | disable | query | toggle ) ACTION="$1" ;; - * ) - [ ! $1 ] && ACTION=toggle - echo $ACTION - ;; -esac +MAIN() { + case $1 in + enable | disable | query | toggle ) ACTION="$1" ;; + * ) + [ ! $1 ] && ACTION=toggle + echo $ACTION + ;; + esac -[[ $ACTION =~ ^toggle$ ]] && { - xset -q | grep -qi 'prefer blanking: *no' \ - && ACTION='enable' || ACTION='disable' -} - -[ ! $ACTION ] && NOTIFY_FAIL 1 "unknown screen blank action '$1'" - -case $ACTION in - enable ) : \ - && STATUS 'enabling screen blank' \ - && xset +dpms \ - && xset s blank \ - && xset s on \ - && NOTIFY_SUCCESS 'enabled screen blank' \ - || NOTIFY_FAIL 2 'error enabling screen blank' - ;; - - disable ) : \ - && STATUS 'disabling screen blank' \ - && xset dpms 0 0 0 \ - && xset s noblank \ - && xset s off \ - && NOTIFY_SUCCESS 'disabled screen blank' \ - || NOTIFY_FAIL 2 'error disabling screen blank' - ;; - - query ) + [[ $ACTION =~ ^toggle$ ]] && { xset -q | grep -qi 'prefer blanking: *no' \ - && CURRENT_STATE='disabled' || CURRENT_STATE='enabled' + && ACTION='enable' || ACTION='disable' + } - [ ! $CURRENT_STATE ] && NOTIFY_FAIL 3 'unable to determine current setting' + [ ! $ACTION ] && NOTIFY_FAIL 1 "unknown screen blank action '$1'" - NOTIFY_SUCCESS "screen blank is currently \\033[0;34m$CURRENT_STATE" - ;; -esac + case $ACTION in + enable ) : \ + && STATUS 'enabling screen blank' \ + && xset +dpms \ + && xset s blank \ + && xset s on \ + && NOTIFY_SUCCESS 'enabled screen blank' \ + || NOTIFY_FAIL 2 'error enabling screen blank' + ;; + + disable ) : \ + && STATUS 'disabling screen blank' \ + && xset dpms 0 0 0 \ + && xset s noblank \ + && xset s off \ + && NOTIFY_SUCCESS 'disabled screen blank' \ + || NOTIFY_FAIL 2 'error disabling screen blank' + ;; + + query ) + xset -q | grep -qi 'prefer blanking: *no' \ + && CURRENT_STATE='disabled' || CURRENT_STATE='enabled' + + [ ! $CURRENT_STATE ] && NOTIFY_FAIL 3 'unable to determine current setting' + + NOTIFY_SUCCESS "screen blank is currently \\033[0;34m$CURRENT_STATE" + ;; + esac +} diff --git a/scwrypts/dotwryn/desktop/xrandr/disconnect-all b/scwrypts/dotwryn/desktop/xrandr/disconnect-all index 9b24bd8..72298f7 100755 --- a/scwrypts/dotwryn/desktop/xrandr/disconnect-all +++ b/scwrypts/dotwryn/desktop/xrandr/disconnect-all @@ -1,10 +1,7 @@ #!/bin/zsh -DEPENDENCIES+=() -REQUIRED_ENV+=() - use desktop/xrandr --group dotwryn - -CHECK_ENVIRONMENT ##################################################################### -XRANDR__DISCONNECT_ALL_DISPLAYS $@ +MAIN() { + XRANDR__DISCONNECT_ALL_DISPLAYS $@ +} diff --git a/scwrypts/dotwryn/home/update-all-servers b/scwrypts/dotwryn/home/update-all-servers index f51fa48..8a1ef40 100755 --- a/scwrypts/dotwryn/home/update-all-servers +++ b/scwrypts/dotwryn/home/update-all-servers @@ -1,12 +1,6 @@ #!/bin/zsh -DEPENDENCIES+=( - hostnamectl -) -REQUIRED_ENV+=( - WRYN__SERVER_HOSTNAMES -) - -CHECK_ENVIRONMENT +DEPENDENCIES+=(hostnamectl) +REQUIRED_ENV+=(WRYN__SERVER_HOSTNAMES) ##################################################################### SESSION='update' @@ -60,38 +54,38 @@ CURRENT_SESSION=$(\ ##################################################################### -CHECK_SESSION && FAIL 1 'update currently in progress' +MAIN() { + CHECK_SESSION && FAIL 1 'update currently in progress' -tmux new -d -s $SESSION "echo 'updating all systems'; echo '(leave this window open)'; while true; do sleep 30; done" + tmux new -d -s $SESSION "echo 'updating all systems'; echo '(leave this window open)'; while true; do sleep 30; done" -yN 'after update, do you want to reboot all machines?' && REBOOT=1 || REBOOT=0 -REMINDER -REMINDER 'manual action is required; (in another tab) connect to tmux:' -REMINDER "tmux a -t $SESSION" -REMINDER -REMINDER 'to stop the update at any time, run:' -REMINDER "tmux kill-session -t $SESSION" -REMINDER + yN 'after update, do you want to reboot all machines?' && REBOOT=1 || REBOOT=0 + REMINDER " + manual action is required; (in another tab) connect to tmux: + tmux a -t $SESSION -[ $CURRENT_SESSION ] && { - SUCCESS 'currently in a tmux session; opening new window...' - tmux new-window -t $CURRENT_SESSION "unset TMUX; tmux a -t $SESSION" + to stop the update at any time, run: + tmux kill-session -t $SESSION + " + + [ $CURRENT_SESSION ] && { + SUCCESS 'currently in a tmux session; opening new window...' + tmux new-window -t $CURRENT_SESSION "unset TMUX; tmux a -t $SESSION" + } + + UPDATE_ALL 'yay -Syu' + UPDATE_ALL 'cd ~/.wryn; git pull --autostash' + UPDATE_ALL '~/.wryn/bin/scwrypts config update' + UPDATE_ALL '~/.wryn/bin/scwrypts media push' + UPDATE_ALL '~/.wryn/bin/scwrypts media pull' + UPDATE_ALL 'command -v i3-msg >/dev/null 2>&1 || exit 0; ~/.wryn/bin/scwrypts i3 font override' + + [[ $REBOOT -eq 1 ]] && UPDATE_ALL 'reboot || sudo reboot' + + tmux kill-session -t $SESSION >/dev/null 2>&1 + CHECK_SESSION && WARNING "unable to close tmux session '$SESSION'" + + SUCCESS " \nfinished system update accross all servers\n " + + [[ $REBOOT -eq 1 ]] && { STATUS 'rebooting host machine'; sleep 3; reboot || sudo reboot; } } - -UPDATE_ALL 'yay -Syu' -UPDATE_ALL 'cd ~/.wryn; git pull --autostash' -UPDATE_ALL '~/.wryn/bin/scwrypts config update' -UPDATE_ALL '~/.wryn/bin/scwrypts media push' -UPDATE_ALL '~/.wryn/bin/scwrypts media pull' -UPDATE_ALL 'command -v i3-msg >/dev/null 2>&1 || exit 0; ~/.wryn/bin/scwrypts i3 font override' - -[[ $REBOOT -eq 1 ]] && UPDATE_ALL 'reboot || sudo reboot' - -tmux kill-session -t $SESSION >/dev/null 2>&1 -CHECK_SESSION && WARNING "unable to close tmux session '$SESSION'" - -SUCCESS -SUCCESS 'finished system update accross all servers' -SUCCESS - -[[ $REBOOT -eq 1 ]] && { STATUS 'rebooting host machine'; sleep 3; reboot || sudo reboot; } diff --git a/scwrypts/ssh/connect/ssh b/scwrypts/ssh/connect/ssh index c48c9ec..2559f14 100755 --- a/scwrypts/ssh/connect/ssh +++ b/scwrypts/ssh/connect/ssh @@ -1,13 +1,6 @@ #!/bin/zsh -##################################################################### - -DEPENDENCIES+=() -REQUIRED_ENV+=() - use ssh --group remote CHECK_ENVIRONMENT -##################################################################### - REMOTE__LOGIN $@ diff --git a/scwrypts/ssh/connect/tmux b/scwrypts/ssh/connect/tmux index 43a2538..39e1b18 100755 --- a/scwrypts/ssh/connect/tmux +++ b/scwrypts/ssh/connect/tmux @@ -1,13 +1,6 @@ #!/bin/zsh -##################################################################### - -DEPENDENCIES+=() -REQUIRED_ENV+=() - use tmux --group remote CHECK_ENVIRONMENT -##################################################################### - REMOTE_CONNECT_TMUX $@ diff --git a/scwrypts/ssh/connect/xserver b/scwrypts/ssh/connect/xserver index 0e3b7d1..13fedde 100755 --- a/scwrypts/ssh/connect/xserver +++ b/scwrypts/ssh/connect/xserver @@ -1,13 +1,6 @@ #!/bin/zsh -##################################################################### - -DEPENDENCIES+=() -REQUIRED_ENV+=() - use ssh --group remote CHECK_ENVIRONMENT -##################################################################### - REMOTE_ARGS=(-Y) REMOTE__LOGIN $@ diff --git a/scwrypts/ssh/omni/launcher b/scwrypts/ssh/omni/launcher index d5aeae7..1409b76 100755 --- a/scwrypts/ssh/omni/launcher +++ b/scwrypts/ssh/omni/launcher @@ -1,13 +1,9 @@ #!/bin/zsh - -##################################################################### - DEPENDENCIES+=( tmux hostnamectl scwrypts # must be on path ) -REQUIRED_ENV+=() CHECK_ENVIRONMENT diff --git a/scwrypts/ssh/omni/spawn b/scwrypts/ssh/omni/spawn index 89ce919..1babd9d 100755 --- a/scwrypts/ssh/omni/spawn +++ b/scwrypts/ssh/omni/spawn @@ -1,12 +1,5 @@ #!/bin/zsh - -##################################################################### - -DEPENDENCIES+=() -REQUIRED_ENV+=() - CHECK_ENVIRONMENT - ##################################################################### [[ $TERM =~ tmux ]] && FAIL 69 "\n Cannot run tmux-omni within a tmux session!\n "