From 6128c01c98c8f334ced3e68649fdf450151e8284 Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 5 Jun 2024 23:19:42 +0200 Subject: [PATCH 1/9] shorter bar for small monitors --- .config/ags/modules/bar/main.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index 0a0d8f42e..d5d31cc02 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -1,6 +1,7 @@ const { Gtk } = imports.gi; import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import Battery from 'resource:///com/github/Aylur/ags/service/battery.js'; +import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; import WindowTitle from "./normal/spaceleft.js"; import Indicators from "./normal/spaceright.js"; @@ -82,6 +83,26 @@ export const Bar = async (monitor = 0) => { }) } }); + const shortBarContent = Widget.CenterBox({ + className: 'bar-bg-focus', + startWidget: (await WindowTitle(monitor)), + centerWidget: Widget.Box({ + className: 'spacing-h-4', + children: [ + Widget.Box({ + homogeneous: true, + children: [await FocusOptionalWorkspaces()], + }), + ] + }), + endWidget: Indicators(), + setup: (self) => { + self.hook(Battery, (self) => { + if(!Battery.available) return; + self.toggleClassName('bar-bg-focus-batterylow', Battery.percent <= userOptions.battery.low); + }) + } + }); return Widget.Window({ monitor, name: `bar${monitor}`, @@ -95,9 +116,17 @@ export const Bar = async (monitor = 0) => { children: { 'normal': normalBarContent, 'focus': focusedBarContent, + 'short': shortBarContent, }, setup: (self) => self.hook(currentShellMode, (self) => { - self.shown = currentShellMode.value; + const monitorInfo = Hyprland.getMonitor(monitor); + let width = monitorInfo?.width; + if (monitorInfo?.transform % 2 == 1) + width = monitorInfo?.height; + console.log(width); + let state = currentShellMode.value; + if (width < 1800 && state == 'normal') state = 'short'; + self.shown = state; }) }), }); From fe26540b319fd3c64ff3b37ab4dff42fee4bc859 Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 5 Jun 2024 23:25:54 +0200 Subject: [PATCH 2/9] fixed short bar height --- .config/ags/modules/bar/main.js | 6 +++--- .config/ags/scss/_bar.scss | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index d5d31cc02..f7a65e3fa 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -84,14 +84,14 @@ export const Bar = async (monitor = 0) => { } }); const shortBarContent = Widget.CenterBox({ - className: 'bar-bg-focus', + className: 'bar-bg', startWidget: (await WindowTitle(monitor)), centerWidget: Widget.Box({ className: 'spacing-h-4', children: [ Widget.Box({ homogeneous: true, - children: [await FocusOptionalWorkspaces()], + children: [await NormalOptionalWorkspaces()], }), ] }), @@ -99,7 +99,7 @@ export const Bar = async (monitor = 0) => { setup: (self) => { self.hook(Battery, (self) => { if(!Battery.available) return; - self.toggleClassName('bar-bg-focus-batterylow', Battery.percent <= userOptions.battery.low); + self.toggleClassName('bar-bg-batterylow', Battery.percent <= userOptions.battery.low); }) } }); diff --git a/.config/ags/scss/_bar.scss b/.config/ags/scss/_bar.scss index 31e2161a4..e8095c3ae 100644 --- a/.config/ags/scss/_bar.scss +++ b/.config/ags/scss/_bar.scss @@ -17,6 +17,11 @@ $bar_ws_width_focus_active: 2.045rem; min-height: 2.727rem; } +.bar-bg-batterylow { + background-color: mix($layer0, $errorContainer, 80%); + min-height: 2.727rem; +} + .bar-bg-focus { background-color: $layer0; min-height: 1.364rem; From b11c890a8fed65e267f7e8e575e2731f1f7d4006 Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 5 Jun 2024 23:42:05 +0200 Subject: [PATCH 3/9] fixed height and width for rotated screens --- .../ags/modules/.commondata/hyprlanddata.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.config/ags/modules/.commondata/hyprlanddata.js b/.config/ags/modules/.commondata/hyprlanddata.js index 7489365ec..3df05a31f 100644 --- a/.config/ags/modules/.commondata/hyprlanddata.js +++ b/.config/ags/modules/.commondata/hyprlanddata.js @@ -10,11 +10,21 @@ async function updateStuff() { const display = Gdk.Display.get_default(); monitors.forEach((monitor, i) => { const gdkMonitor = display.get_monitor(i); - monitor.realWidth = monitor.width; - monitor.realHeight = monitor.height; + if (monitor.transform % 2 == 0) { + monitor.realWidth = monitor.width; + monitor.realHeight = monitor.height; + } else { + monitor.realWidth = monitor.height; + monitor.realHeight = monitor.height; + } if (userOptions.monitors.scaleMethod.toLowerCase == "gdk") { - monitor.width = gdkMonitor.get_geometry().width; - monitor.height = gdkMonitor.get_geometry().height; + if (monitor.transform % 2 == 0) { + monitor.width = gdkMonitor.get_geometry().width; + monitor.height = gdkMonitor.get_geometry().height; + } else { + monitor.width = gdkMonitor.get_geometry().height; + monitor.height = gdkMonitor.get_geometry().width; + } } else { // == "division" monitor.width = Math.ceil(monitor.realWidth / monitor.scale); From fcba09b9ff7b23487c204f5e0133cca0d3ca42f8 Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 5 Jun 2024 23:48:54 +0200 Subject: [PATCH 4/9] changed short bar to use existing monitor data --- .config/ags/modules/bar/main.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index f7a65e3fa..9a069fcd9 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -1,8 +1,8 @@ const { Gtk } = imports.gi; import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import Battery from 'resource:///com/github/Aylur/ags/service/battery.js'; -import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js'; +import { monitors } from '../.commondata/hyprlanddata.js'; import WindowTitle from "./normal/spaceleft.js"; import Indicators from "./normal/spaceright.js"; import Music from "./normal/music.js"; @@ -119,13 +119,8 @@ export const Bar = async (monitor = 0) => { 'short': shortBarContent, }, setup: (self) => self.hook(currentShellMode, (self) => { - const monitorInfo = Hyprland.getMonitor(monitor); - let width = monitorInfo?.width; - if (monitorInfo?.transform % 2 == 1) - width = monitorInfo?.height; - console.log(width); let state = currentShellMode.value; - if (width < 1800 && state == 'normal') state = 'short'; + if (monitors[monitor].width < 1800 && state == 'normal') state = 'short'; self.shown = state; }) }), From c14b21719f3910ffda6b6b424d005e3de728298d Mon Sep 17 00:00:00 2001 From: Myryk Date: Wed, 12 Jun 2024 21:48:43 +0200 Subject: [PATCH 5/9] set threshold lower --- .config/ags/modules/bar/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index 71e6ba3c5..4b4898aec 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -124,7 +124,7 @@ export const Bar = async (monitor = 0) => { }, setup: (self) => self.hook(currentShellMode, (self) => { let state = currentShellMode.value; - if (monitors[monitor].width < 1800 && state == 'normal') state = 'short'; + if (monitors[monitor].width < 1400 && state == 'normal') state = 'short'; self.shown = state; }) }), From 95327db0e9ed06f9f0f01ba75912401caa386890 Mon Sep 17 00:00:00 2001 From: Myryk Date: Sat, 15 Jun 2024 13:11:40 +0200 Subject: [PATCH 6/9] fixed mixed up value in hyprlanddata.js --- .config/ags/modules/.commondata/hyprlanddata.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/.commondata/hyprlanddata.js b/.config/ags/modules/.commondata/hyprlanddata.js index 3df05a31f..6992c6236 100644 --- a/.config/ags/modules/.commondata/hyprlanddata.js +++ b/.config/ags/modules/.commondata/hyprlanddata.js @@ -15,10 +15,10 @@ async function updateStuff() { monitor.realHeight = monitor.height; } else { monitor.realWidth = monitor.height; - monitor.realHeight = monitor.height; + monitor.realHeight = monitor.width; } if (userOptions.monitors.scaleMethod.toLowerCase == "gdk") { - if (monitor.transform % 2 == 0) { + if (monitor.transform % 2 == 0) { // does get_geometry() return rotated values? monitor.width = gdkMonitor.get_geometry().width; monitor.height = gdkMonitor.get_geometry().height; } else { From 0de2b941754cedd1ef32f75bbe926295a2682db7 Mon Sep 17 00:00:00 2001 From: Myryk Date: Sun, 16 Jun 2024 00:03:22 +0200 Subject: [PATCH 7/9] added comments --- .config/ags/modules/.commondata/hyprlanddata.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/.commondata/hyprlanddata.js b/.config/ags/modules/.commondata/hyprlanddata.js index 6992c6236..8915e406b 100644 --- a/.config/ags/modules/.commondata/hyprlanddata.js +++ b/.config/ags/modules/.commondata/hyprlanddata.js @@ -10,7 +10,7 @@ async function updateStuff() { const display = Gdk.Display.get_default(); monitors.forEach((monitor, i) => { const gdkMonitor = display.get_monitor(i); - if (monitor.transform % 2 == 0) { + if (monitor.transform % 2 == 0) { //switch width and height if monitor is rotated monitor.realWidth = monitor.width; monitor.realHeight = monitor.height; } else { @@ -18,7 +18,7 @@ async function updateStuff() { monitor.realHeight = monitor.width; } if (userOptions.monitors.scaleMethod.toLowerCase == "gdk") { - if (monitor.transform % 2 == 0) { // does get_geometry() return rotated values? + if (monitor.transform % 2 == 0) { //gdkMonitor also does not account for rotation monitor.width = gdkMonitor.get_geometry().width; monitor.height = gdkMonitor.get_geometry().height; } else { From 591631e4cf130bd61934974fb2a5cc2f818d4de0 Mon Sep 17 00:00:00 2001 From: Myryk Date: Sun, 16 Jun 2024 00:53:31 +0200 Subject: [PATCH 8/9] hiding elements instead of 'short' mode --- .config/ags/modules/bar/main.js | 39 ++++++++++----------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/.config/ags/modules/bar/main.js b/.config/ags/modules/bar/main.js index 4b4898aec..2a80143ee 100644 --- a/.config/ags/modules/bar/main.js +++ b/.config/ags/modules/bar/main.js @@ -83,26 +83,6 @@ export const Bar = async (monitor = 0) => { }) } }); - const shortBarContent = Widget.CenterBox({ - className: 'bar-bg', - startWidget: (await WindowTitle(monitor)), - centerWidget: Widget.Box({ - className: 'spacing-h-4', - children: [ - Widget.Box({ - homogeneous: true, - children: [await NormalOptionalWorkspaces()], - }), - ] - }), - endWidget: Indicators(), - setup: (self) => { - self.hook(Battery, (self) => { - if(!Battery.available) return; - self.toggleClassName('bar-bg-batterylow', Battery.percent <= userOptions.battery.low); - }) - } - }); const nothingContent = Widget.Box({ className: 'bar-bg-nothing', }) @@ -119,15 +99,20 @@ export const Bar = async (monitor = 0) => { children: { 'normal': normalBarContent, 'focus': focusedBarContent, - 'short': shortBarContent, 'nothing': nothingContent, }, - setup: (self) => self.hook(currentShellMode, (self) => { - let state = currentShellMode.value; - if (monitors[monitor].width < 1400 && state == 'normal') state = 'short'; - self.shown = state; - }) - }), + setup: (self) => self + .hook(currentShellMode, (self) => { + self.shown = currentShellMode.value; + }) + .on("size-allocate", (self) => { + if (self.children[currentShellMode.value]?.get_allocated_width() > monitors[monitor].width) { + self.children[currentShellMode.value].centerWidget.children[0].visible = false; + self.children[currentShellMode.value].centerWidget.children[2].visible = false; + } + }) + , + }) }); } From 7df3f68d3e2c78a8febb26e35fcaeff4d7f86d6e Mon Sep 17 00:00:00 2001 From: Myryk Date: Sun, 16 Jun 2024 00:57:22 +0200 Subject: [PATCH 9/9] removed unnecessary css change --- .config/ags/scss/_bar.scss | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.config/ags/scss/_bar.scss b/.config/ags/scss/_bar.scss index df1110f9c..b12123d97 100644 --- a/.config/ags/scss/_bar.scss +++ b/.config/ags/scss/_bar.scss @@ -17,11 +17,6 @@ $bar_ws_width_focus_active: 2.045rem; min-height: 2.727rem; } -.bar-bg-batterylow { - background-color: mix($layer0, $errorContainer, 80%); - min-height: 2.727rem; -} - .bar-bg-focus { background-color: $layer0; min-height: 1.364rem;