-
-
Save 5310/1033619bd0c9a14a53c4c3fec82a903a 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#-- CONFIGURATION | |
transparent_alpha=0 | |
maximized_alpha=100 | |
interval=0.5 | |
#-- | |
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 | |
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 |
And if you monitor panel with: xfconf-query -c xfce4-panel -m -v
and change color from panel preferences you'll see that it changes just background-rgba property to ((null)) and there's also warning: "Unable to convert GValue to string"
.
Seems like bug ?
Looking further, I found the line which issues the error message in xfconf
source code (here). However, it only seems to output the error message when in verbose mode (-v
); otherwise, it just prints the panel name i.e. set: /panels/panel-X/background-rgba
when changed.
I also narrowed down the moment it issues the error (here). It might be because GValue
in this case is an array with 4 values (rgba)?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good catch! Added
bc
to the requirements. On Arch Linux, it already came installed as a dependency fromcups
. Not sure on Ubuntu.Yeah, I think you're on to something as well regarding the refresh issue; the delay is almost unnoticeable from the panel settings. Maybe it enforces refreshing when the user changes values? The enter/leave opacity values for the panel are also refreshed instantly when applied.