feat: change shell mode per monitor

Multimonitor improvement
This commit is contained in:
Danilo
2024-08-10 22:32:15 +02:00
parent 92e2224524
commit 273e545e8e
2 changed files with 18 additions and 9 deletions
+1 -2
View File
@@ -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];
})
}),
});
+17 -7
View File
@@ -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')
}
}