diff --git a/.config/ags/modules/.configuration/user_options.js b/.config/ags/modules/.configuration/user_options.js index 5cb9a279a..e5ef916a3 100644 --- a/.config/ags/modules/.configuration/user_options.js +++ b/.config/ags/modules/.configuration/user_options.js @@ -221,6 +221,12 @@ let configOptions = { 'cycleTab': "Ctrl+Tab", } }, + 'bar': { + // 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"] + 'modes': ["normal"] + }, } // Override defaults with user's options diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index 2a0d6e68e..771306e86 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..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; @@ -15,18 +15,40 @@ globalThis['openMusicControls'] = showMusicControls; globalThis['openColorScheme'] = showColorScheme; globalThis['mpris'] = Mpris; +// 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.modes[i]) { + monitorBarConfigs.push(userOptions.bar.modes[i]) + } else { + monitorBarConfigs.push('normal') + } + } + return monitorBarConfigs; + +} +export const currentShellMode = Variable(initialMonitorShellModes(), {}) // normal, focus + // Mode switching -export const currentShellMode = Variable('normal', {}) // 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') } }