Last active
May 12, 2020 12:03
-
-
Save tpb1908/6501c8a184b09f2e4fac833b4fe57061 to your computer and use it in GitHub Desktop.
Listener for i3 IPC events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import asyncio | |
from i3ipc.aio import Connection | |
from i3ipc import Event | |
def onWindowEvent(i3, e): | |
if e.ipc_data["container"]["urgent"]: | |
print("Urgent\n\n\n") | |
print(f"Data: {e.ipc_data}") | |
async def main(): | |
i3 = await Connection().connect() | |
i3.on(Event.WINDOW, onWindowEvent) | |
await i3.main() | |
if __name__ == "__main__": | |
asyncio.run(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import tkinter as tk | |
from ewmh import EWMH | |
ewmh = EWMH() | |
window = tk.Tk() | |
window.attributes('-type', 'dialog') # Floating | |
entry = tk.Entry(window) | |
entry.pack() | |
win = None | |
# Grab focus and save reference to window | |
def grab_win(): | |
global win | |
window.focus_force() | |
entry.focus_set() | |
win = ewmh.getActiveWindow() | |
print(f"Window name {win.get_wm_name()}") | |
def set_state(): | |
print(f"Setting state for win {win.get_wm_name()}") | |
ewmh.setWmState(win, 1, '_NET_WM_STATE_DEMANDS_ATTENTION') | |
ewmh.display.flush() | |
# Once window is shown | |
window.after(300, grab_win) | |
# Delay, to allow moving to another workspace/scratchpad | |
window.after(3000, set_state) | |
window.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment