sway
sway copied to clipboard
Add ability to get current window opacity
Description: sway
can currently set opacity
very easily in different ways, e.g., swaymsg opacity 0.5
or for_window [<criteria>] opacity 0.75
. But there's no way to get the opacity
of a window.
I would like to ability to bind a key to 'cycle through opacity values', but I cannot implement this without being able to query the current opacity value for a given window.
Enhancement Request: in swaymsg -t get_tree
's output, an opacity
field should be returned with the window's current opacity
value.
(I couldn't find a non-sway way to get opacity either, through other Wayland tools, etc. If such a way exists it could be a workaround, so please let me know. :slightly_smiling_face:)
I don't get the use case, you can just keep the current opacity locally when cycling through it.
(I couldn't find a non-sway way to get opacity either, through other Wayland tools, etc. If such a way exists it could be a workaround, so please let me know. slightly_smiling_face)
The opacity is a sway feature, Wayland has nothing to do with it.
Related: https://github.com/swaywm/sway/issues/6574#issuecomment-933070655
I don't get the use case, you can just keep the current opacity locally when cycling through it.
Maybe I'm missing something? As far as I can tell, it's not possible to have a binding that cycles through opacities...
As an example, on i3
(with picom
) I have something similar to this:
bindsym $mod+t exec 'picom-trans --toggle 0.5'
Which, when used will toggle the transparency of the focused window.
With a script it's easy with picom-trans
to get the transparency, and then use that to figure out what the next opacity should be if cycling through many. (This is what I have in i3
, cycling though 1.0, 0.5, 0.75
opacity values).
What do you mean "keep the current opacity locally"? :thinking:
I don't get the use case, you can just keep the current opacity locally when cycling through it.
Maybe I'm missing something? As far as I can tell, it's not possible to have a binding that cycles through opacities...
As an example, on
i3
(withpicom
) I have something similar to this:bindsym $mod+t exec 'picom-trans --toggle 0.5'
Which, when used will toggle the transparency of the focused window. With a script it's easy with
picom-trans
to get the transparency, and then use that to figure out what the next opacity should be if cycling through many. (This is what I have ini3
, cycling though1.0, 0.5, 0.75
opacity values).What do you mean "keep the current opacity locally"? thinking
check this for your case https://gist.github.com/rickyrsyah/05e28ab2adbb5472f9269acaa072738d
@acheronfail I don't know if you figured this out but here a script that will toggle the opacity of the current window:
#!/usr/bin/bash
swaymsg opacity plus 0.01
if [ $? -eq 0 ]; then
# opacity was not 1, we toggle off
swaymsg opacity 1
else
# opacity was 1, we toggle on
swaymsg opacity 0.5
fi
Just need one keybind in sway config
bindsym $mod+o exec toggle-transparency.sh