diff --git a/eww/bar/eww.yuck b/eww/bar/eww.yuck index 884a2db..04c95c5 100644 --- a/eww/bar/eww.yuck +++ b/eww/bar/eww.yuck @@ -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 "[]" diff --git a/eww/bar/scripts/compositor-control b/eww/bar/scripts/compositor-control index 2b02113..5c531e1 100755 --- a/eww/bar/scripts/compositor-control +++ b/eww/bar/scripts/compositor-control @@ -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) diff --git a/eww/bar/scripts/workspace.sh b/eww/bar/scripts/workspace.sh deleted file mode 100755 index 1cc571b..0000000 --- a/eww/bar/scripts/workspace.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -hyprctl dispatch workspace $1 -~/.config/hypr/wallpaper.sh $1