dotfiles/.config/quickshell/components/HyprlandWorkspace.qml
2025-06-19 21:21:43 +02:00

39 lines
905 B
QML

import QtQuick
import Quickshell.Hyprland
Text {
id: text
required property int id
required property string icon
required property color default_color
required property color empty_color
required property color active_color
text: icon
color: empty_color
Component.onCompleted: {
Hyprland.rawEvent.connect(hyprEvent)
colorWorkspace()
}
function hyprEvent(e) {
if (e.name == "workspace") {
if (e.data == id) {
text.color = text.active_color
} else {
colorWorkspace()
}
}
}
function colorWorkspace() {
if (Hyprland.workspaces.values.some((w) => {
return w.id == id && w.lastIpcObject.windows > 0
})) {
text.color = text.default_color
} else {
text.color = text.empty_color
}
}
}