From 273e545e8e1e25f560b733c208320ffbc2f99644 Mon Sep 17 00:00:00 2001 From: Danilo Date: Sat, 10 Aug 2024 22:32:15 +0200 Subject: [PATCH 1/4] 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') } } From 2428d06b6b0ea7486dda03707a7922f9f8abcbee Mon Sep 17 00:00:00 2001 From: Danilo Date: Sun, 11 Aug 2024 23:48:45 +0200 Subject: [PATCH 2/4] feat: add userOptions entry for monitor bar mode --- .../modules/.configuration/user_options.js | 5 +++++ .config/ags/variables.js | 20 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 5cb9a279a..3ab37048d 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -221,6 +221,11 @@ let configOptions = { 'cycleTab': "Ctrl+Tab", } }, + 'bar': { + // Array of bar styles for each monitor. + // Example for four monitors: ["normal", "focus", "normal", "nothing"] + 'monitors': ["normal"] + }, } // Override defaults with user's options diff --git a/.config/ags/variables.js b/.config/ags/variables.js index e1bc3f6ec..c26f16e67 100644 --- a/.config/ags/variables.js +++ b/.config/ags/variables.js @@ -15,11 +15,23 @@ globalThis['openMusicControls'] = showMusicControls; globalThis['openColorScheme'] = showColorScheme; globalThis['mpris'] = Mpris; -// Mode switching -const numberOfMonitors = Gdk.Display.get_default()?.get_n_monitors() || 1; -const initialMonitorShellModes = Array.from({ length: numberOfMonitors }, () => 'normal'); -export const currentShellMode = Variable(initialMonitorShellModes, {}) // normal, focus +// load monitor shell modes from userOptions +const initialMonitorShellModes = () => { + const numberOfMonitors = Gdk.Display.get_default()?.get_n_monitors() || 1; + const monitorBarConfigs = []; + for (let i = 0; i < numberOfMonitors; i++) { + if (userOptions.bar.monitors[i]) { + monitorBarConfigs.push(userOptions.bar.monitors[i]) + } else { + monitorBarConfigs.push('normal') + } + } + return monitorBarConfigs; +} +export const currentShellMode = Variable(initialMonitorShellModes(), {}) // normal, focus + +// Mode switching const updateMonitorShellMode = (monitorShellModes, monitor, mode) => { const newValue = [...monitorShellModes.value]; newValue[monitor] = mode; From 97fe16b6bbe915b103088e59b8bbc3903c8facba Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:51:31 +0700 Subject: [PATCH 3/4] rename bar.monitors -> bar.modes --- .config/ags/modules/.configuration/user_options.js | 5 +++-- .config/ags/variables.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 3ab37048d..e5ef916a3 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -222,9 +222,10 @@ let configOptions = { } }, 'bar': { - // Array of bar styles for each monitor. + // Array of bar modes for each monitor. Hit Ctrl+Alt+Slash to cycle. + // Modes: "normal", "focus" (workspace indicator only), "nothing" // Example for four monitors: ["normal", "focus", "normal", "nothing"] - 'monitors': ["normal"] + 'modes': ["normal"] }, } diff --git a/.config/ags/variables.js b/.config/ags/variables.js index c26f16e67..cc7ad76e6 100644 --- a/.config/ags/variables.js +++ b/.config/ags/variables.js @@ -20,8 +20,8 @@ const initialMonitorShellModes = () => { const numberOfMonitors = Gdk.Display.get_default()?.get_n_monitors() || 1; const monitorBarConfigs = []; for (let i = 0; i < numberOfMonitors; i++) { - if (userOptions.bar.monitors[i]) { - monitorBarConfigs.push(userOptions.bar.monitors[i]) + if (userOptions.bar.modes[i]) { + monitorBarConfigs.push(userOptions.bar.modes[i]) } else { monitorBarConfigs.push('normal') } From db004eee6479303b6c90d01006ed1d09d1b72831 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 15 Aug 2024 20:54:15 +0700 Subject: [PATCH 4/4] fix "ReferenceError: Hyprland is not defined" --- .config/ags/variables.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/variables.js b/.config/ags/variables.js index cc7ad76e6..bf6a9ff6f 100644 --- a/.config/ags/variables.js +++ b/.config/ags/variables.js @@ -1,8 +1,8 @@ - const { Gdk, Gtk } = imports.gi; import App from 'resource:///com/github/Aylur/ags/app.js' -import Variable from 'resource:///com/github/Aylur/ags/variable.js'; +import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js'; +import Variable from 'resource:///com/github/Aylur/ags/variable.js'; import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; const { exec, execAsync } = Utils;