aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-10-20 21:06:38 +0200
committerGitHub <noreply@github.com>2018-10-20 21:06:38 +0200
commit6e6476c3d5b84edee57b5afb452d202d2fc283a6 (patch)
treeecf6e63b5851adaaf87e46c1e9dfa05b5bc54d21
parenta41b77ef295326e94101da0c1d62832ab6a6ce7d (diff)
parent0d5aaf5359c671a51bd319bd7972e0f5e7bcde84 (diff)
Merge pull request #2900 from Hi-Angel/master
A script to make inactive windows transparent
-rwxr-xr-xcontrib/inactive-windows-transparency.py28
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 @@
+#!/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()