Skip to content

Instantly share code, notes, and snippets.

@danielclough
Last active October 20, 2023 00:04
Show Gist options
  • Save danielclough/1b4a44c43d75f08078c14a27e8708983 to your computer and use it in GitHub Desktop.
Save danielclough/1b4a44c43d75f08078c14a27e8708983 to your computer and use it in GitHub Desktop.
Use wmctrl and xprop to toggle Alacritty.
#!/bin/sh
PROGRAM_WINDOW_ID=`wmctrl -lx | tr -s ' ' | grep Alacritty | cut -f1 -d ' '`
# Start if not already started
[ -z ${PROGRAM_WINDOW_ID} ] && /usr/bin/alacritty
if [ -v $(xprop -id ${PROGRAM_WINDOW_ID} |grep _NET_WM_STATE_FOCUSED) ] ;
then
# Focused->Hidden
wmctrl -i -R "$PROGRAM_WINDOW_ID"
else
# Hidden/Unfocused->Focused
wmctrl -F -i -r "$PROGRAM_WINDOW_ID" -b toggle,hidden
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment