Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rouchage/48b735086ff8542a4abb7b20bd7afe02 to your computer and use it in GitHub Desktop.
Save rouchage/48b735086ff8542a4abb7b20bd7afe02 to your computer and use it in GitHub Desktop.
Changes XFCE panel transparency depending on whether any window on the current workspace is maximized or not #script
#!/usr/bin/env bash
### NOTE: Works on xfce 4.12 ###
#-- softs to install:
#-- xorg-xprop wmctrl
#-- Animation effect added by -> Rouchage
#-- CONFIGURATION
transparent_alpha=50
maximized_alpha=100
interval=0.1 #Timer
#--
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
if [[ $(xfconf-query -c xfce4-panel -p "$alpha_prop") != 100 ]]; then #-- ანიმაციის ლუპის თავიდან ასაცილებლად; to avoid animation loop, first check value
for ((i=$transparent_alpha;i<=$maximized_alpha;i++)); #-- იზრდება 1 ინტერვალით და ქმნის ანიმაციის ეფექტს
do
xfconf-query -c xfce4-panel -p "$alpha_prop" -s "$i"
# set-> xfconf-query -c xfce4-panel -p /panels/panel-1/background-alpha -s "100"
# get-> xfconf-query -c xfce4-panel -p /panels/panel-1/background-alpha
done
fi
done
}
on_no_window_maximized() {
for alpha_prop in "${alpha_prop_list[@]}"; do
if [[ $(xfconf-query -c xfce4-panel -p "$alpha_prop") == 100 ]]; then #-- ანიმაციის ლუპის თავიდან ასაცილებლად; to avoid animation loop, first check value
for ((i=$maximized_alpha;i>=$transparent_alpha;i--));
do
xfconf-query -c xfce4-panel -p "$alpha_prop" -s "$i"
done
fi
done
}
echo $alpha_prop_list
#-- ტაიმერი 0.1 წამიანი ინტერვალით
while true; do
current_desktop=$(wmctrl -d | grep '*' | cut -d ' ' -f1)
is_any_window_maximized=false
for i in $(wmctrl -lG | awk -v d="$current_desktop" '$2==d {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