Add new opacity script to set any window's opacity

This commit is contained in:
Talia 2025-07-14 15:48:50 +02:00
parent 89fd721632
commit d0ac7076d0

View file

@ -1,6 +1,14 @@
#!/bin/sh
if [ "$TERM" = "xterm-kitty" ]
then
kitty @ set-background-opacity $1
id=$(xdotool selectwindow)
before=$(xprop -id $id 32c _NET_WM_WINDOW_OPACITY | lua -e 'print(tonumber(io.read():match("= .*$"):sub(2)))')
initial=$(xprop -id $id 32c _NET_WM_WINDOW_OPACITY | lua -e 'print(math.floor(tonumber(io.read():match("= .*$"):sub(2)) / 0xffffffff * 100 + 0.5))')
((zenity --scale --title "Opacity" --value=$initial --print-partial; echo $? >&3) \
| lua -e 'for line in io.lines() do print(string.format("0x%08x", math.floor(tonumber(line) / 100 * 0xffffffff + 0.5))) end' \
| xargs -I{} xprop -id $id -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY {}) 3>&1 | (read xs; exit $xs)
if [ $? -ne 0 ]
then xprop -id $id -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $before
fi