Last active
October 20, 2023 00:04
-
-
Save danielclough/1b4a44c43d75f08078c14a27e8708983 to your computer and use it in GitHub Desktop.
Use wmctrl and xprop to toggle Alacritty.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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