-
-
Save 5310/1033619bd0c9a14a53c4c3fec82a903a to your computer and use it in GitHub Desktop.
#!/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 |
5310
commented
Aug 29, 2019
via email
i don't know, i'm not really that good finding something that necessary for bash script, i'm just daily linux user and just "google" for something when it doesn't work. like first time i can't apply this when using 18.04 and then the solution is to make this executable and install wmctrl and then add this to "session and startup".
maybe you can update(or make new one because 18.04 still active until future date) the script when 20.04 lts is released because sometimes there are many change in setting because development update and the old one like 4.13.x (the one i currently use) will be deprecated in the future
Your code is pretty easy to rewrite for xfce 4.14, you need to change background-alpha
to background-rgba
, because background-alpha is gone)) and instead of 0-100 integer, now there is array of floating numbers, so you have to set transparency like this:
xfconf-query -c xfce4-panel -p "$alpha_prop" -t double -s 1.000000 -t double -s 0.500000 -t double -s 0.000000 -t double -s "$maximized_alpha"
You must change just last value, cause it sets transparency, whole should look like this:
#!/usr/bin/env bash
#-- CONFIGURATION
transparent_alpha=0.000000
maximized_alpha=1.000000
interval=0.1
#--
alpha_prop_list=()
for prop in $(xfconf-query -c xfce4-panel -p /panels -l); do
[[ "$prop" == *"background-rgba"* ]] && 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"
xfconf-query -c xfce4-panel -p "$alpha_prop" -t double -s 1.000000 -t double -s 0.500000 -t double -s 0.000000 -t double -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"
xfconf-query -c xfce4-panel -p "$alpha_prop" -t double -s 1.000000 -t double -s 0.500000 -t double -s 0.000000 -t double -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 there is just single problem: panel updates color partially, unless you move mouse all over panel. but if you set color from panel preferences it updates immediately, maybe because it flashes during settings is open. If you get this fix please let me know.
And in xfce 4.14 you need first change panel color manually from: panel preferences >> Appearance >> Style - set to "solid color"
.
And I've forked your code and added animation, so if you're on xfce 4.12 check my version. I'll try to make it for 4.14 as well.
I've forked Rouchage's code (here) with a patch for versions>=4.13. I noticed however a delay by xfce4-panel in applying the alpha value when compared to previous parameters - it seems to 'lag' on both animated and un-animated methods. I included both for further testing.
Note: as observed, the panel must be configured to solid color in panel preferences >> Appearance >> Style
for versions 4.13+.
This is great! Does either of these versions work for the 4.12 as well?
Yes - tested and fully working with 4.12 as well. To make sure, I added a condition to check the installed xfce4-panel version (line 33).
Good job. Add bc
in "Required software" list. And have you any idea how to fix color changing lag? It does not occur when you open panel preferences and there change panel color, in this time rectangle around panel flashes, may be it is reason that avoids lag? What do you think about it?
Good catch! Added bc
to the requirements. On Arch Linux, it already came installed as a dependency from cups
. 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.
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)?