feat: Move set-workspace to compositor-control
This commit is contained in:
parent
9ca97466a1
commit
9147fa3fff
|
@ -65,7 +65,7 @@
|
|||
(for workspace in workspaces
|
||||
(button
|
||||
:class "${workspace.class}"
|
||||
:onclick "scripts/workspace.sh ${workspace.id}"
|
||||
:onclick "scripts/compositor-control set-workspace ${workspace.id}"
|
||||
"${workspace.text}"))
|
||||
))
|
||||
(deflisten workspaces :initial "[]"
|
||||
|
|
|
@ -67,6 +67,8 @@ class CompositorHandler:
|
|||
pass
|
||||
def listen_active_window_title(self):
|
||||
pass
|
||||
def set_workspace(self, i):
|
||||
pass
|
||||
|
||||
class HyprlandHandler(CompositorHandler):
|
||||
def __init__(self, socket_addr):
|
||||
|
@ -125,6 +127,15 @@ class HyprlandHandler(CompositorHandler):
|
|||
print(title, flush=True)
|
||||
self.listen(callback)
|
||||
|
||||
@override
|
||||
def set_workspace(self, i):
|
||||
result = os.popen(f"hyprctl dispatch workspace {i}").read()
|
||||
if result != "ok\n":
|
||||
raise RuntimeError(f"Failed to set workspace: {result}")
|
||||
|
||||
# FIXME: Set the wallpaper too.
|
||||
# ~/.config/hypr/wallpaper.sh $1
|
||||
|
||||
|
||||
class SwayHandler(CompositorHandler):
|
||||
@staticmethod
|
||||
|
@ -163,5 +174,11 @@ if __name__ == "__main__":
|
|||
handler.listen_workspaces()
|
||||
elif key == "active-title":
|
||||
handler.listen_active_window_title()
|
||||
elif key == "set-workspace":
|
||||
if len(sys.argv) != 3:
|
||||
print(f"Set workspace must be accompanied by an argument", file=sys.stderr)
|
||||
|
||||
arg = sys.argv[2]
|
||||
handler.set_workspace(arg)
|
||||
else:
|
||||
print(f"Unknown key: {key}", file=sys.stderr)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
hyprctl dispatch workspace $1
|
||||
~/.config/hypr/wallpaper.sh $1
|
Loading…
Reference in New Issue