remove hyprland junk
This commit is contained in:
parent
f7066a383a
commit
d72878d820
9 changed files with 2 additions and 2216 deletions
|
@ -7,8 +7,6 @@ DESKTOP = os.getenv('XDG_CURRENT_DESKTOP')
|
|||
|
||||
if DESKTOP == 'i3' or DESKTOP == 'sway':
|
||||
STATE_DIR = '{}.{}'.format(os.getenv('I3SOCK'), 'ptray')
|
||||
elif DESKTOP == "hyprland":
|
||||
STATE_DIR = '{}/{}.ptray'.format(os.getenv("XDG_RUNTIME_DIR"), os.getenv("HYPRLAND_INSTANCE_SIGNATURE"))
|
||||
else:
|
||||
raise ValueError('Unsupported value of XDG_CURRENT_DESKTOP: {}'.format(DESKTOP))
|
||||
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
import os
|
||||
import socket
|
||||
import json
|
||||
from typing import NamedTuple, Any
|
||||
|
||||
HYPR = "/tmp/hypr/{}".format(os.getenv("HYPRLAND_INSTANCE_SIGNATURE"))
|
||||
|
||||
COMMANDSOCK = "{}/.socket.sock".format(HYPR)
|
||||
EVENTSOCK = "{}/.socket2.sock".format(HYPR)
|
||||
|
||||
BUF_SIZE = 2 ** 20
|
||||
|
||||
class EventType(Enum):
|
||||
WORKSPACE = "workspace"
|
||||
FOCUSED_MON = "focusedmon"
|
||||
ACTIVE_WINDOW = "activewindow"
|
||||
ACTIVE_WINDOW_V2 = "activewindowv2"
|
||||
FULLSCREEN = "fullscreen"
|
||||
MONITOR_REMOVED = "monitorremoved"
|
||||
MONITOR_ADDED = "monitoradded"
|
||||
CREATE_WORKSPACE = "createworkspace"
|
||||
DESTROY_WORKSPACE = "destroyworkspace"
|
||||
MOVE_WORKSPACE = "moveworkspace"
|
||||
ACTIVE_LAYOUT = "activelayout"
|
||||
OPEN_WINDOW = "openwindow"
|
||||
CLOSE_WINDOW = "closewindow"
|
||||
MOVE_WINDOW = "movewindow"
|
||||
OPEN_LAYER = "openlayer"
|
||||
CLOSE_LAYER = "closelayer"
|
||||
SUBMAP = "submap"
|
||||
CHANGE_FLOATING_MODE = "changefloatingmode"
|
||||
URGENT = "urgent"
|
||||
MINIMIZE = "minimize"
|
||||
SCREENCAST = "screencast"
|
||||
WINDOW_TITLE = "windowtitle"
|
||||
|
||||
class Event(NamedTuple):
|
||||
type : EventType
|
||||
value : str
|
||||
|
||||
def subscribe(sockfile=EVENTSOCK):
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM | socket.SOCK_CLOEXEC)
|
||||
sock.connect(sockfile)
|
||||
|
||||
while True:
|
||||
msg = sock.recvmsg(BUF_SIZE)[0]
|
||||
type, value = msg.split('>>', 1)
|
||||
|
||||
return Event(type=type, value=value)
|
||||
|
||||
def hyprctl(cmd, sockfile=COMMANDSOCK):
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM | socket.SOCK_CLOEXEC)
|
||||
try:
|
||||
sock.connect(sockfile)
|
||||
|
||||
header = 'j/'.encode('utf-8')
|
||||
payload = cmd.encode('utf-8')
|
||||
|
||||
sock.sendmsg([header, payload])
|
||||
|
||||
msg = sock.recvmsg(BUF_SIZE)[0]
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
return json.loads(msg)
|
||||
|
||||
print(json.dumps(hyprctl('clients')))
|
||||
|
||||
class Monitor:
|
||||
event_handler = None
|
||||
tracked_classes = None
|
||||
|
||||
window_ids = None
|
||||
|
||||
def __init__(self, event_handler, tracked_classes):
|
||||
self.event_handler = event_handler
|
||||
self.tracked_classes = tracked_classes
|
||||
self.window_ids = {name: set() for name in tracked_classes}
|
||||
|
||||
windows = hyprctl('clients')
|
||||
monitors = hyprctl('monitors')
|
||||
open_workspaces = [m['specialWorkspace']['id'] for m in monitors]
|
||||
for window in windows:
|
||||
for name: classes in tracked_classes.items():
|
||||
for cls in classes:
|
||||
if cls in window['class']:
|
||||
id = window['address']
|
||||
self.event_handler.on_create(name, id)
|
||||
self.window_ids[name].add(id)
|
||||
|
||||
workspace_id = window['workspace']['id']
|
||||
if workspace_id < 0:
|
||||
self.event_handler.on_float(name, id)
|
||||
if workspace_id in open_workspaces:
|
||||
self.event_handler.on_visible(name, id)
|
||||
else:
|
||||
self.event_handler.on_invisible(name, id)
|
||||
else:
|
||||
self.event_handler.on_tile(name, id)
|
||||
self.event_handler.on_visible(name, id)
|
||||
|
||||
def listen(self):
|
||||
for event in subscribe():
|
||||
self.handle_event(event)
|
||||
|
||||
def match_window_id_to_name(self, id):
|
||||
for name, ids in self.window_ids.items():
|
||||
if id in ids:
|
||||
return name
|
||||
return None
|
||||
|
||||
def handle_event(self, event):
|
||||
if event == EventType.MOVE_WINDOW:
|
||||
id, workspace = event.split(',', 1)
|
||||
if workspace.startsWith('special'):
|
||||
self.even
|
||||
movewindow>>2700e80,special:3
|
Loading…
Add table
Add a link
Reference in a new issue