diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index 1da272d..dd5b113 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -211,7 +211,6 @@ # used for the framework 16 laptop framework-tool framework-tool-tui - krita # image edition yt-dlp# some youtube downloader vlc @@ -223,6 +222,7 @@ libsForQt5.qt5.qtgraphicaleffects mprisence kdePackages.qt5compat + ]; # fonts diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index a371861..1758ed2 100755 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -77,7 +77,9 @@ (pkgs.callPackage ../../modules/scripts/man.nix {}) (pkgs.callPackage ../../modules/scripts/trimmer.nix {}) (pkgs.callPackage ../../modules/scripts/QSsysinfo.nix {}) - #pkgs + (pkgs.callPackage ../../modules/scripts/QSnotifycache.nix {}) + (pkgs.callPackage ../../modules/scripts/QSnotifyhistory.nix {}) +#pkgs pkgs.gruvbox-gtk-theme # # Adds the 'hello' command to your environment. It prints a friendly # # "Hello, world!" when run. diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index a3f6ad3..311bb19 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -202,6 +202,7 @@ in { "custom-mountkdrive" "waybar" "custom-gitnotify" + "QS-notifycache" # builds the cache that will be used for the notification history ######################### # login autostart diff --git a/modules/scripts/QSnotifycache.nix b/modules/scripts/QSnotifycache.nix new file mode 100644 index 0000000..b82eaa5 --- /dev/null +++ b/modules/scripts/QSnotifycache.nix @@ -0,0 +1,17 @@ +# creates and maintains cache file for the notification history +{ + writeShellApplication, + ... +}: +writeShellApplication { + name = "QS-notifycache"; + runtimeInputs = [ + ]; + text = '' +CACHE="$HOME/.cache/notify_history" +# Create or erase existing cache +mkdir -p "$(dirname "$CACHE")" +: > "$CACHE" # truncate file +echo "Notification history initialized at $(date)" >> "$CACHE" + ''; +} diff --git a/modules/scripts/QSnotifyhistory.nix b/modules/scripts/QSnotifyhistory.nix new file mode 100644 index 0000000..3f5210b --- /dev/null +++ b/modules/scripts/QSnotifyhistory.nix @@ -0,0 +1,31 @@ +{ + writeShellApplication, + ... +}: +writeShellApplication { + name = "QS-notifyhistory"; + runtimeInputs = [ + ]; + text = '' + app="$1" + title="$2" + body="$3" + date="$(date +%T)" + urgency="$4" + + case "$urgency" in + 0) urgency_text="low";; + 1) urgency_text="normal";; + 2) urgency_text="critical";; + *) urgency_text="unknown";; + esac + { + echo "$app" + echo "$title" + echo "$body" + echo "$date" + echo "$urgency_text" + + } >> "$HOME/.cache/notify_history" + ''; +} diff --git a/modules/scripts/QSsysinfo.nix b/modules/scripts/QSsysinfo.nix index 6a0d928..a3b90d5 100644 --- a/modules/scripts/QSsysinfo.nix +++ b/modules/scripts/QSsysinfo.nix @@ -47,7 +47,7 @@ for f in /sys/class/hwmon/hwmon*/fan*_input; do count=$((count + 1)) fi done -fan=$(( sum / count / 1000 )) +fan=$(( sum / count )) fan=$(printf "%4s" "$fan") mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}') diff --git a/other/quickshell/notifs/Display.qml b/other/quickshell/notifs/Display.qml index 89a1d3a..d72ac96 100644 --- a/other/quickshell/notifs/Display.qml +++ b/other/quickshell/notifs/Display.qml @@ -15,7 +15,6 @@ Item { ColumnLayout { id: layout - anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right @@ -30,15 +29,23 @@ Item { smooth: false } - Rectangle { + Item { id: bannerRect - color: Theme.Colors.background + //color: "transparent" //Theme.Colors.background Layout.fillWidth: true - implicitHeight: textColumn.height + implicitHeight: textColumn.implicitHeight Layout.leftMargin: (width / trumpetTop.sourceSize.width) * 2 + 3 Layout.rightMargin: (width / trumpetTop.sourceSize.width) * 2 + 3 + Image { + //anchors.right: parent.right + height: textColumn.height + width: textColumn.width + source: "../assets/wood.png" + smooth: false + //opacity: 0.4 + } ColumnLayout { id: textColumn @@ -69,7 +76,7 @@ Item { text: root.notif ? root.notif.summary + (root.notif.body ? "\n" : "") : "" font.family: "BigBlueTermPlusNerdFont" wrapMode: Text.Wrap - font.pointSize: 18 + font.pointSize: 14 font.bold: true color: Theme.Colors.displayColor1 } @@ -78,7 +85,9 @@ Item { text: root.notif ? root.notif.body : "" font.family: "BigBlueTermPlusNerdFont" wrapMode: Text.Wrap - font.pointSize: 14 + Layout.maximumWidth: bannerRect.width + Layout.fillWidth: true + font.pointSize: 11 font.bold: false color: Theme.Colors.displayColor2 } diff --git a/other/quickshell/notifs/NotificationCenter.qml b/other/quickshell/notifs/NotificationCenter.qml new file mode 100644 index 0000000..2f594c5 --- /dev/null +++ b/other/quickshell/notifs/NotificationCenter.qml @@ -0,0 +1,31 @@ +pragma Singleton +pragma ComponentBehavior: Bound + +import QtQuick +import Quickshell +import Quickshell.Io +import "." as Notifs + +Singleton { + id: root + + PanelWindow { + id: window + visible: false + + Notifs.NotificationCenterView { + id: notificationCenter + anchors.right: parent.right + } + } + + IpcHandler { + target: "notifications" + + function toggle() { + window.visible = !window.visible + if (window.visible) + notificationCenter.reload() + } + } +} diff --git a/other/quickshell/notifs/NotificationCenterView.qml b/other/quickshell/notifs/NotificationCenterView.qml new file mode 100644 index 0000000..839101c --- /dev/null +++ b/other/quickshell/notifs/NotificationCenterView.qml @@ -0,0 +1,66 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Quickshell +import Quickshell.Io + +Rectangle { + id: root + width: 1000 + height: 800 + color: "black" + visible: false + // Toggle the notification center visibility + function toggleNotificationCenter() { + root.visible = !root.visible + console.log("DEBUG: Toggled NotificationCenter. Visible =", root.visible) + if (root.visible) { + reload() + } + } + + // FileView for reading the notification cache + FileView { + id: historyFile + path: Quickshell.env("HOME") + "/.cache/notify_history" + blockLoading: true + } + + // Reload notifications from the file + function reload() { + root.visible = true + /*var text = historyFile.text() + if (!text || text.length === 0) { + console.log("DEBUG: Notification file empty") + return + } + + console.log("DEBUG: Raw notification file content:\n" + text) + var lines = text.split("\n") + console.log("DEBUG: Total lines in file:", lines.length) + + var i = 1 + while (i < lines.length) { + var app = lines[i++] || "" + var title = lines[i++] || "" + var bodyLines = [] + + while (i < lines.length && !/^\d{2}:\d{2}:\d{2}$/.test(lines[i])) { + bodyLines.push(lines[i++]) + } + + if (i >= lines.length) break + + var time = lines[i++] || "" + var urgency = lines[i++] || "normal" + var body = bodyLines.join("\n") + + console.log("DEBUG: Parsed notification:", app, title, body, time, urgency) + + }*/ + } + Component.onCompleted: { + console.log("DEBUG: NotificationCenterView component loaded") + reload() + } +} diff --git a/other/quickshell/notifs/OldNotificationCenter.qml b/other/quickshell/notifs/OldNotificationCenter.qml new file mode 100644 index 0000000..70188c2 --- /dev/null +++ b/other/quickshell/notifs/OldNotificationCenter.qml @@ -0,0 +1,44 @@ +pragma Singleton +pragma ComponentBehavior: Bound + +import QtQuick +import Quickshell +import Quickshell.Io +import "." as Notifs + +Singleton { + id: root + property bool isOpen: false + + IpcHandler { + target: "notifications" + + function open() { + root.isOpen = true + } + + function close() { + root.isOpen = false + } + + function toggle() { + root.isOpen = !root.isOpen + } + } + + LazyLoader { + id: loader + active: root.isOpen + Notifs.NotificationCenterView { + id: notificationCenter + anchors.centerIn: parent + width: 1000 + height: 800 + visible: true + } + } + + function init() { + // Empty init function to ensure singleton is loaded + } +} diff --git a/other/quickshell/notifs/OldNotificationCenterView.qml b/other/quickshell/notifs/OldNotificationCenterView.qml new file mode 100644 index 0000000..6104845 --- /dev/null +++ b/other/quickshell/notifs/OldNotificationCenterView.qml @@ -0,0 +1,126 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Quickshell +import Quickshell.Io + +Rectangle { + id: root + width: 1000 + height: 800 + color: "black" + + // Use ListModel so Repeater updates automatically + ListModel { + id: notificationsModel + } + // Toggle the notification center visibility + function toggleNotificationCenter() { + root.visible = !root.visible + console.log("DEBUG: Toggled NotificationCenter. Visible =", root.visible) + if (root.visible) { + reload() + } + } + + // FileView for reading the notification cache + FileView { + id: historyFile + path: Quickshell.env("HOME") + "/.cache/notify_history" + blockLoading: true + } + + // Reload notifications from the file +function reload() { + notificationsModel.clear() + var text = historyFile.text() + if (!text || text.length === 0) { + console.log("DEBUG: Notification file empty") + return + } + + console.log("DEBUG: Raw notification file content:\n" + text) + var lines = text.split("\n") + console.log("DEBUG: Total lines in file:", lines.length) + + var i = 1 + while (i < lines.length) { + var app = lines[i++] || "" + var title = lines[i++] || "" + var bodyLines = [] + + while (i < lines.length && !/^\d{2}:\d{2}:\d{2}$/.test(lines[i])) { + bodyLines.push(lines[i++]) + } + + if (i >= lines.length) break + + var time = lines[i++] || "" + var urgency = lines[i++] || "normal" + var body = bodyLines.join("\n") + + console.log("DEBUG: Parsed notification:", app, title, body, time, urgency) + + notificationsModel.insert(0, { app: app, title: title, body: body, time: time, urgency: urgency }) + } + + console.log("DEBUG: Total notifications loaded:", notificationsModel.count) +} + Component.onCompleted: { + console.log("DEBUG: NotificationCenter component completed") + reload() + } + + // Scrollable list of notifications + ScrollView { + anchors.fill: parent + + ColumnLayout { + id: list + width: parent.width + spacing: 8 +Repeater { + model: notificationsModel + delegate: Rectangle { + width: list.width + height: columnContent.implicitHeight + 20 + color: "transparent" + + Image { + anchors.fill: parent + source: "../assets/wood.png" + fillMode: Image.Stretch + z: 0 + } + + ColumnLayout { + id: columnContent + width: parent.width + //anchors.fill: parent + anchors.margins: 10 + z: 1 + + Text { + text: time + " | " + app + color: urgency === "critical" ? "red" : "white" + } + + Text { + text: title + font.bold: true + color: urgency === "critical" ? "red" : "white" + wrapMode: Text.Wrap + } + + Text { + text: body + wrapMode: Text.Wrap + color: urgency === "critical" ? "red" : "white" + } + } + } +} + + } + } +} diff --git a/other/quickshell/notifs/Overlay.qml b/other/quickshell/notifs/Overlay.qml index dbe7ab3..629b22d 100644 --- a/other/quickshell/notifs/Overlay.qml +++ b/other/quickshell/notifs/Overlay.qml @@ -2,11 +2,14 @@ pragma ComponentBehavior: Bound import QtQuick import Quickshell +import Quickshell.Io import Quickshell.Wayland import Quickshell.Services.Notifications import "../theme" as Theme import "." + + PanelWindow { id: root @@ -23,8 +26,13 @@ PanelWindow { bottom: true right: true } - + Process { + id: notifLogger + } NotificationServer { + + + actionsSupported: true onNotification: notif => { @@ -33,6 +41,9 @@ PanelWindow { if (notif) { notif.tracked = true; root.notifs = [...root.notifs, notif]; + + notifLogger.command = ["QS-notifyhistory", notif.appName, notif.summary, notif.body, notif.urgency] + notifLogger.running = true // logs the notification for later } } } diff --git a/other/quickshell/shell.qml b/other/quickshell/shell.qml index 0a720c9..1a66c5b 100644 --- a/other/quickshell/shell.qml +++ b/other/quickshell/shell.qml @@ -17,9 +17,10 @@ ShellRoot { bar: bar } - Component.onCompleted: () => { + Component.onCompleted: { //Launcher.Controller.init(); Screenshot.Controller.init(); //Lock.Controller.init(); - } + Notifs.NotificationCenter.init(); + } } diff --git a/todo b/todo index 1f2641e..b018f7a 100644 --- a/todo +++ b/todo @@ -24,11 +24,7 @@ deadnix and aljandra to clean up the repo with quickshell: - see all thoses waarnings and errors - set keybinds. for screenshot - fix screenshot (copy, write, etc.) fix player control icons - remove unnecessary stuff give battery percentage maybe modify some of the images (like the notification body) do a full bar (no ugly empty space at top)