#+TITLE: Other useful Spectrwm scripts #+author: joelchrono12 header-args :tangle yes * My spectrwm scripts These are other kinds of scripts that you can use alongside my main [[./bar.org][baraction.sh]] script. They make use of ~wmctrl~ to add some level of functionality to Spectrwm. Here are the scripts! Once generated, make sure to do the following command to make them executable! #+begin_example chmod +x file.sh #+end_example * Keep trayer on workspace This script makes sure that trayer or any system tray or application stays in your current workspace. Spectrwm does not work very well with these kinda programs, and this solution is still kinda hacky, which is why its not part of my main script. If it does not work, sorry. #+begin_src bash :tangle keep-trayer-ws.sh #!/bin/bash current_ws="$(wmctrl -d | grep '*' | awk '{print $1}')" wmctrl -r panel -t $current_ws #+end_src * Number of windows in workspace A simple script that shows how many windows are open inside of current workspace #+begin_src bash :tangle workspace-windows.sh #!/bin/bash ws_icon="$(wmctrl -d | grep "*" | awk '{print $9}')" windows_number="$(wmctrl -l | grep -v panel | awk '{print $2}'))" current_ws="$(wmctrl -d | grep '*' | awk '{print $1}')" windows_in_ws="$(echo -e "$windows_number" | grep $current_ws | wc -l)" echo -e "[$ws_icon ] [$windows_in_ws]" #+end_src * Volume control I normally use the ~volumeicon~ to take care of this, or ~pamixer~ on a terminal, but this script can do it too!, kinda... Make sure to add this line to beginning or the main bar script #+begin_example trap 'update' 5 #+end_example And this is the script itself. #+begin_src bash :tangle volume-spectrwm.sh #!/bin/bash volumecontrol() { pkill -SIGTRAP baraction.sh case $1 in increase) amixer set Master 5%+ ;; ecrease) amixer set Master 5%- ;; toggle) amixer set Master toggle ;; ,*) ;; esac; } volumecontrol $1 #+end_src