This commit is contained in:
Bloxx12 2025-06-24 07:46:51 +02:00
commit 1a27b905bf
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
16 changed files with 622 additions and 177 deletions

42
services/Notification.qml Normal file
View file

@ -0,0 +1,42 @@
pragma Singleton
pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Services.Notifications
import QtQuick
Singleton {
id: root
readonly property list<Notif> list: []
readonly property list<Notif> popups: list.filter(n => n.popup)
NotificationServer {
id: server
keepOnReload: false
onNotification: notif => {
notif.tracked = true;
root.list.push(notifComp.createObject(root, {
popup: true,
notification: notif
}));
}
}
component Notif: QtObject {
property bool popup
readonly property date time: new Date()
required property Notification notification
readonly property string summary: notification.summary
}
Component {
id: notifComp
Notif {}
}
}

85
services/niri/Niri.qml Normal file
View file

@ -0,0 +1,85 @@
// Kind thanks to https://github.com/MapoMagpie/nixos-flakes/blob/main/home/ui/quickshell/config/Data/Niri.qml
// This file was taken from there and further modified.
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
// property var data
property var workspaces: []
property var activeWorkspace: "VOID"
property var activeWorkspaceIndex: 0
property var windows: []
// property var activedWindowId: 0
Process {
id: proc
command: ["niri", "msg", "-j", "event-stream"]
running: true
stdout: SplitParser {
onRead: data => {
var event = JSON.parse(data);
let workspaces = [];
if (event.WorkspacesChanged) {
root.workspaces = event.WorkspacesChanged.workspaces.filter(w => w.name);
root.workspaces = root.workspaces.sort((a, b) => a.id - b.id);
root.activeWorkspaceIndex = root.workspaces.findIndex(w => w.is_focused);
if (root.activeWorkspaceIndex < 0) {
root.activeWorkspaceIndex = 0;
}
root.activeWorkspace = root.workspaces[root.activeWorkspaceIndex].name;
}
if (event.WindowsChanged) {
root.windows = [...event.WindowsChanged.windows].sort((a, b) => a.id - b.id);
}
if (event.WindowOpenedOrChanged) {
const window = event.WindowOpenedOrChanged.window;
const index = root.windows.findIndex(w => w.id === window.id);
// console.log("window opened or changed: ", index, ", win id: ", window.id);
if (index >= 0) {
// console.log("replace window, old: ", root.windows[index].id, ", new: ", window.id);
root.windows[index] = window;
} else {
// console.log("push window, new: ", window.id);
root.windows.push(window);
}
root.windows = [...root.windows.sort((a, b) => a.id - b.id)];
}
if (event.WindowClosed) {
const index = root.windows.findIndex(w => w.id === event.WindowClosed.id);
// console.log("window closed: ", index, ", win id: ", event.WindowClosed.id);
if (index >= 0) {
root.windows.splice(index, 1);
}
root.windows = [...root.windows.sort((a, b) => a.id - b.id)];
}
if (event.WorkspaceActivated) {
root.activeWorkspaceIndex = root.workspaces.findIndex(w => w.id === event.WorkspaceActivated.id);
if (root.activeWorkspaceIndex < 0) {
root.activeWorkspaceIndex = 0;
}
root.activeWorkspace = root.workspaces[root.activeWorkspaceIndex].name;
}
}
}
}
}
// {
// "workspaces": [
// {
// "id": 5,
// "idx": 4,
// "name": "GAME",
// "output": "DP-3",
// "is_active": false,
// "is_focused": false,
// "active_window_id": null
// },
// ]
// }