Add notification panel with unread badge, drop window switcher button

Bell button (left of the workspaces, left of the clock in taskbar mode) opens
a full-height right-edge panel of mako notifications; clicking one marks it
read via scripts/notifs.py. Window switcher stays on Mod+Shift+A.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
nico
2026-09-26 01:34:52 +02:00
parent df4acf1523
commit 85fee48d10
4 changed files with 313 additions and 23 deletions

View File

@@ -25,13 +25,14 @@ Waybar has been fully retired. The whole top bar is one Quickshell shell (`quick
- **Logo + workspaces** — per-monitor workspace pills (Hyprland IPC), click to switch. Click the logo itself to toggle taskbar mode (below)
- **Taskbar mode** — clicking the logo swaps the workspace pills, window title, and stat pills for a compact Windows-style taskbar of every open window, shown as icon buttons (resolved via `DesktopEntries.heuristicLookup()`, the same mechanism app launchers use, falling back to the title's first letter if no icon is found). Hover a button for the full title, click to focus. Clock and power button stay visible in both modes
- **Window switcher** — a button between the workspaces and the window title that drops down a list of every open window across all workspaces; click one to focus it. Also bound to `Mod+Shift+A`
- **Window switcher** — `Mod+Shift+A` drops down a list of every open window across all workspaces; click one to focus it
- **Active window title** — per-monitor, shows the title of whichever window is focused on that specific screen
- **System tray** — StatusNotifierItem icons with left-click activate / right-click context menu
- **CPU / RAM / disk / GPU** — live stats pills with hover tooltips (per-core CPU breakdown, load average, memory/disk usage, GPU temperature + VRAM); click the CPU pill to toggle it between usage % and temperature
- **Volume** — click opens the mixer, right-click mutes, scroll adjusts volume (via `wpctl`)
- **Network** — shows the active connection (Wi-Fi SSID or wired); hover shows the local IP, click toggles to the public IP
- **Clock** — hover for the full date + ISO week number, click opens a small month calendar
- **Notification panel** — the bell button (with an unread badge) opens a panel down the right screen edge, top to bottom, listing recent notifications from mako's history. Click a notification (or “Mark all read”) to mark it read and drop it from the list. mako can't delete single history entries, so read state is kept by `scripts/notifs.py` in `~/.local/state/quickshell/notifs-read`
- **Power menu** — restart / shutdown / logout dropdown
All the stats are pulled by small shell scripts in `quickshell/default/scripts/` rather than baked into the QML.

View File

@@ -23,7 +23,7 @@ icon-border-radius=8
max-visible=5
sort=-time
history=1
max-history=20
max-history=50
default-timeout=5000
[urgency=critical]

View File

@@ -97,6 +97,8 @@ Variants {
property string hovered: ""
property bool menuOpen: false
property bool calendarOpen: false
property bool notifOpen: false
property var notifList: []
property bool taskbarMode: false
property bool clockHovering: false
property bool netHovering: false
@@ -181,6 +183,77 @@ Variants {
Timer { interval: 100; running: true; repeat: false; onTriggered: statsProc.running = true }
Timer { interval: 1000; running: true; repeat: true; onTriggered: statsProc.running = true }
Component {
id: bellComp
Rectangle {
anchors.fill: parent
radius: 10
color: (bellArea.containsMouse || bar.notifOpen) ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
Text {
anchors.centerIn: parent
text: bar.notifList.length > 0 ? "\uf0f3" : "\uf0a2"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: (bellArea.containsMouse || bar.notifOpen) ? "#0f111a" : (bar.notifList.length > 0 ? "#1793d1" : "#565f89")
}
Rectangle {
visible: bar.notifList.length > 0
anchors { top: parent.top; right: parent.right; topMargin: -3; rightMargin: -3 }
width: Math.max(14, badgeText.implicitWidth + 6)
height: 14
radius: 7
color: "#f7768e"
Text {
id: badgeText
anchors.centerIn: parent
text: bar.notifList.length > 99 ? "99+" : bar.notifList.length
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 9
font.bold: true
color: "#0f111a"
}
}
MouseArea {
id: bellArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
bar.notifOpen = !bar.notifOpen
if (bar.notifOpen) notifProc.running = true
}
}
}
}
// ---- notification panel (mako history minus what was marked read) ----
Process {
id: notifProc
command: ["python3", "/home/nico/.config/quickshell/default/scripts/notifs.py"]
stdout: StdioCollector { id: notifCollector }
onExited: {
try { bar.notifList = JSON.parse(notifCollector.text) } catch (e) {}
}
}
Process {
id: notifReadProc
onExited: notifProc.running = true
}
function markRead(keys) {
var gone = {}
keys.forEach(function (k) { gone[k] = true })
notifList = notifList.filter(function (n) { return !gone[n.key] })
notifReadProc.command = ["python3", "/home/nico/.config/quickshell/default/scripts/notifs.py", "read"].concat(keys)
notifReadProc.running = true
}
Timer { interval: 400; running: true; repeat: false; onTriggered: notifProc.running = true }
Timer { interval: 4000; running: true; repeat: true; onTriggered: notifProc.running = true }
Process {
id: netProc
command: ["bash", "-c", "conn=$(nmcli -t -f TYPE,STATE,CONNECTION device status 2>/dev/null | awk -F: '$2==\"connected\"{print $1; exit}'); if [ \"$conn\" = \"wifi\" ]; then name=$(nmcli -t -f active,ssid dev wifi 2>/dev/null | awk -F: '$1==\"yes\"{print $2; exit}'); else name=\"LAN\"; fi; ip=$(ip route get 1.1.1.1 2>/dev/null | awk '{for(i=1;i<=NF;i++) if ($i==\"src\") print $(i+1)}'); echo \"${conn}|${name}|${ip}\""]
@@ -342,28 +415,12 @@ Variants {
}
}
Rectangle {
id: winSwitchBtn
Loader {
id: bellBtn
visible: !bar.taskbarMode
Layout.preferredWidth: visible ? 26 : 0
Layout.preferredWidth: visible ? 32 : 0
Layout.preferredHeight: 26
radius: 10
color: (winSwitchArea.containsMouse || root.windowSwitcherOpen) ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
Text {
anchors.centerIn: parent
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: (winSwitchArea.containsMouse || root.windowSwitcherOpen) ? "#0f111a" : "#7aa2f7"
}
MouseArea {
id: winSwitchArea
anchors.fill: parent
hoverEnabled: true
onClicked: root.windowSwitcherOpen = !root.windowSwitcherOpen
}
sourceComponent: bellComp
}
}
@@ -968,6 +1025,13 @@ Variants {
}
}
Loader {
visible: bar.taskbarMode
Layout.preferredWidth: visible ? 32 : 0
Layout.preferredHeight: 26
sourceComponent: bellComp
}
Rectangle {
id: clockPill
Layout.preferredWidth: 100
@@ -1259,6 +1323,161 @@ Variants {
}
}
LazyLoader {
active: bar.notifOpen
PanelWindow {
id: notifWindow
screen: bar.modelData
anchors { top: true; right: true; bottom: true }
margins { top: 34; right: 8; bottom: 8 }
implicitWidth: 380
color: "transparent"
WlrLayershell.namespace: "notif-panel"
WlrLayershell.layer: WlrLayer.Top
HyprlandFocusGrab {
windows: [ notifWindow ]
active: true
onCleared: bar.notifOpen = false
}
Rectangle {
anchors.fill: parent
radius: 12
color: "#f01a1b26"
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
ColumnLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 8
RowLayout {
Layout.fillWidth: true
Text {
Layout.fillWidth: true
text: root.isGerman ? "Benachrichtigungen" : "Notifications"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
font.bold: true
color: "#c0caf5"
}
Rectangle {
visible: bar.notifList.length > 0
Layout.preferredWidth: readAllText.implicitWidth + 16
Layout.preferredHeight: 24
radius: 8
color: readAllArea.containsMouse ? "#1793d1" : Qt.rgba(0.478, 0.635, 0.969, 0.15)
Text {
id: readAllText
anchors.centerIn: parent
text: "\uf00c " + (root.isGerman ? "Alle gelesen" : "Mark all read")
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: readAllArea.containsMouse ? "#0f111a" : "#c0caf5"
}
MouseArea {
id: readAllArea
anchors.fill: parent
hoverEnabled: true
onClicked: bar.markRead(bar.notifList.map(function (n) { return n.key }))
}
}
}
Text {
visible: bar.notifList.length === 0
Layout.fillWidth: true
Layout.topMargin: 20
horizontalAlignment: Text.AlignHCenter
text: root.isGerman ? "Alles gelesen" : "All caught up"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
color: "#565f89"
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
spacing: 6
model: bar.notifList
boundsBehavior: Flickable.StopAtBounds
delegate: Rectangle {
required property var modelData
width: ListView.view.width
height: cardCol.implicitHeight + 16
radius: 10
color: cardArea.containsMouse ? Qt.rgba(0.478, 0.635, 0.969, 0.18) : Qt.rgba(0.478, 0.635, 0.969, 0.08)
border.width: modelData.urgency === "critical" ? 1 : 0
border.color: "#f7768e"
ColumnLayout {
id: cardCol
anchors { left: parent.left; right: parent.right; top: parent.top; margins: 8 }
spacing: 2
RowLayout {
Layout.fillWidth: true
Text {
Layout.fillWidth: true
text: modelData.app
elide: Text.ElideRight
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 10
color: "#1793d1"
}
Text {
text: "\uf00c"
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: cardArea.containsMouse ? "#a6e3a1" : "#565f89"
}
}
Text {
Layout.fillWidth: true
text: modelData.summary
wrapMode: Text.Wrap
maximumLineCount: 2
elide: Text.ElideRight
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 12
font.bold: true
color: "#c0caf5"
}
Text {
visible: modelData.body !== ""
Layout.fillWidth: true
text: modelData.body
wrapMode: Text.Wrap
maximumLineCount: 4
elide: Text.ElideRight
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 11
color: "#9aa5ce"
}
}
MouseArea {
id: cardArea
anchors.fill: parent
hoverEnabled: true
onClicked: bar.markRead([modelData.key])
}
}
}
}
}
}
}
LazyLoader {
active: bar.calendarOpen
@@ -1470,7 +1689,7 @@ Variants {
id: winSwitchPopup
screen: bar.modelData
anchors { top: true; left: true }
margins { top: 34; left: leftRow.x + winSwitchBtn.x }
margins { top: 34; left: leftRow.x + bellBtn.x + bellBtn.width + 6 }
implicitWidth: 320
implicitHeight: winSwitchCol.implicitHeight + 16
color: "transparent"

View File

@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Notification panel backend: mako's list + history minus what was marked read.
notifs.py print the unread notifications as JSON, newest first
notifs.py read KEY.. mark those keys as read
notifs.py readall mark everything currently listed as read
mako can't delete single history entries, so "read" lives in our own state file.
A key hashes id + app + text, so ids restarting from 1 after a mako restart
don't hide new notifications.
"""
import hashlib
import json
import os
import subprocess
import sys
STATE = os.path.join(os.environ.get("XDG_STATE_HOME", os.path.expanduser("~/.local/state")), "quickshell", "notifs-read")
KEEP = 500
def mako(cmd):
try:
out = subprocess.run(["makoctl", cmd, "-j"], capture_output=True, text=True, timeout=3).stdout
return json.loads(out or "[]")
except Exception:
return []
def all_notifs():
seen, items = set(), []
for n in mako("list") + mako("history"):
if n["id"] in seen:
continue
seen.add(n["id"])
raw = f'{n["id"]}\0{n.get("app_name")}\0{n.get("summary")}\0{n.get("body")}'
items.append({
"key": hashlib.sha1(raw.encode()).hexdigest()[:16],
"id": n["id"],
"app": n.get("app_name") or "",
"summary": n.get("summary") or "",
"body": n.get("body") or "",
"urgency": n.get("urgency") or "normal",
})
return sorted(items, key=lambda n: -n["id"])
def read_keys():
try:
return [l.strip() for l in open(STATE) if l.strip()]
except OSError:
return []
def mark(keys):
old = read_keys()
merged = old + [k for k in keys if k not in old]
os.makedirs(os.path.dirname(STATE), exist_ok=True)
with open(STATE, "w") as f:
f.write("\n".join(merged[-KEEP:]) + "\n")
if __name__ == "__main__":
if len(sys.argv) > 2 and sys.argv[1] == "read":
mark(sys.argv[2:])
elif len(sys.argv) > 1 and sys.argv[1] == "readall":
mark([n["key"] for n in all_notifs()])
else:
done = set(read_keys())
print(json.dumps([n for n in all_notifs() if n["key"] not in done]))