#!/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) } VARS GENERAL() { GENERALOPTS=$(printf "mfact +\nmfact -\nToggle Scratchpad\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:22" ;; "mfact -") xsetroot -name "fsignal:23" ;; "Toggle Scratchpad") xsetroot -name "fsignal:60" ;; "Toggle Sticky") xsetroot -name "fsignal:24" ;; "Toggle Bar") xsetroot -name "fsignal:25" ;; "Toggle Fullscreen") xsetroot -name "fsignal:26" ;; "Reorganize Tags") xsetroot -name "fsignal:29" ;; "Reset Layout/mfact") xsetroot -name "fsignal:63" ;; 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" } # Source layout data if [ -e "/usr/share/speedwm/layouts" ]; then . /usr/share/speedwm/layouts fi # Tile if [ "$LAYOUT_TILE" = "1" ]; then L1="$(printf "L1: Tiling\n")" fi # Tile (5:4) if [ "$LAYOUT_TILE54" = "1" ]; then L17="$(printf "L17: Tiling (5:4)\n")" fi # Monocle if [ "$LAYOUT_MONOCLE" = "1" ]; then L3="$(printf "L3: Monocle\n")" fi # Grid if [ "$LAYOUT_GRID" = "1" ]; then L4="$(printf "L4: Grid\n")" fi # Dwindle if [ "$LAYOUT_DWINDLE" = "1" ]; then L9="$(printf "L8: Dwindle\n")" fi # Spiral if [ "$LAYOUT_SPIRAL" = "1" ]; then L8="$(printf "L8: Spiral\n")" fi # Three Columns if [ "$LAYOUT_TCL" = "1" ]; then L10="$(printf "L10: Three Columns\n")" fi # Bottom Stack if [ "$LAYOUT_BSTACK" = "1" ]; then L11="$(printf "L11: Bottom Stack Vertical\n")" fi # Horizontal Bottom Stack if [ "$LAYOUT_BSTACKH" = "1" ]; then L12="$(printf "L12: Bottom Stack Horizontal\n")" fi # Horizontal Grid if [ "$LAYOUT_HGRID" = "1" ]; then L13="$(printf "L13: Horizontal Grid\n")" fi # Dynamic Grid if [ "$LAYOUT_DGRID" = "1" ]; then L19="$(printf "L19: Dynamic Grid\n")" fi # Tatami if [ "$LAYOUT_TATAMI" = "1" ]; then L14="$(printf "L14: Tatami\n")" fi # Tilewide if [ "$LAYOUT_TW" = "1" ]; then L15="$(printf "L15: Tilewide\n")" fi # Centered Master if [ "$LAYOUT_CM" = "1" ]; then L6="$(printf "L6: Centered Master\n")" fi # Centered Floating Master if [ "$LAYOUT_CFM" = "1" ]; then L7="$(printf "L7: Centered Floating Master\n")" fi # Deck if [ "$LAYOUT_DECK" = "1" ]; then L5="$(printf "L5: Deck\n")" fi # Columns if [ "$LAYOUT_COL" = "1" ]; then L18="$(printf "L18: Column\n")" fi # Stairs if [ "$LAYOUT_STAIRS" = "1" ]; then L16="$(printf "L16: Stairs\n")" fi case "$1" in "layout") SEL_LAYOUT=$(printf "${L1}\nL2: Floating\n${L3}\n${L4}\n${L5}\n${L6}\n${L7}\n${L8}\n${L9}\n${L10}\n${L11}\n${L12}\n${L13}\n${L14}\n${L15}\n${L16}\n${L17}\n${L18}\n${L19}\nPrevious Layout\nNext Layout" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;; "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)" ;; "reloadcolors") xsetroot -name "fsignal:31" ;; "-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: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: Fibonacci Spiral") xsetroot -name "fsignal:8" ;; "L9: Fibonacci Dwindle") xsetroot -name "fsignal:9" ;; "L10: Three Column") xsetroot -name "fsignal:10" ;; "L11: Bottom Stack Vertical") xsetroot -name "fsignal:11" ;; "L12: Bottom Stack Horizontal") xsetroot -name "fsignal:12" ;; "L13: Horizontal Grid") xsetroot -name "fsignal:13" ;; "L14: Tatami") xsetroot -name "fsignal:14" ;; "L15: Tilewide") xsetroot -name "fsignal:15" ;; "L16: Stairs") xsetroot -name "fsignal:16" ;; "L17: Tiling (5:4)") xsetroot -name "fsignal:17" ;; "L18: Column") xsetroot -name "fsignal:18" ;; "L19: Dynamic Grid") xsetroot -name "fsignal:19" ;; "Previous Layout") xsetroot -name "fsignal:21" ;; "Next Layout") xsetroot -name "fsignal:20" ;; esac