.,-:::::/     ...      :::.:::::::::::::::::::::.:::::::..       :::.    :::..-:::::':::.   :::::::..  .        :   
,;;-'````'   .;;;;;;;.   ;;`;;;;;;;;;''''`;;;```.;;;;;;``;;;;   ,;;`;;;;,  `;;;;;;'''' ;;`;;  ;;;;``;;;; ;;,.    ;;;  
[[[   [[[[[[,[[     \[[,,[[ '[[,  [[      `]]nnn]]' [[[,/[[[' ,['  [n[[[[[. '[[[[[,,==,[[ '[[, [[[,/[[[' [[[[, ,[[[[, 
"$$c.    "$$$$$,     $$c$$$cc$$$c $$       $$$""    $$$$$$c   $$    $$$$ "Y$c$$`$$$"`c$$$cc$$$c$$$$$$c   $$$$$$$$"$$$ 
 `Y8bo,,,o88"888,_ _,88P888   888,88,      888o     888b "88boY8,  ,8888    Y8d8888   888   888888b "88bo888 Y88" 888o
   `'YMUP"YMM "YMMMMMP" YMM   ""` MMM      YMMMb    MMMM   "W" "YmmP MMM     YYM"MM,  YMM   ""`MMMM   "W"MMM  M'  "MMM

BSPWM - Moving windows out of the way

This time I want to show you my attempt on a Scratchpad like feature for BSPWM. It is not exactly a Scratchpad like the one of the I3 window manager, but you could easily modify my code to make it more Scratchpadly (Scratchpad windows are hidden and floating, I don’t care about floating).

I added the following keyboard shortcuts to my sxhkrc. The first one hides the current focused window. The second shortcut helps me to find the hidden window I want to unhide.

Code sxhkrc:

# hide window
super + period
    bspc node -g hidden

# unhide window
super + ctrl + period
    ${HOME}/.config/bspwm/bspcmd unhide

If I want to get a previously hidden window back, I hit the defined shortcut and the script bspcmd with the parameter unhide is called.

The bspcmd file is a bash script containing a set of functions to improve my workflow with BSPWM. For this post, I have shortened it to only show the necessary parts, when executed with unhide as parameter.

The script also requires two additional programms:

  • xtitle output the window title of the given window ID (WID)
  • rofi a window switcher, application launcher and dmenu replacement

Code bspcmd:


CMD=${1:-help}; shift

help() {
    echo "Available commands:"
    echo "  * unhide - select and unhide window"

unhide() {
    case $action in
            selection=`for id in $(bspc query -N -n .hidden); do
                title=$(xtitle $id)
                [[ -z "$title" ]] && title="<unnamed>"
                echo $id $title
            done | rofi -dmenu -i -p "Hidden windows" | cut -f1 -d' '`
            [[ -z "$selection" ]] && exit 1

            bspc node $selection -g hidden=off

case $CMD in
        unhide $1

The unhide() function gathers all hidden windows, looks up the window title (if available) and displays a list using Rofi. On selecting a list entry, the hidden flag will be removed for that particular window so it will be displayed again.