Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Created May 18, 2022 02:26
Show Gist options
  • Save lopesivan/5db7acd2e640acf7bfe56a008b5e2834 to your computer and use it in GitHub Desktop.
Save lopesivan/5db7acd2e640acf7bfe56a008b5e2834 to your computer and use it in GitHub Desktop.
i3wm hide/show google-chrome
#!/bin/sh
if xwininfo -tree -root | grep -q "chrome"
then
echo "Window detected."
if xdo id -a "Google Chrome" >&- 2>&-;
then
map_state=$(xwininfo -all -id `xdo id -a "Google Chrome"` | grep "Map State"| cut -d\s -f2)
HIDE="xdo hide -a 'Google Chrome'"
SHOW="xdo show -a 'Google Chrome'"
fi
if xdo id -n google-chrome >&- 2>&-;
then
map_state=`xwininfo -all -id $(xdo id -n google-chrome) | grep "Map State"| cut -d\s -f2`
HIDE="xdo hide -n google-chrome"
SHOW="xdo show -n google-chrome"
fi
if [ "$map_state" = 'Viewable' ];
then
eval $HIDE
else
eval $SHOW
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment