mirror of
https://github.com/swaywm/sway.git
synced 2024-12-27 07:26:55 +01:00
A script to make inactive windows transparent
Sway has ability to apply transparency to arbitrary windows. This script wires up this functional to one of popular use-cases from i3+<compositor_name>. Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
This commit is contained in:
parent
a41b77ef29
commit
0d5aaf5359
1 changed files with 28 additions and 0 deletions
28
contrib/inactive-windows-transparency.py
Executable file
28
contrib/inactive-windows-transparency.py
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# This script requires i3ipc-python package (install it from a system package manager
|
||||
# or pip).
|
||||
# It makes inactive windows transparent. Use `transparency_val` variable to control
|
||||
# transparency strength in range of 0…1.
|
||||
|
||||
import i3ipc
|
||||
|
||||
transparency_val = '0.8';
|
||||
ipc = i3ipc.Connection()
|
||||
prev_focused = None
|
||||
|
||||
for window in ipc.get_tree():
|
||||
if window.focused:
|
||||
prev_focused = window
|
||||
else:
|
||||
window.command('opacity ' + transparency_val)
|
||||
|
||||
def on_window_focus(ipc, focused):
|
||||
global prev_focused
|
||||
if focused.container.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859
|
||||
focused.container.command('opacity 1')
|
||||
prev_focused.command('opacity ' + transparency_val)
|
||||
prev_focused = focused.container
|
||||
|
||||
ipc.on("window::focus", on_window_focus)
|
||||
ipc.main()
|
Loading…
Reference in a new issue