Skip to content

Commit

Permalink
keyd-application-mapper: Add hyperland support
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasGrandl authored and rvaiya committed Nov 25, 2022
1 parent d1b008e commit d79df6a
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions scripts/keyd-application-mapper
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,43 @@ class SwayMonitor():

self.on_window_change(cls, title)

class HyprMonitor():
def __init__(self, on_window_change):
assert_env('HYPRLAND_INSTANCE_SIGNATURE')

self.on_window_change = on_window_change

def init(self):
pass

def run(self):
import socket

last_cls = ''
last_title = ''

s = "/tmp/hypr/" + str(os.getenv('HYPRLAND_INSTANCE_SIGNATURE')) + "/.socket2.sock"

client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect(s)

while True:
data = client.recv(4096)
msg = data.decode('utf-8')
tmp = msg.split('>>')
if tmp[0] == 'activewindow' and len(tmp) > 1:
cls, title = tmp[1].split(',')

if title == '' and cls == '':
continue

if last_cls != cls or last_title != title:
last_cls = cls
last_title = title

self.on_window_change(cls, title)

client.close()

class XMonitor():
def __init__(self, on_window_change):
Expand Down Expand Up @@ -367,6 +404,7 @@ class GnomeMonitor():
def get_monitor(on_window_change):
monitors = [
('Sway', SwayMonitor),
('Hyprland', HyprMonitor),
('Gnome', GnomeMonitor),
('X', XMonitor),
]
Expand Down

0 comments on commit d79df6a

Please sign in to comment.