summaryrefslogtreecommitdiff
path: root/bar
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-09 11:55:23 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-09 11:55:23 +0800
commitca9fcf800485ac5dff633275d56f0b33c4670225 (patch)
treea354cfeca9c5602e46ab31b3b1983e23dd64fedb /bar
parentb707a6ee3ebfb5b527af63f0eacfb63ec1a580cb (diff)
finished bar
Diffstat (limited to 'bar')
-rw-r--r--bar/Workspace.qml59
1 files changed, 47 insertions, 12 deletions
diff --git a/bar/Workspace.qml b/bar/Workspace.qml
index 2f8d1ea..9c78e30 100644
--- a/bar/Workspace.qml
+++ b/bar/Workspace.qml
@@ -1,21 +1,56 @@
import "../services"
+import "../config"
import QtQuick.Layouts
import QtQuick
import Quickshell
Item {
- Layout.preferredHeight: 50
- Layout.preferredWidth: parent.width / 3
+ Layout.preferredHeight: 50
+ Layout.preferredWidth: parent.width / 3
- RowLayout {
- anchors.fill: parent
- spacing: 0
- Repeater {
- model: Hyprland.workspaces
+ property list<bool> workspaceOccupied: []
- Text {
- text: modelData.active ? modelData.name + " (Active)" : modelData.name
- }
- }
- }
+ function updateWorkspaceOccupied() {
+ // workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => {
+ // return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1);
+ // })
+ workspaceOccupied = Array.from({ length: Bar.workspaces }, (_, i) => {
+ return Hyprland.workspaces.values.some(ws => ws.id === (i + 1));
+ });
+ }
+ function isActive(index: int): bool {
+ Hyprland.focusedWorkspace.id.toString() == (index + 1).toString();
+ }
+ function isOccupied(index: int): bool {
+ return workspaceOccupied[index] === true;
+ }
+
+ Connections {
+ target: Hyprland.workspaces
+ function onValuesChanged() {
+ updateWorkspaceOccupied();
+ }
+ }
+
+ Component.onCompleted: updateWorkspaceOccupied()
+
+ RowLayout {
+ anchors.fill: parent
+ spacing: 0
+ Repeater {
+ model: Bar.workspaces
+
+ Rectangle {
+ Text {
+ text: Hyprland.focusedWorkspace.id.toString() == (index + 1).toString()
+ // text: isActive(index)
+ }
+ implicitWidth: 10
+ implicitHeight: 10
+ opacity: !isOccupied(index) ? 0.2 : 1
+ // color: isActive(index) ? "#00ff00" : "#ffffff"
+ color: "#000000"
+ }
+ }
+ }
}