#!/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 +") xsetroot -name "fsignal:18" ;; "mfact -") xsetroot -name "fsignal:19" ;; "Toggle Sticky") xsetroot -name "fsignal:20" ;; "Toggle Bar") xsetroot -name "fsignal:21" ;; "Toggle Fullscreen") xsetroot -name "fsignal:22" ;; "Reorganize Tags") xsetroot -name "fsignal:25" ;; "Reset Layout/mfact") xsetroot -name "fsignal: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") xsetroot -name "fsignal:65" ;; "list") sed 's|xsetroot -name "fsignal:||g; s|"||g; s| - ||g; s@|@-@g' /usr/share/speedwm/example.fsignal | head -n "$(expr "$(cat /usr/share/speedwm/example.fsignal | wc -l)" - 1)" ;; "-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 ;; "Previous Layout") xsetroot -name "fsignal:16" ;; "Next Layout") xsetroot -name "fsignal:17" ;; "L1: Tiling") xsetroot -name "fsignal:1" ;; "L2: Floating") xsetroot -name "fsignal:2" ;; "L3: Monocle") xsetroot -name "fsignal:3" ;; "L4: Grid") xsetroot -name "fsignal:4" ;; "L5: Deck") xsetroot -name "fsignal:5" ;; "L6: Centered Master") xsetroot -name "fsignal:6" ;; "L7: Centered Floating Master") xsetroot -name "fsignal:7" ;; "L8: Dwindle") xsetroot -name "fsignal:8" ;; "L9: Spiral") xsetroot -name "fsignal:9" ;; "L10: Bottom Stack (Vertical)") xsetroot -name "fsignal:10" ;; "L11: Bottom Stack (Horizontal)") xsetroot -name "fsignal:11" ;; "L12: Grid (Horizontal)") xsetroot -name "fsignal:12" ;; "L13: Dynamic Grid") xsetroot -name "fsignal:13" ;; "L14: Custom") xsetroot -name "fsignal:1" && xsetroot -name "fsignal:17" ;; "Enter S expression") xsetroot -name "fsignal:15" ;; esac