From d0ac7076d03cb1fff4bfd1aa2043f05beef09b14 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 14 Jul 2025 15:48:50 +0200 Subject: [PATCH] Add new opacity script to set any window's opacity --- bin/opacity | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bin/opacity b/bin/opacity index 4a624c5..ff5d499 100755 --- a/bin/opacity +++ b/bin/opacity @@ -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