aboutsummaryrefslogtreecommitdiffstats
path: root/polybar
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-04-26 16:17:45 -0700
committerGravatar Tom Willemse2020-04-26 16:17:45 -0700
commit4b637506d971a4c1c05bd3e85ceee0ad923fc72e (patch)
treeb39e54e137ed8d57092148d50f3c97bd94800d0b /polybar
parente67f221c21c6719c8d17d74ee58e0ddc38689532 (diff)
downloadnew-dotfiles-4b637506d971a4c1c05bd3e85ceee0ad923fc72e.tar.gz
new-dotfiles-4b637506d971a4c1c05bd3e85ceee0ad923fc72e.zip
Automatically hide polybar if necessary
xfreerdp doesn’t seem to play nice with Polybar, so hide Polybar whenever xfreerdp is focused.
Diffstat (limited to 'polybar')
-rwxr-xr-xpolybar/.config/herbstluftwm/autostart.d/polybar.sh2
-rwxr-xr-xpolybar/usr/bin/autohide-polybar.sh21
2 files changed, 22 insertions, 1 deletions
diff --git a/polybar/.config/herbstluftwm/autostart.d/polybar.sh b/polybar/.config/herbstluftwm/autostart.d/polybar.sh
index bec6eb7..3dd29ab 100755
--- a/polybar/.config/herbstluftwm/autostart.d/polybar.sh
+++ b/polybar/.config/herbstluftwm/autostart.d/polybar.sh
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
-pgrep polybar || { polybar "$(hostname)" 2> /dev/null & }
+pgrep polybar || { autohide-polybar.sh && polybar "$(hostname)" 2> /dev/null & }
diff --git a/polybar/usr/bin/autohide-polybar.sh b/polybar/usr/bin/autohide-polybar.sh
new file mode 100755
index 0000000..1b0e0d7
--- /dev/null
+++ b/polybar/usr/bin/autohide-polybar.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+# Has to start with my_ or herbstluftwm will throw up.
+attr_name=my_polybar_showing
+
+herbstclient get_attr "$attr_name" 1> /dev/null 2>&1 \
+ || herbstclient new_attr bool "$attr_name"
+herbstclient set_attr "$attr_name" true
+
+herbstclient -i focus_changed | while read -r _ winid _; do
+ window_class=$(herbstclient attr "clients.${winid}.class")
+ showing_polybar=$(herbstclient attr "$attr_name")
+
+ if [[ $window_class =~ xfreerdp ]]; then
+ polybar-msg cmd hide > /dev/null \
+ && herbstclient set_attr "$attr_name" false
+ elif [[ $showing_polybar == "false" ]]; then
+ polybar-msg cmd show > /dev/null \
+ && herbstclient set_attr "$attr_name" true
+ fi
+done &