Run Raise or Hide for Labwc

A very useful script to make yourself a Quick Terminal - show and hide with one key.
Or for less frequently used programs that you want to launch and hide, and then quickly call up when needed. For example, the music player, internet radio (like audacious or pyradio)

Good companion for Run or Raise

Three actions for one key:

  • launching the program
  • hiding it
  • and showing it again

(In Mabox Openbox, a similar mechanism is used for Quake terminal F12 and Pyradio W-r)

runraisehide

#!/bin/bash
# runraisehide - run or raise and hide 

[[ -z "$1" ]] && echo "Usage: ${0##*/} executable" && exit 1

# if active -> minimize
wlrctl window find ${1} state:active && wlrctl window minimize ${1} && exit 0

# if minimized or inactive -> give focus 
wlrctl window find ${1} state:minimized && wlrctl window focus ${1} && exit 0
wlrctl window find ${1} state:inactive && wlrctl window focus ${1} && exit 0
${1} 2>&1 &
disown

rc.xml

Assign programs to keys in ~/.config/labwc/rc.xml

<keybind key="F12" name.action="Execute" command.action="runraisehide foot"/>
<keybind key="W-r" name.action="Execute" command.action="runraisehide pyradio"/>
1 Like