From 438c3abdfa62798f12611f8409cba22964cbb881 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:09:56 +0700 Subject: [PATCH] bar: fix multimonitor (?) --- .config/ags/config.js | 11 ++- .config/ags/modules/bar/main.js | 2 +- .config/ags/modules/bar/normal/spaceleft.js | 72 ++++++++++---------- .config/ags/modules/bar/normal/spaceright.js | 41 +++++------ 4 files changed, 64 insertions(+), 62 deletions(-) diff --git a/.config/ags/config.js b/.config/ags/config.js index c0c317829..2a96f2dbc 100644 --- a/.config/ags/config.js +++ b/.config/ags/config.js @@ -56,6 +56,8 @@ const Windows = () => [ forMonitors((id) => Corner(id, 'top right')), forMonitors((id) => Corner(id, 'bottom left')), forMonitors((id) => Corner(id, 'bottom right')), + forMonitors(BarCornerTopleft), + forMonitors(BarCornerTopright), ]; const CLOSE_ANIM_TIME = 210; // Longer than actual anim time to make sure widgets animate fully App.config({ @@ -70,9 +72,6 @@ App.config({ }); // Stuff that don't need to be toggled. And they're async so ugh... -Bar().catch(print); // Use this to debug the bar. Single monitor only. -// BarCornerTopleft().catch(print); // Use this to debug the bar. Single monitor only. -// BarCornerTopright().catch(print); // Use this to debug the bar. Single monitor only. -// forMonitors(Bar); -forMonitors(BarCornerTopleft); -forMonitors(BarCornerTopright); +forMonitors(Bar); +// Bar().catch(print); // Use this to debug the bar. Single monitor only. + diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index 0c3aed1b5..7f74c541a 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -46,7 +46,7 @@ export const Bar = async (monitor = 0) => { const minHeight = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL); // execAsync(['bash', '-c', `hyprctl keyword monitor ,addreserved,${minHeight},0,0,0`]).catch(print); }, - startWidget: WindowTitle(), + startWidget: (await WindowTitle()), centerWidget: Widget.Box({ className: 'spacing-h-4', children: [ diff --git a/.config/ags/modules/bar/normal/spaceleft.js b/.config/ags/modules/bar/normal/spaceleft.js index 08cb4aacc..6fbe5d394 100644 --- a/.config/ags/modules/bar/normal/spaceleft.js +++ b/.config/ags/modules/bar/normal/spaceleft.js @@ -38,39 +38,41 @@ const WindowTitle = async () => { } } -const OptionalWindowTitleInstance = await WindowTitle(); -export default () => Widget.EventBox({ - onScrollUp: () => { - Indicator.popup(1); // Since the brightness and speaker are both on the same window - Brightness.screen_value += 0.05; - }, - onScrollDown: () => { - Indicator.popup(1); // Since the brightness and speaker are both on the same window - Brightness.screen_value -= 0.05; - }, - onPrimaryClick: () => { - App.toggleWindow('sideleft'); - }, - child: Widget.Box({ - homogeneous: false, - children: [ - Widget.Box({ className: 'bar-corner-spacing' }), - Widget.Overlay({ - overlays: [ - Widget.Box({ hexpand: true }), - Widget.Box({ - className: 'bar-sidemodule', hexpand: true, - children: [Widget.Box({ - vertical: true, - className: 'bar-space-button', - children: [ - OptionalWindowTitleInstance, - ] - })] - }), - ] - }) - ] - }) -}); \ No newline at end of file +export default async () => { + const optionalWindowTitleInstance = await WindowTitle(); + return Widget.EventBox({ + onScrollUp: () => { + Indicator.popup(1); // Since the brightness and speaker are both on the same window + Brightness.screen_value += 0.05; + }, + onScrollDown: () => { + Indicator.popup(1); // Since the brightness and speaker are both on the same window + Brightness.screen_value -= 0.05; + }, + onPrimaryClick: () => { + App.toggleWindow('sideleft'); + }, + child: Widget.Box({ + homogeneous: false, + children: [ + Widget.Box({ className: 'bar-corner-spacing' }), + Widget.Overlay({ + overlays: [ + Widget.Box({ hexpand: true }), + Widget.Box({ + className: 'bar-sidemodule', hexpand: true, + children: [Widget.Box({ + vertical: true, + className: 'bar-space-button', + children: [ + optionalWindowTitleInstance, + ] + })] + }), + ] + }) + ] + }) + }); +} \ No newline at end of file diff --git a/.config/ags/modules/bar/normal/spaceright.js b/.config/ags/modules/bar/normal/spaceright.js index 0b4fee7b3..cdb92c993 100644 --- a/.config/ags/modules/bar/normal/spaceright.js +++ b/.config/ags/modules/bar/normal/spaceright.js @@ -9,27 +9,28 @@ import Indicator from '../../../services/indicator.js'; import { StatusIcons } from '../../.commonwidgets/statusicons.js'; import { Tray } from "./tray.js"; +const SeparatorDot = () => Widget.Revealer({ + transition: 'slide_left', + revealChild: false, + attribute: { + 'count': SystemTray.items.length, + 'update': (self, diff) => { + self.attribute.count += diff; + self.revealChild = (self.attribute.count > 0); + } + }, + child: Widget.Box({ + vpack: 'center', + className: 'separator-circle', + }), + setup: (self) => self + .hook(SystemTray, (self) => self.attribute.update(self, 1), 'added') + .hook(SystemTray, (self) => self.attribute.update(self, -1), 'removed') + , +}); + export default () => { const barTray = Tray(); - const separatorDot = Widget.Revealer({ - transition: 'slide_left', - revealChild: false, - attribute: { - 'count': SystemTray.items.length, - 'update': (self, diff) => { - self.attribute.count += diff; - self.revealChild = (self.attribute.count > 0); - } - }, - child: Widget.Box({ - vpack: 'center', - className: 'separator-circle', - }), - setup: (self) => self - .hook(SystemTray, (self) => self.attribute.update(self, 1), 'added') - .hook(SystemTray, (self) => self.attribute.update(self, -1), 'removed') - , - }); const barStatusIcons = StatusIcons({ className: 'bar-statusicons', setup: (self) => self.hook(App, (self, currentName, visible) => { @@ -53,7 +54,7 @@ export default () => { const emptyArea = SpaceRightDefaultClicks(Widget.Box({ hexpand: true, })); const indicatorArea = SpaceRightDefaultClicks(Widget.Box({ children: [ - separatorDot, + SeparatorDot(), barStatusIcons ], }));