From 48f689668c5b4724764f027d478628bb795ac273 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:00:49 +0700 Subject: [PATCH] workspace widget: side mouse btn for special ws --- .../modules/bar/normal/workspaces_hyprland.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.config/ags/modules/bar/normal/workspaces_hyprland.js b/.config/ags/modules/bar/normal/workspaces_hyprland.js index 770ba6bc8..ba30f69e7 100644 --- a/.config/ags/modules/bar/normal/workspaces_hyprland.js +++ b/.config/ags/modules/bar/normal/workspaces_hyprland.js @@ -175,15 +175,17 @@ export default () => EventBox({ .catch(print); }) self.on('button-press-event', (self, event) => { - if (!(event.get_button()[1] === 1)) return; // We're only interested in left-click here - self.attribute.clicked = true; - const [_, cursorX, cursorY] = event.get_coords(); - const widgetWidth = self.get_allocation().width; - // const wsId = Math.ceil(cursorX * NUM_OF_WORKSPACES_PER_GROUP / widgetWidth) + self.attribute.ws_group * NUM_OF_WORKSPACES_PER_GROUP; - // Hyprland.messageAsync(`dispatch workspace ${wsId}`).catch(print); - const wsId = Math.ceil(cursorX * userOptions.workspaces.shown / widgetWidth); - Utils.execAsync([`${App.configDir}/scripts/hyprland/workspace_action.sh`, 'workspace', `${wsId}`]) - .catch(print); + if (event.get_button()[1] === 1) { + self.attribute.clicked = true; + const [_, cursorX, cursorY] = event.get_coords(); + const widgetWidth = self.get_allocation().width; + const wsId = Math.ceil(cursorX * userOptions.workspaces.shown / widgetWidth); + Utils.execAsync([`${App.configDir}/scripts/hyprland/workspace_action.sh`, 'workspace', `${wsId}`]) + .catch(print); + } + else if (event.get_button()[1] === 8) { + Hyprland.messageAsync(`dispatch togglespecialworkspace`).catch(print); + } }) self.on('button-release-event', (self) => self.attribute.clicked = false); }