-
Notifications
You must be signed in to change notification settings - Fork 44
feat(HyprlandService): support urgent event
#428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
d43e0a4
dae7963
35d6cd6
fedcf40
3f70a2f
a9b9f2f
a2209fb
25f0437
8ef9ae2
d8e8a88
dfa7263
371fb22
50e6a7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,7 @@ def __init__(self): | |
| self._windows: dict[str, HyprlandWindow] = {} | ||
| self._active_window: HyprlandWindow = HyprlandWindow() | ||
| self._monitors: dict[str, HyprlandMonitor] = {} | ||
| self._urgent_windows = set() | ||
|
|
||
| self._OBJ_TYPES: dict[str, _HyprlandObjDesc] = { | ||
| "workspace": _HyprlandObjDesc( | ||
|
|
@@ -143,6 +144,29 @@ def workspaces(self) -> list[HyprlandWorkspace]: | |
| """ | ||
| return list(self._workspaces.values()) | ||
|
|
||
| @IgnisProperty | ||
| def urgent_windows(self) -> list[str]: | ||
| """ | ||
| - read-only | ||
|
|
||
| A list of urgent windows. | ||
| """ | ||
| return list(self._urgent_windows) | ||
|
|
||
| @IgnisProperty | ||
| def urgent_workspaces(self) -> list[str]: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, maybe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that, how would you bind to urgent though? Do you just bind to the windows property at that point?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wouldn't support binding to both properties under HyprlandWindow and the hyprland service though. I might be over-complicating it but how would I do what I'm doing in hyprland_workspaces() in the example bar? |
||
| """ | ||
| - read-only | ||
|
|
||
| A list of urgent workspaces. | ||
| """ | ||
| clients = json.loads(self.send_command("j/clients")) | ||
| urgent_workspaces = [] | ||
| for i in clients: | ||
| if i["address"][len("0x") :] in self._urgent_windows: | ||
| urgent_workspaces.append(i["workspace"]["id"]) | ||
| return urgent_workspaces | ||
|
|
||
| @IgnisProperty | ||
| def active_workspace(self) -> HyprlandWorkspace: | ||
| """ | ||
|
|
@@ -194,6 +218,8 @@ def get_full_w_addr(addr: str) -> str: | |
| value_list = event_value.split(",") | ||
|
|
||
| match event_type: | ||
| case "urgent": | ||
| self.__sync_urgent(value_list[0]) | ||
| case "destroyworkspacev2": | ||
| self.__destroy_workspace(int(value_list[0])) | ||
| case "createworkspacev2": | ||
|
|
@@ -357,12 +383,24 @@ def __sync_main_keyboard(self) -> None: | |
| def __sync_active_layout(self, layout: str) -> None: | ||
| self._main_keyboard.sync({"active_keymap": layout}) | ||
|
|
||
| def __sync_urgent(self, urgent_window) -> None: | ||
| self._urgent_windows.add(urgent_window) | ||
| self.notify("urgent_windows") | ||
| self.notify("urgent_workspaces") | ||
|
|
||
| def __sync_active_window(self) -> None: | ||
| active_window_data = json.loads(self.send_command("j/activewindow")) | ||
| if active_window_data == {}: | ||
| active_window_data = HyprlandWindow().data | ||
|
|
||
| self.active_window.sync(active_window_data) | ||
|
|
||
| active_window_id = active_window_data["address"][len("0x") :] | ||
| if active_window_id in self._urgent_windows: | ||
| self._urgent_windows.remove(active_window_id) | ||
| self.notify("urgent_windows") | ||
| self.notify("urgent_workspaces") | ||
|
|
||
| self.notify("active-window") | ||
|
|
||
| def __open_window(self, address: str) -> None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should return a list of
HyprlandWindowandHyprlandWorkspaceaccordinglyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done in my latest commits.