Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Created May 18, 2022 02:23
Show Gist options
  • Save lopesivan/e39333357306d0874e1781bf38d832c4 to your computer and use it in GitHub Desktop.
Save lopesivan/e39333357306d0874e1781bf38d832c4 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
echo 111111
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'"
echo 111111
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
# ID=$(xdo id -n google-chrome)
# map_state=''
# if xdo id -a "Google Chrome" > /dev/null;
# echo 1111
# 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'"
# echo 1111
# then
# echo 2222
# 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"
# echo 2222
# fi
#
# if [ "$map_state" = 'Viewable' ];
# then
# echo 3333
# echo "Window detected."
# echo $HIDE
# echo 3333
# else
# echo 4444
# echo "Window not detected... spawning."
# echo $SHOW
# echo 4444
# fi
else
echo "Window not detected... spawning."
i3 "exec --no-startup-id chrome"
fi
# if [ "$map_state" = 'UnMapped' ];
# then
# echo "Window not detected... spawning."
# xdo show -N qutebrowser
# fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment