toggleShowDesktop for Labwc

toggleShowDesktop is a handy Openbox action which currently is not implemented in Labwc yet.

Usually bound to W-d or/and optionally to mouse left-click on desktop.

Replacement script for Labwc using wlrctl utility.
toggleShowDesktop:

#!/bin/bash
# toggleShowDesktop - Openbox's missing action for Labwc

CACHE_FILE="$HOME/.cache/.tsd"

# If any window is unminimized 
if wlrctl window find state:unminimized; then
	# fill CACHE_FILE with unminimized windows list
	wlrctl window list state:unminimized > $CACHE_FILE
    # minimize all unminimized
	wlrctl window minimize state:unminimized
else # no unminimized windows: read list and unminimize (focus) all
	while IFS=':' read -r app_id title; do
		wlrctl window focus app_id:$app_id state:minimized
	done < "$CACHE_FILE"
	> "$CACHE_FILE"
fi

rc.xml

Keybind:

<keybind key="W-d">
    <action name="Execute" command="toggleShowDesktop"/>
</keybind>

Optional mouse bind for left click on Desktop action.
Put it into <context name="Root"> section:

<mousebind button="Left" action="Press">
      <action name="Execute" command="toggleShowDesktop"/>
</mousebind>

The toggle desktop and runraise (hide) scripts are really nice. :slight_smile:

Note.
Still have to fill in full path to ~/bin.
Thats fine, now knowing.

Copied the dot files to my laptop and it runs nice.
Fast response. Even with gif anim as background.

:bird:

Only small drawback… sometimes it changes windows stacking order. No big deal.
Anyway, it’s good to have it until it’s implemented natively in Labwc.
Here is open issue for it on Labwc github.

1 Like