From 3bb67a9a4f55203f1aea12cd714a9b100e53857f Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 11 Apr 2025 01:39:31 +0200 Subject: [PATCH] bar: workspaces: better occupied state --- .config/quickshell/modules/bar/Workspaces.qml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.config/quickshell/modules/bar/Workspaces.qml b/.config/quickshell/modules/bar/Workspaces.qml index 0eaf706a4..6730a6515 100644 --- a/.config/quickshell/modules/bar/Workspaces.qml +++ b/.config/quickshell/modules/bar/Workspaces.qml @@ -4,14 +4,16 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import Quickshell +import Quickshell.Wayland import Quickshell.Hyprland import Quickshell.Io Rectangle { required property var bar readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen) - readonly property list workspaceOccupied: [] + readonly property Toplevel activeWindow: ToplevelManager.activeToplevel readonly property int workspaceGroup: Math.floor((monitor.activeWorkspace?.id - 1) / ConfigOptions.bar.workspacesShown) + property list workspaceOccupied: [] property int widgetPadding: 4 property int workspaceButtonWidth: 26 property int activeWorkspaceMargin: 1 @@ -29,7 +31,10 @@ Rectangle { function updateWorkspaceOccupied() { workspaceOccupied = Array.from({ length: ConfigOptions.bar.workspacesShown }, (_, i) => { return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * ConfigOptions.bar.workspacesShown + i + 1); - }); + }) + if(!activeWindow?.activated) { + workspaceOccupied[(monitor.activeWorkspace?.id - 1) % ConfigOptions.bar.workspacesShown] = false; + } } // Initialize workspaceOccupied when the component is created