144 lines
6 KiB
Bash
Executable file
144 lines
6 KiB
Bash
Executable file
#!/bin/sh
|
|
# speedwm-utils
|
|
# Because controlling speedwm using shell scripts is based.
|
|
# Licensed under GNU GPLv3.
|
|
|
|
case "$RUNLAUNCHER" in
|
|
"") RUNLAUNCHER=dmenu # Run launcher to use (dmenu, rofi, etc.) ;;
|
|
esac
|
|
|
|
HAVE_GRID="true"
|
|
if [ -e "$HOME/.config/speedwm-de/global/config" ]; then
|
|
. $HOME/.config/speedwm-de/global/config
|
|
else
|
|
mkdir -p $HOME/.config/speedwm-de/global
|
|
printf "HAVE_GRID=$HAVE_GRID # Whether or not to use the Grid argument. If you do not have the dmenu grid patch, set this to false. Doing so will disable grid." > $HOME/.config/speedwm-de/global/config
|
|
fi
|
|
|
|
if [ "$HAVE_GRID" = "true" ]; then
|
|
GRIDNUM="1"
|
|
fi
|
|
|
|
if [ "$HAVE_GRID" = "true" ]; then
|
|
GRIDARG="-g"
|
|
fi
|
|
|
|
VARS() {
|
|
BINDIR=$(cat /usr/share/speedwm-bindir)
|
|
|
|
SIGNAL_1=1 # Layout: Tiling
|
|
SIGNAL_2=2 # Layout: Floating
|
|
SIGNAL_3=3 # Layout: Monocle
|
|
SIGNAL_4=4 # Layout: Grid
|
|
SIGNAL_5=5 # Layout: Deck
|
|
SIGNAL_6=6 # Layout: Centered Master
|
|
SIGNAL_7=7 # Layout: Centered Floating Master
|
|
SIGNAL_8=8 # Layout: Fibonacci Spiral
|
|
SIGNAL_9=9 # Layout: Fibonacci Dwindle
|
|
SIGNAL_10=10 # Layout: Three Column
|
|
SIGNAL_11=11 # Layout: Bottom Stack Vertical
|
|
SIGNAL_12=12 # Layout: Bottom Stack Horizontal
|
|
SIGNAL_13=13 # Layout: Horizontal Grid
|
|
SIGNAL_14=14 # Layout: Tatami
|
|
SIGNAL_15=15 # Layout: Tilewide
|
|
SIGNAL_16=16 # Layout: Previous
|
|
SIGNAL_17=17 # Layout: Next
|
|
SIGNAL_18=18 # General: Reload resources (xrdb)
|
|
SIGNAL_19=19 # General: Set mfact (-0.05)
|
|
SIGNAL_20=20 # General: Set mfact (+0.05)
|
|
SIGNAL_21=21 # General: Toggle Scratchpad
|
|
SIGNAL_22=22 # General: Toggle Sticky
|
|
SIGNAL_23=23 # General: Toggle Bar
|
|
SIGNAL_24=24 # General: Toggle Fullscreen
|
|
SIGNAL_25=25 # General: Restart speedwm
|
|
SIGNAL_26=26 # Unused: Unused 26
|
|
SIGNAL_27=27 # Layout: Stairs
|
|
SIGNAL_28=28 # General: Reset layout/mfact
|
|
SIGNAL_29=29 # General: Reorganize Tags
|
|
SIGNAL_30=30 # General: Quit speedwm
|
|
SIGNAL_31=31 # General: Restart speedwm
|
|
SIGNAL_32=32 # Unused: Unused 32
|
|
SIGNAL_33=33 # Unused: Unused 33
|
|
SIGNAL_34=34 # Unused: Unused 34
|
|
SIGNAL_35=35 # Layout: Tiling 5:4
|
|
SIGNAL_36=36 # Layout: Columns
|
|
SIGNAL_37=37 # Layout: Dynamic Grid
|
|
}
|
|
|
|
VARS
|
|
|
|
GENERAL() {
|
|
GENERALOPTS=$(printf "mfact +\nmfact -\nToggle Scratchpad\nToggle Sticky\nToggle Bar\nToggle Fullscreen\nToggle rmaster\nReset Layout/mfact\nReorganize Tags" | $RUNLAUNCHER -l 20 -p 'What do you want to do?')
|
|
case "$GENERALOPTS" in
|
|
"mfact +") xsetroot -name "fsignal:$SIGNAL_20" ;;
|
|
"mfact -") xsetroot -name "fsignal:$SIGNAL_19" ;;
|
|
"Toggle Scratchpad") xsetroot -name "fsignal:$SIGNAL_21" ;;
|
|
"Toggle Sticky") xsetroot -name "fsignal:$SIGNAL_22" ;;
|
|
"Toggle Bar") xsetroot -name "fsignal:$SIGNAL_23" ;;
|
|
"Toggle Fullscreen") xsetroot -name "fsignal:$SIGNAL_24" ;;
|
|
"Toggle rmaster") xsetroot -name "fsignal:$SIGNAL_26" ;;
|
|
"Reorganize Tags") xsetroot -name "fsignal:$SIGNAL_29" ;;
|
|
"Reset Layout/mfact") xsetroot -name "fsignal:$SIGNAL_28" ;;
|
|
esac
|
|
}
|
|
|
|
OPT() {
|
|
MENUOPTS=$(printf "Layout\nReload .Xresources\nSpawn\nGeneral\nExit" | $RUNLAUNCHER -l 20 -p 'What do you want to do?')
|
|
|
|
case "$MENUOPTS" in
|
|
"Layout") ${0} -layout $2 && exit 0 ;;
|
|
"Reload .Xresources") ${0} -reloadxrdb && exit 0 ;;
|
|
"Spawn") ${0} -spawn $2 && exit 0 ;;
|
|
"General") ${0} -general $2 && exit 0 ;;
|
|
"Exit") exit 0 ;;
|
|
esac
|
|
}
|
|
|
|
HELP() {
|
|
printf "speedwmutils allows you to control speedwm using your terminal or dmenu/rofi.\n-- Arguments --\n-layout | Let the user select a speedwm layout\n-reloadxrdb | Reload .Xresources\n-spawn | Spawn a command through speedwm\n-exec | Execute an fsignal signum\n-list | List all available signums\n" > /tmp/speedwm-printed-help
|
|
pgrep -x $RUNLAUNCHER || cat /tmp/speedwm-printed-help
|
|
pgrep -x $RUNLAUNCHER && cat /tmp/speedwm-printed-help | $RUNLAUNCHER -p 'speedwmutils help' $GRIDARG $GRIDNUM -l 20
|
|
}
|
|
|
|
case "$1" in
|
|
"-layout") SEL_LAYOUT=$(printf "L1: Tiling\nL2: Floating\nL3: Monocle\nL4: Grid\nL5: Deck\nL6: Centered Master\nL7: Centered Floating Master\nL8: Fibonacci Spiral\nL9: Fibonacci Dwindle\nL10: Three Column\nL11: Bottom Stack Vertical\nL12: Bottom Stack Horizontal\nL13: Horizontal Grid\nL14: Tatami\nL15: Tilewide\nL16: Stairs\nL17: Tiling (5:4)\nL18: Column\nL19: Dynamic Grid\nPrevious Layout\nNext Layout" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;;
|
|
"-spawn") printf "Not complete" ;;
|
|
"-list") sed 's|xsetroot -name "fsignal:||g' /usr/share/speedwm-fsignal | sed 's|"||g' ;;
|
|
"-reloadxrdb") xsetroot -name "fsignal:$SIGNAL_18" ;;
|
|
"-help") HELP ;;
|
|
"-exec")
|
|
if [ "$2" = "" ]; then
|
|
exit 0
|
|
else
|
|
xsetroot -name "fsignal:$2"
|
|
fi ;;
|
|
"-h") HELP ;;
|
|
"-general") GENERAL ;;
|
|
"") OPT ;;
|
|
esac
|
|
|
|
case "$SEL_LAYOUT" in
|
|
"Exit") exit 0 ;;
|
|
"L1: Tiling") xsetroot -name "fsignal:$SIGNAL_1" ;;
|
|
"L2: Floating") xsetroot -name "fsignal:$SIGNAL_2" ;;
|
|
"L3: Monocle") xsetroot -name "fsignal:$SIGNAL_3" ;;
|
|
"L4: Grid") xsetroot -name "fsignal:$SIGNAL_4" ;;
|
|
"L5: Deck") xsetroot -name "fsignal:$SIGNAL_5" ;;
|
|
"L6: Centered Master") xsetroot -name "fsignal:$SIGNAL_6" ;;
|
|
"L7: Centered Floating Master") xsetroot -name "fsignal:$SIGNAL_7" ;;
|
|
"L8: Fibonacci Spiral") xsetroot -name "fsignal:$SIGNAL_8" ;;
|
|
"L9: Fibonacci Dwindle") xsetroot -name "fsignal:$SIGNAL_9" ;;
|
|
"L10: Three Column") xsetroot -name "fsignal:$SIGNAL_10" ;;
|
|
"L11: Bottom Stack Vertical") xsetroot -name "fsignal:$SIGNAL_11" ;;
|
|
"L12: Bottom Stack Horizontal") xsetroot -name "fsignal:$SIGNAL_12" ;;
|
|
"L13: Horizontal Grid") xsetroot -name "fsignal:$SIGNAL_13" ;;
|
|
"L14: Tatami") xsetroot -name "fsignal:$SIGNAL_14" ;;
|
|
"L15: Tilewide") xsetroot -name "fsignal:$SIGNAL_15" ;;
|
|
"L16: Stairs") xsetroot -name "fsignal:$SIGNAL_27" ;;
|
|
"L17: Tiling (5:4)") xsetroot -name "fsignal:$SIGNAL_35" ;;
|
|
"L18: Column") xsetroot -name "fsignal:$SIGNAL_36" ;;
|
|
"L19: Dynamic Grid") xsetroot -name "fsignal:$SIGNAL_37" ;;
|
|
"Previous Layout") xsetroot -name "fsignal:$SIGNAL_16" ;;
|
|
"Next Layout") xsetroot -name "fsignal:$SIGNAL_17" ;;
|
|
esac
|