From 80581cdc3d54811c30c85ad8fffe0c2bc84caee1 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:43:05 +0700 Subject: [PATCH] make session multimonitor (#424) --- .config/ags/config.js | 2 +- .config/ags/modules/session/main.js | 2 +- .config/ags/modules/session/sessionscreen.js | 6 +++--- .config/ags/modules/sideright/quicktoggles.js | 2 +- .config/ags/variables.js | 4 ++-- .config/hypr/hyprland/keybinds.conf | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.config/ags/config.js b/.config/ags/config.js index abc0b65de..a8924a288 100644 --- a/.config/ags/config.js +++ b/.config/ags/config.js @@ -52,7 +52,7 @@ const Windows = () => [ SideLeft(), SideRight(), forMonitors(Osk), - Session(), + forMonitors(Session), userOptions.dock.enabled ? forMonitors(Dock) : null, ...(userOptions.appearance.fakeScreenRounding ? [ forMonitors((id) => Corner(id, 'top left', true)), diff --git a/.config/ags/modules/session/main.js b/.config/ags/modules/session/main.js index 4329edba1..cf4f8010f 100644 --- a/.config/ags/modules/session/main.js +++ b/.config/ags/modules/session/main.js @@ -2,7 +2,7 @@ import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import SessionScreen from "./sessionscreen.js"; import PopupWindow from '../.widgethacks/popupwindow.js'; -export default (id = '') => PopupWindow({ // On-screen keyboard +export default (id = 0) => PopupWindow({ // On-screen keyboard name: `session${id}`, visible: false, keymode: 'exclusive', diff --git a/.config/ags/modules/session/sessionscreen.js b/.config/ags/modules/session/sessionscreen.js index aed8c3cc2..80d5436e7 100644 --- a/.config/ags/modules/session/sessionscreen.js +++ b/.config/ags/modules/session/sessionscreen.js @@ -59,7 +59,7 @@ const SessionButton = (name, icon, command, props = {}, colorid = 0) => { }); } -export default ({ id = '' }) => { +export default ({ id = 0 }) => { // lock, logout, sleep const lockButton = SessionButton('Lock', 'lock', () => { App.closeWindow(`session${id}`); execAsync(['loginctl', 'lock-session']).catch(print) }, {}, 1); const logoutButton = SessionButton('Logout', 'logout', () => { App.closeWindow(`session${id}`); execAsync(['bash', '-c', 'pkill Hyprland || pkill sway || pkill niri || loginctl terminate-user $USER']).catch(print) }, {}, 2); @@ -98,8 +98,8 @@ export default ({ id = '' }) => { return Widget.Box({ className: 'session-bg', css: ` - min-width: ${monitors[(id == '' ? 0 : id)].width}px; - min-height: ${monitors[(id == '' ? 0 : id)].height}px; + min-width: ${monitors[id].width}px; + min-height: ${monitors[id].height}px; `, // idk why but height = screen height doesn't fill vertical: true, children: [ diff --git a/.config/ags/modules/sideright/quicktoggles.js b/.config/ags/modules/sideright/quicktoggles.js index 712bfaee5..1c33c1bf2 100644 --- a/.config/ags/modules/sideright/quicktoggles.js +++ b/.config/ags/modules/sideright/quicktoggles.js @@ -228,7 +228,7 @@ export const ModulePowerIcon = (props = {}) => Widget.Button({ tooltipText: 'Session', onClicked: () => { closeEverything(); - Utils.timeout(1, () => App.openWindow('session')); + Utils.timeout(1, () => openWindowOnAllMonitors('session')); }, child: MaterialIcon('power_settings_new', 'norm'), setup: button => { diff --git a/.config/ags/variables.js b/.config/ags/variables.js index c77027f2d..908e2b56b 100644 --- a/.config/ags/variables.js +++ b/.config/ags/variables.js @@ -47,11 +47,11 @@ globalThis['openWindowOnAllMonitors'] = (name) => { globalThis['closeEverything'] = () => { const numMonitors = Gdk.Display.get_default()?.get_n_monitors() || 1; for (let i = 0; i < numMonitors; i++) { - App.closeWindow(`cheatsheet${i}`); App.closeWindow(`click2close${i}`); + App.closeWindow(`cheatsheet${i}`); + App.closeWindow(`session${i}`); } App.closeWindow('sideleft'); App.closeWindow('sideright'); App.closeWindow('overview'); - App.closeWindow('session'); }; diff --git a/.config/hypr/hyprland/keybinds.conf b/.config/hypr/hyprland/keybinds.conf index 50c5e4818..dc79b59eb 100644 --- a/.config/hypr/hyprland/keybinds.conf +++ b/.config/hypr/hyprland/keybinds.conf @@ -88,7 +88,7 @@ bind = Super, N, exec, ags -t 'sideright' bind = Super, M, exec, ags run-js 'openMusicControls.value = (!mpris.getPlayer() ? false : !openMusicControls.value);' bind = Super, Comma, exec, ags run-js 'openColorScheme.value = true; Utils.timeout(2000, () => openColorScheme.value = false);' bind = Super, K, exec, for ((i=0; i<$(xrandr --listmonitors | grep -c 'Monitor'); i++)); do ags -t "osk""$i"; done -bind = Control+Alt, Delete, exec, ags -t 'session' +bind = Control+Alt, Delete, exec, for ((i=0; i<$(xrandr --listmonitors | grep -c 'Monitor'); i++)); do ags -t "session""$i"; done bindle = , XF86AudioRaiseVolume, exec, ags run-js 'indicator.popup(1);' bindle = , XF86AudioLowerVolume, exec, ags run-js 'indicator.popup(1);' bindle=, XF86MonBrightnessUp, exec, ags run-js 'brightness.screen_value += 0.05; indicator.popup(1);'