summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-29 23:45:12 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-04-29 23:45:12 +1000
commit2fd1e90d57378e7335bf72496d4787cddbed890f (patch)
tree811ce727710bf0404f6c1009d7daab8331cd9fd3
parentbar: animate tray recolour (diff)
downloadcaelestia-shell-2fd1e90d57378e7335bf72496d4787cddbed890f.tar.gz
caelestia-shell-2fd1e90d57378e7335bf72496d4787cddbed890f.tar.bz2
caelestia-shell-2fd1e90d57378e7335bf72496d4787cddbed890f.zip
bar: fix activewindow
-rw-r--r--modules/bar/components/ActiveWindow.qml2
-rw-r--r--services/Hyprland.qml37
-rw-r--r--utils/Icons.qml7
3 files changed, 24 insertions, 22 deletions
diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml
index b4dc14d..6d8d10e 100644
--- a/modules/bar/components/ActiveWindow.qml
+++ b/modules/bar/components/ActiveWindow.qml
@@ -15,7 +15,7 @@ StyledRect {
MaterialIcon {
id: icon
- text: Icons.getAppCategoryIcon(Hyprland.activeClient?.class) ?? "desktop_windows"
+ text: Icons.getAppCategoryIcon(Hyprland.activeClient?.wmClass, "desktop_windows")
color: root.colour
}
diff --git a/services/Hyprland.qml b/services/Hyprland.qml
index 92f1de5..336be73 100644
--- a/services/Hyprland.qml
+++ b/services/Hyprland.qml
@@ -11,7 +11,7 @@ Singleton {
property list<Client> clients: []
readonly property var workspaces: Hyprland.workspaces
readonly property var monitors: Hyprland.monitors
- readonly property Client activeClient: Client {}
+ property Client activeClient: null
readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null
readonly property HyprlandMonitor focusedMonitor: Hyprland.monitors.values.find(m => m.lastIpcObject.focused) ?? null
@@ -54,25 +54,30 @@ Singleton {
id: getActiveClient
command: ["sh", "-c", "hyprctl -j activewindow | jq -c"]
stdout: SplitParser {
- onRead: data => root.activeClient.lastIpcObject = JSON.parse(data)
+ onRead: data => {
+ const client = JSON.parse(data);
+ root.activeClient = client.address ? clientComp.createObject(root, {
+ lastIpcObject: client
+ }) : null;
+ }
}
}
component Client: QtObject {
- property var lastIpcObject
- property string address: lastIpcObject?.address ?? ""
- property string wmClass: lastIpcObject?.class ?? ""
- property string title: lastIpcObject?.title ?? ""
- property string initialClass: lastIpcObject?.initialClass ?? ""
- property string initialTitle: lastIpcObject?.initialTitle ?? ""
- property int x: (lastIpcObject?.at ?? [])[0] ?? 0
- property int y: (lastIpcObject?.at ?? [])[1] ?? 0
- property int width: (lastIpcObject?.size ?? [])[0] ?? 0
- property int height: (lastIpcObject?.size ?? [])[1] ?? 0
- property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject?.workspace?.id) ?? null
- property bool floating: lastIpcObject?.floating ?? false
- property bool fullscreen: lastIpcObject?.fullscreen ?? false
- property int pid: lastIpcObject?.pid ?? 0
+ required property var lastIpcObject
+ property string address: lastIpcObject.address
+ property string wmClass: lastIpcObject.class
+ property string title: lastIpcObject.title
+ property string initialClass: lastIpcObject.initialClass
+ property string initialTitle: lastIpcObject.initialTitle
+ property int x: lastIpcObject.at[0]
+ property int y: lastIpcObject.at[1]
+ property int width: lastIpcObject.size[0]
+ property int height: lastIpcObject.size[1]
+ property HyprlandWorkspace workspace: Hyprland.workspaces.values.find(w => w.id === lastIpcObject.workspace.id) ?? null
+ property bool floating: lastIpcObject.floating
+ property bool fullscreen: lastIpcObject.fullscreen
+ property int pid: lastIpcObject.pid
}
Component {
diff --git a/utils/Icons.qml b/utils/Icons.qml
index 92d8de8..312ae6d 100644
--- a/utils/Icons.qml
+++ b/utils/Icons.qml
@@ -152,17 +152,14 @@ Singleton {
property string osIcon: ""
- function getAppCategoryIcon(name: string): string {
- if (!name)
- return null;
-
+ function getAppCategoryIcon(name: string, fallback: string): string {
const categories = DesktopEntries.applications.values.find(app => app.id === name)?.categories;
if (categories)
for (const [key, value] of Object.entries(this.categoryIcons))
if (categories.includes(key))
return value;
- return "terminal";
+ return fallback;
}
function getNetworkIcon(strength: int): string {