From 92877d23415231c81a4fb838da6f815e270258e1 Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Fri, 20 Jun 2025 10:13:58 +0200 Subject: [PATCH] small quickshell changes --- .config/quickshell/components/Bar.qml | 11 ++-- .../components/HyprlandWorkspace.qml | 59 +++++++++++-------- .../components/NotificationPanel.qml | 4 +- .../widgets/HyprlandWorkspacesWidget.qml | 31 ++++++---- 4 files changed, 63 insertions(+), 42 deletions(-) diff --git a/.config/quickshell/components/Bar.qml b/.config/quickshell/components/Bar.qml index 790823f..aa961f8 100644 --- a/.config/quickshell/components/Bar.qml +++ b/.config/quickshell/components/Bar.qml @@ -11,7 +11,8 @@ Scope { property font customFont: Qt.font({ bold: true, pointSize: 12, - family: "FantasqueSansMNerdFont" + // forgot which font I'm actually using, this yields some fallback that works well. + family: "NF" }) Variants { @@ -34,8 +35,8 @@ Scope { right: 10 } - height: 50 - color: "#171a18" + implicitHeight: 50 + color: "#15121b" RowLayout { spacing: 15 @@ -54,8 +55,8 @@ Scope { HyprlandWorkspacesWidget { font: customFont - default_color: "#689D6A" - active_color: "#8ec07c" + default_color: "#cdd6f4" + active_color: "#ebbcba" empty_color: "#928374" spacing: 15 } diff --git a/.config/quickshell/components/HyprlandWorkspace.qml b/.config/quickshell/components/HyprlandWorkspace.qml index 1b9cf91..d2256c9 100644 --- a/.config/quickshell/components/HyprlandWorkspace.qml +++ b/.config/quickshell/components/HyprlandWorkspace.qml @@ -1,39 +1,52 @@ import QtQuick import Quickshell.Hyprland +import Quickshell.Widgets -Text { - id: text +WrapperRectangle { required property int id required property string icon required property color default_color required property color empty_color required property color active_color + required property font font + property bool active: false + color: active ? "#753a88" : "transparent" - text: icon - color: empty_color + radius: 20 + topMargin: 3 + bottomMargin: 3 + leftMargin: active ? 12 : 6 + rightMargin: active ? 12 : 6 - Component.onCompleted: { - Hyprland.rawEvent.connect(hyprEvent) - colorWorkspace() - } + Text { + text: icon + color: active ? parent.active_color : parent.empty_color + font: parent.font - function hyprEvent(e) { - if (e.name == "workspace") { - if (e.data == id) { - text.color = text.active_color + Component.onCompleted: { + Hyprland.rawEvent.connect(hyprEvent) + colorWorkspace() + } + + function hyprEvent(e) { + if (e.name == "workspace") { + parent.active = e.data == id + if (e.data == id) { + text.color = parent.active_color + } else { + colorWorkspace() + } + } + } + + function colorWorkspace() { + if (Hyprland.workspaces.values.some((w) => { + return w.id == id && w.lastIpcObject.windows > 0 + })) { + text.color = parent.default_color } else { - colorWorkspace() + text.color = parent.empty_color } } } - - 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 - } - } } diff --git a/.config/quickshell/components/NotificationPanel.qml b/.config/quickshell/components/NotificationPanel.qml index 51583c0..2b5880c 100644 --- a/.config/quickshell/components/NotificationPanel.qml +++ b/.config/quickshell/components/NotificationPanel.qml @@ -10,8 +10,8 @@ PanelWindow { required property color text_color property list notification_objects - width: 500 - height: 600 + implicitWidth: 500 + implicitHeight: 600 color: "#171a18" diff --git a/.config/quickshell/widgets/HyprlandWorkspacesWidget.qml b/.config/quickshell/widgets/HyprlandWorkspacesWidget.qml index f07762d..b44a438 100644 --- a/.config/quickshell/widgets/HyprlandWorkspacesWidget.qml +++ b/.config/quickshell/widgets/HyprlandWorkspacesWidget.qml @@ -4,7 +4,7 @@ import QtQuick.Layouts RowLayout { id: container - property var icons: {1: "一", 2: "二", 3: "三", 4: "四", 5: "五"} + property var icons: {1: "1", 2: "2", 3: "3", 4: "4", 5: "5"} property int nWorkspaces: 5 property font font property color default_color @@ -12,22 +12,29 @@ RowLayout { property color active_color Component.onCompleted: { - var workspaceComponent = Qt.createComponent("../components/HyprlandWorkspace.qml"); + var workspaceComponent = Qt.createComponent("../components/HyprlandWorkspace.qml") + Hyprland.rawEvent.connect(hyprEvent) for (var i = 1; i <= nWorkspaces; i++) { var workspace = workspaceComponent - .createObject(container, - { - id: i, - icon: icons[i], - font: font, - default_color: default_color, - empty_color: empty_color, - active_color: active_color - } - ) + .createObject(container, + { + id: i, + icon: icons[i], + font: font, + default_color: default_color, + empty_color: empty_color, + active_color: active_color + } + ) if (workspace == null) { console.log("Error creating workspace") } } } + + function hyprEvent(e) { + // console.log(e.name, e.data) + // console.log(Hyprland.workspaces.values) + // console.log(Hyprland) + } }