Skip to content

Commit

Permalink
add inactive-alpha IPC script
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Jul 7, 2023
1 parent ccffc27 commit f933d00
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ipc-scripts/inactive-alpha.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f933d00

Please sign in to comment.