From 7922ded35ff292e485c3369dab9726b9142ce526 Mon Sep 17 00:00:00 2001 From: coast Date: Mon, 7 Sep 2026 07:07:22 +0330 Subject: a lot of quickshell --- .../modules/notifications/NotificationFocus.qml | 123 +++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 home-configuration/config/quickshell/modules/notifications/NotificationFocus.qml (limited to 'home-configuration/config/quickshell/modules/notifications/NotificationFocus.qml') diff --git a/home-configuration/config/quickshell/modules/notifications/NotificationFocus.qml b/home-configuration/config/quickshell/modules/notifications/NotificationFocus.qml new file mode 100644 index 0000000..af52eaa --- /dev/null +++ b/home-configuration/config/quickshell/modules/notifications/NotificationFocus.qml @@ -0,0 +1,123 @@ +import QtQuick +import Quickshell +import Quickshell.Io +import "../../config.js" as Config + +Item { + id: root + + property string pendingApp: "" + + Process { + id: windowsProcess + + command: ["niri", "msg", "-j", "windows"] + + stdout: StdioCollector { + id: windowsOutput + + onStreamFinished: { + var windows + + try { + windows = JSON.parse(this.text) + } catch (error) { + console.error( + "Failed to parse niri windows:", + error + ) + + root.pendingApp = "" + return + } + + var app = root.pendingApp.toLowerCase() + root.pendingApp = "" + + if (Config.notificationVesktopNames.indexOf(app) !== -1) { + for (var i = 0; i < windows.length; i++) { + var niriWindow = windows[i] + var appId = (niriWindow.app_id || "").toLowerCase() + + if (appId === Config.notificationVesktopAppId) { + console.log( + "FOCUSING VESKTOP WINDOW:", + niriWindow.id, + niriWindow.title + ) + + focusProcess.exec([ + "niri", + "msg", + "action", + "focus-window", + "--id", + String(niriWindow.id) + ]) + + return + } + } + + console.log( + "No matching Niri window found for:", + app + ) + + return + } + + for (var j = 0; j < windows.length; j++) { + var window = windows[j] + var windowAppId = (window.app_id || "").toLowerCase() + + if ( + windowAppId === app || + windowAppId === app + ".desktop" + ) { + console.log( + "FOCUSING WINDOW:", + window.id, + window.app_id, + window.title + ) + + focusProcess.exec([ + "niri", + "msg", + "action", + "focus-window", + "--id", + String(window.id) + ]) + + return + } + } + + console.log( + "No matching Niri window found for:", + app + ) + } + } + } + + Process { + id: focusProcess + } + + function focusSource(notification) { + if (!notification) + return + + root.pendingApp = notification.appName + + windowsProcess.exec([ + "niri", + "msg", + "-j", + "windows" + ]) + } +} -- cgit v1.3