diff options
author | 2018-10-20 21:06:38 +0200 | |
---|---|---|
committer | 2018-10-20 21:06:38 +0200 | |
commit | 6e6476c3d5b84edee57b5afb452d202d2fc283a6 (patch) | |
tree | ecf6e63b5851adaaf87e46c1e9dfa05b5bc54d21 /contrib/inactive-windows-transparency.py | |
parent | Merge pull request #2896 from RyanDwyer/abort-proprietary (diff) | |
parent | A script to make inactive windows transparent (diff) | |
download | sway-6e6476c3d5b84edee57b5afb452d202d2fc283a6.tar.gz sway-6e6476c3d5b84edee57b5afb452d202d2fc283a6.tar.zst sway-6e6476c3d5b84edee57b5afb452d202d2fc283a6.zip |
Merge pull request #2900 from Hi-Angel/master
A script to make inactive windows transparent
Diffstat (limited to 'contrib/inactive-windows-transparency.py')
-rwxr-xr-x | contrib/inactive-windows-transparency.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/contrib/inactive-windows-transparency.py b/contrib/inactive-windows-transparency.py new file mode 100755 index 00000000..af26c017 --- /dev/null +++ b/contrib/inactive-windows-transparency.py | |||
@@ -0,0 +1,28 @@ | |||
1 | #!/usr/bin/python | ||
2 | |||
3 | # This script requires i3ipc-python package (install it from a system package manager | ||
4 | # or pip). | ||
5 | # It makes inactive windows transparent. Use `transparency_val` variable to control | ||
6 | # transparency strength in range of 0…1. | ||
7 | |||
8 | import i3ipc | ||
9 | |||
10 | transparency_val = '0.8'; | ||
11 | ipc = i3ipc.Connection() | ||
12 | prev_focused = None | ||
13 | |||
14 | for window in ipc.get_tree(): | ||
15 | if window.focused: | ||
16 | prev_focused = window | ||
17 | else: | ||
18 | window.command('opacity ' + transparency_val) | ||
19 | |||
20 | def on_window_focus(ipc, focused): | ||
21 | global prev_focused | ||
22 | if focused.container.id != prev_focused.id: # https://github.com/swaywm/sway/issues/2859 | ||
23 | focused.container.command('opacity 1') | ||
24 | prev_focused.command('opacity ' + transparency_val) | ||
25 | prev_focused = focused.container | ||
26 | |||
27 | ipc.on("window::focus", on_window_focus) | ||
28 | ipc.main() | ||