#!/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="$(dirname $(command -v status))/" } VARS GENERAL() { GENERALOPTS=$(printf "mfact +\nmfact -\nToggle Sticky\nToggle Bar\nToggle Fullscreen\nReset Layout/mfact\nReorganize Tags" | $RUNLAUNCHER -l 20 -p 'What do you want to do?') case "$GENERALOPTS" in "mfact +") speedwm -s "#cmd:18" ;; "mfact -") speedwm -s "#cmd:19" ;; "Toggle Sticky") speedwm -s "#cmd:20" ;; "Toggle Bar") speedwm -s "#cmd:21" ;; "Toggle Fullscreen") speedwm -s "#cmd:22" ;; "Reorganize Tags") speedwm -s "#cmd:25" ;; "Reset Layout/mfact") speedwm -s "#cmd:59" ;; esac } OPT() { MENUOPTS=$(printf "Layout\nReload .Xresources\nGeneral\nExit" | $RUNLAUNCHER -l 20 -p 'What do you want to do?') case "$MENUOPTS" in "Layout") ${0} layout $2 && exit 0 ;; "Reload .Xresources") ${0} reloadcolors && exit 0 ;; "General") ${0} -general $2 && exit 0 ;; "Exit") exit 0 ;; esac } HELP() { printf "speedwm-utils - Control speedwm using your terminal or dmenu.\n" printf "\nlayout Let the user select a speedwm layout" printf "\nreloadcolors Reload .Xresources" printf "\nexec Execute an fsignal signum" printf "\nlist List all available signums" printf "\n" } L1="$(printf "L1: Tiling\n")" L2="$(printf "L2: Floating\n")" L3="$(printf "L3: Monocle\n")" L4="$(printf "L4: Grid\n")" L5="$(printf "L5: Deck\n")" L6="$(printf "L6: Centered Master\n")" L7="$(printf "L7: Centered Floating Master\n")" L8="$(printf "L8: Dwindle\n")" L9="$(printf "L9: Spiral\n")" L10="$(printf "L10: Bottom Stack (Vertical)\n")" L11="$(printf "L11: Bottom Stack (Horizontal)\n")" L12="$(printf "L12: Grid (Horizontal)\n")" L13="$(printf "L13: Dynamic Grid\n")" L14="$(printf "L14: Custom\n")" case "$1" in "layout") SEL_LAYOUT=$(printf "${L1}\n${L2}\n${L3}\n${L4}\n${L5}\n${L6}\n${L7}\n${L8}\n${L9}\n${L10}\n${L11}\n${L12}\n${L13}\n${L14}\nPrevious Layout\nNext Layout\nEnter S expression" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;; "reloadcolors") speedwm -s "#cmd:65" ;; "list") sed 's|speedwm -s "#cmd:||g; s|"||g; s| - ||g; s@|@-@g' /usr/share/speedwm/example.signal | head -n "$(expr "$(cat /usr/share/speedwm/example.signal | wc -l)" - 1)" ;; "-help") HELP ;; "exec") if [ "$2" = "" ]; then exit 0 else speedwm -s "#cmd:$2" fi ;; "-h") HELP ;; "-general") GENERAL ;; "") OPT ;; esac case "$SEL_LAYOUT" in "Exit") exit 0 ;; "Previous Layout") speedwm -s "#cmd:16" ;; "Next Layout") speedwm -s "#cmd:17" ;; "L1: Tiling") speedwm -s "#cmd:1" ;; "L2: Floating") speedwm -s "#cmd:2" ;; "L3: Monocle") speedwm -s "#cmd:3" ;; "L4: Grid") speedwm -s "#cmd:4" ;; "L5: Deck") speedwm -s "#cmd:5" ;; "L6: Centered Master") speedwm -s "#cmd:6" ;; "L7: Centered Floating Master") speedwm -s "#cmd:7" ;; "L8: Dwindle") speedwm -s "#cmd:8" ;; "L9: Spiral") speedwm -s "#cmd:9" ;; "L10: Bottom Stack (Vertical)") speedwm -s "#cmd:10" ;; "L11: Bottom Stack (Horizontal)") speedwm -s "#cmd:11" ;; "L12: Grid (Horizontal)") speedwm -s "#cmd:12" ;; "L13: Dynamic Grid") speedwm -s "#cmd:13" ;; "L14: Custom") speedwm -s "#cmd:1" && speedwm -s "#cmd:17" ;; "Enter S expression") speedwm -s "#cmd:15" ;; esac