Created
October 15, 2022 03:06
-
-
Save benyaminl/ded0c2715b34a05cf176f98dee9375b3 to your computer and use it in GitHub Desktop.
GVIM toggle view or hide based on workspace, will start gvim if on that workspace there are no gvim. Useful to mimic AHK on Linux using WMCTRL. Tested on Fedora 36
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/bash | |
DESKTOP=$(wmctrl -d | grep "*" | awk --field-separator=" " '{print $1}') | |
STATUS=$(wmctrl -l | grep " $DESKTOP " | grep -i gvim | wc -l) | |
WIN=$(wmctrl -l | grep " $DESKTOP " | grep -i gvim | awk '{print $4}') | |
# zenity --notification --text="$STATUS $DESKTOP $WIN" | |
if [ $STATUS -gt 0 ] | |
then | |
activeWindow=$(xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | cut -d '"' -f 2) | |
# zenity --notification --text="$activeWindow" | |
if [[ $activeWindow =~ "GVIM" ]] | |
then | |
wmctrl -r $WIN -b toggle,hidden | |
else | |
wmctrl -a $WIN | |
fi | |
else | |
/usr/bin/gvim | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment