From 273e545e8e1e25f560b733c208320ffbc2f99644 Mon Sep 17 00:00:00 2001 From: Danilo Date: Sat, 10 Aug 2024 22:32:15 +0200 Subject: [PATCH] feat: change shell mode per monitor Multimonitor improvement --- .config/ags/modules/bar/main.js | 3 +-- .config/ags/variables.js | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index 952fb3fbc..94b7a3732 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -101,8 +101,7 @@ export const Bar = async (monitor = 0) => { 'nothing': nothingContent, }, setup: (self) => self.hook(currentShellMode, (self) => { - self.shown = currentShellMode.value; - + self.shown = currentShellMode.value[monitor]; }) }), }); diff --git a/.config/ags/variables.js b/.config/ags/variables.js index c9aa243dd..e1bc3f6ec 100644 --- a/.config/ags/variables.js +++ b/.config/ags/variables.js @@ -16,17 +16,27 @@ globalThis['openColorScheme'] = showColorScheme; globalThis['mpris'] = Mpris; // Mode switching -export const currentShellMode = Variable('normal', {}) // normal, focus +const numberOfMonitors = Gdk.Display.get_default()?.get_n_monitors() || 1; +const initialMonitorShellModes = Array.from({ length: numberOfMonitors }, () => 'normal'); +export const currentShellMode = Variable(initialMonitorShellModes, {}) // normal, focus + +const updateMonitorShellMode = (monitorShellModes, monitor, mode) => { + const newValue = [...monitorShellModes.value]; + newValue[monitor] = mode; + monitorShellModes.value = newValue; +} globalThis['currentMode'] = currentShellMode; globalThis['cycleMode'] = () => { - if (currentShellMode.value === 'normal') { - currentShellMode.value = 'focus'; - } - else if (currentShellMode.value === 'focus') { - currentShellMode.value = 'nothing'; + const monitor = Hyprland.active.monitor.id || 0; + + if (currentShellMode.value[monitor] === 'normal') { + updateMonitorShellMode(currentShellMode, monitor, 'focus') + } + else if (currentShellMode.value[monitor] === 'focus') { + updateMonitorShellMode(currentShellMode, monitor, 'nothing') } else { - currentShellMode.value = 'normal'; + updateMonitorShellMode(currentShellMode, monitor, 'normal') } }