Skip to content

Instantly share code, notes, and snippets.

@txtyash
Created July 20, 2022 10:17
Show Gist options
  • Save txtyash/8c412144283e783af120ea9f5dd994fa to your computer and use it in GitHub Desktop.
Save txtyash/8c412144283e783af120ea9f5dd994fa to your computer and use it in GitHub Desktop.
My scratchpad script in xmonad for handy stuff
#!/bin/bash
while true; do
action=x
clear
echo -ne "\n\t\tACTION?\n\n\tg(Go to)\tm(Move to)\n\tv(Vol)\t\tb(bright)\n\tk(kbd)\t\tt(touchpad)\n\tp(picom)\tn(network)"
read -r -n 1 action
clear
if [[ "$action" = "g" ]]; then
echo -ne "\n\n GO TO? a1 s2 q3 w4 d5 f6 e7 r8 t9:\n\n "
read -r -n 1 tag
case $tag in
a | 1) workspace=1 ;;
s | 2) workspace=2 ;;
q | 3) workspace=3 ;;
w | 4) workspace=4 ;;
d | 5) workspace=5 ;;
f | 6) workspace=6 ;;
e | 7) workspace=7 ;;
r | 8) workspace=8 ;;
* | 9) workspace=9 ;;
esac
xdotool key Super+$workspace
clear
elif [[ "$action" = "m" ]]; then
echo -ne "\n\n MOVE TO? \n a1 s2 q3 w4 d5 f6 e7 r8 t9:\n\n "
read -r -n 1 tag
case $tag in
a | 1) workspace=1 ;;
s | 2) workspace=2 ;;
q | 3) workspace=3 ;;
w | 4) workspace=4 ;;
d | 5) workspace=5 ;;
f | 6) workspace=6 ;;
e | 7) workspace=7 ;;
r | 8) workspace=8 ;;
* | 9) workspace=9 ;;
esac
xdotool key Super+j
xdotool key Super+Shift+$workspace
xdotool key Super+$workspace
clear
elif [[ "$action" = "v" ]]; then
while true; do
echo -ne "\n\n Change VOL? j(dec) k(inc) q(quit)\n m(mute) u(unmute):\n "
amixer get Master | tail -n 1
read -r -n 1 change
if [[ "$change" = "k" ]]; then
amixer set Master 3%+
clear
elif [[ "$change" = "j" ]]; then
amixer set Master 3%-
clear
elif [[ "$change" = "m" ]]; then
amixer set Master toggle
clear
elif [[ "$change" = "u" ]]; then
alsactl restore
clear
elif [[ "$change" != "q" ]]; then
clear
continue
else
break
fi
done
break
elif [[ "$action" = "b" ]]; then
while true; do
echo -ne "\n\n Change Brightness? j(dec) k(inc) q(quit):\n\n "
brightnessctl g
read -r -n 1 change
if [[ "$change" = "k" ]]; then
brightnessctl set 3%+
clear
elif [[ "$change" = "j" ]]; then
brightnessctl set 3%-
clear
elif [[ "$change" != "q" ]]; then
clear
continue
else
break
fi
done
break
elif [[ "$action" = "k" ]]; then
while true; do
echo -ne "\n\n Keyboard Backlight? j(dec) k(inc) q(quit):\n\n "
brightnessctl g --device="$(ls /sys/class/leds | rg kbd)"
read -r -n 1 change
if [[ "$change" = "k" ]]; then
brightnessctl --device="$(ls /sys/class/leds | rg kbd)" set 1+
clear
elif [[ "$change" = "j" ]]; then
brightnessctl --device="$(ls /sys/class/leds | rg kbd)" set 1-
clear
elif [[ "$change" != "q" ]]; then
clear
continue
else
break
fi
done
break
elif [[ "$action" = "t" ]]; then
toggle_touchpad
break
elif [[ "$action" = "w" ]]; then
feh --bg-scale --randomize ~/pictures/wallpapers/*
break
elif [[ "$action" = "p" ]]; then
/usr/bin/bash ~/.config/picom/picom-file-toggle.sh
break
elif [[ "$action" = "d" ]]; then
xset dpms force off
break
elif [[ "$action" = "n" ]]; then
nmtui
break
elif [[ "$action" = "q" ]]; then
break
else
echo -ne "\n\n BAD CHOICE"
sleep 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment