From f933d00c6cb1b7971b8913a3966adf3bd3e4ed7c Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Fri, 7 Jul 2023 09:51:38 +0200 Subject: [PATCH] add inactive-alpha IPC script --- ipc-scripts/inactive-alpha.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 ipc-scripts/inactive-alpha.py diff --git a/ipc-scripts/inactive-alpha.py b/ipc-scripts/inactive-alpha.py new file mode 100644 index 000000000..83f471580 --- /dev/null +++ b/ipc-scripts/inactive-alpha.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +# +# This script demonstrates how Wayfire's IPC can be used to set the opacity of inactive views. + +import os +from wayfire_socket import * + +addr = os.getenv('WAYFIRE_SOCKET') +sock = WayfireSocket(addr) +sock.watch() + +last_focused_toplevel = -1 +while True: + msg = sock.read_message() + # The view-mapped event is emitted when a new window has been opened. + if "event" in msg and msg["event"] == "view-focused": + view = msg["view"] + print(view) + new_focus = view["id"] if view and view["type"] == "toplevel" else -1 + if last_focused_toplevel != new_focus: + if last_focused_toplevel != -1 and new_focus != -1: + sock.set_view_alpha(last_focused_toplevel, 0.8) + + if new_focus != -1: + sock.set_view_alpha(new_focus, 1.0) + + last_focused_toplevel = new_focus