Skip to content

Instantly share code, notes, and snippets.

@bharadwaj-raju
Created August 13, 2016 19:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bharadwaj-raju/24aaea84e9421c9d86b8e435e3e744ba to your computer and use it in GitHub Desktop.
Save bharadwaj-raju/24aaea84e9421c9d86b8e435e3e744ba to your computer and use it in GitHub Desktop.
changes panel transparency depending on whether any window is maximized or not
#!/usr/bin/env bash
#-- CONFIGURATION
transparent_alpha=0
maximized_alpha=100
interval=0
#--
alpha_prop_list=()
for prop in $(xfconf-query -c xfce4-panel -p /panels -l); do
[[ "$prop" == *"background-alpha"* ]] && alpha_prop_list+=($prop)
done
on_maximized() {
for alpha_prop in "${alpha_prop_list[@]}"; do
xfconf-query -c xfce4-panel -p "$alpha_prop" -s "$maximized_alpha"
done
}
on_no_window_maximized() {
for alpha_prop in "${alpha_prop_list[@]}"; do
xfconf-query -c xfce4-panel -p "$alpha_prop" -s "$transparent_alpha"
done
}
echo $alpha_prop_list
while true; do
is_any_window_maximized=false
for i in $(wmctrl -l | awk '{ print $1 }'); do
status=$(xprop -id $i _NET_WM_STATE)
if [[ "$status" == *"MAXIMIZED"* && "$status" != *"HIDDEN"* ]]; then
is_any_window_maximized=true
break
else
is_any_window_maximized=false
fi
done
if [[ $is_any_window_maximized == true ]]; then
on_maximized
else
on_no_window_maximized
fi
sleep $interval
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment