Create Hyprland IPC hook for silencing notifications, fix a typo in NotificationsWidget

This commit is contained in:
Amaro Lopes
2025-10-09 23:25:04 -03:00
parent 0a52c18f6f
commit 3c9d671535
3 changed files with 36 additions and 5 deletions

View File

@@ -65,10 +65,7 @@ Item {
id: notifText id: notifText
anchors.fill: parent anchors.fill: parent
text: root.notificationIcon + " " text: root.notificationIcon
// text: {
// NotificationService.notificationsNumber > 0 ? "\udb80\udc9a " + NotificationService.notificationsNumber : "\ueaa2";
// }
} }
MouseArea { MouseArea {

View File

@@ -3,13 +3,18 @@ pragma Singleton
import Quickshell import Quickshell
import Quickshell.Hyprland import Quickshell.Hyprland
import Quickshell.Wayland import Quickshell.Wayland
import Quickshell.Io
Singleton { Singleton {
id:root
readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")
readonly property var focusedMon: Hyprland.focusedMonitor readonly property var focusedMon: Hyprland.focusedMonitor
property var hasFullscreen: false
property var isScreencasting: false
property var sortedTopLevels: { property var sortedTopLevels: {
if (!ToplevelManager.toplevels || !ToplevelManager.toplevels.values) { if (!ToplevelManager.toplevels || !ToplevelManager.toplevels.values) {
return []; return [];
@@ -87,4 +92,33 @@ Singleton {
} }
return workspaceDesktopEntries; return workspaceDesktopEntries;
} }
Socket {
path: `${Quickshell.env("XDG_RUNTIME_DIR")}/hypr/${Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")}/.socket2.sock`
connected: true
parser: SplitParser {
property var fullscreenRegex: new RegExp("fullscreen>>.");
property var screencastRegex: new RegExp("screencast>>.*")
onRead: msg => {
let match = fullscreenRegex.exec(msg);
if (match != null) {
if(msg.split(">>")[1] === "1") {
root.hasFullscreen = true
} else {
root.hasFullscreen = false
}
}
match = screencastRegex.exec(msg);
if (match != null) {
if(msg.split(">>")[1].split(',')[0] === "1") {
root.isScreencasting = true
} else {
root.isScreencasting = false
}
}
}
}
}
} }

View File

@@ -14,7 +14,7 @@ Singleton {
readonly property var trackedNotifications: notificationServer.trackedNotifications readonly property var trackedNotifications: notificationServer.trackedNotifications
readonly property var notificationsNumber: notificationServer.trackedNotifications.values.length readonly property var notificationsNumber: notificationServer.trackedNotifications.values.length
property bool notificationsMuted: false property bool notificationsMuted: HyprlandService.hasFullscreen || HyprlandService.isScreencasting
property ListModel globalList: ListModel {} property ListModel globalList: ListModel {}
NotificationServer { NotificationServer {