aboutsummaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/modules/status/SnoozeRow.qml114
-rw-r--r--desktop/modules/status/StatusPage.qml10
2 files changed, 124 insertions, 0 deletions
diff --git a/desktop/modules/status/SnoozeRow.qml b/desktop/modules/status/SnoozeRow.qml
new file mode 100644
index 0000000..046d7cb
--- /dev/null
+++ b/desktop/modules/status/SnoozeRow.qml
@@ -0,0 +1,114 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import Quickshell
+import Quickshell.Io
+import QtQuick
+import QtQuick.Controls
+import "../.."
+
+// A switch plus a minutes field. On snoozes for the typed minutes through
+// notify-snooze.sh; off clears. The last used value is persisted by the
+// script, so the field prefills from it.
+Item {
+ id: row
+
+ // A tick so the switch reflects the snooze ending on its own.
+ property double now: Date.now()
+ Timer {
+ interval: 1000
+ running: true
+ repeat: true
+ onTriggered: row.now = Date.now()
+ }
+
+ readonly property bool active: Notify.snoozeUntil > row.now
+
+ implicitHeight: Math.max(texts.implicitHeight, sw.implicitHeight) + 16
+
+ function apply(on) {
+ if (on) {
+ const n = parseInt(minutes.text, 10);
+ snooze.command = ["notify-snooze.sh", String(isNaN(n) || n < 1 ? 30 : n)];
+ } else {
+ snooze.command = ["notify-snooze.sh", "off"];
+ }
+ snooze.running = false;
+ snooze.running = true;
+ }
+
+ Process { id: snooze }
+
+ FileView {
+ id: lastUsed
+ path: `${Quickshell.env("HOME")}/.local/state/notify-snooze.minutes`
+ printErrors: false
+ onLoaded: minutes.text = text().trim()
+ onLoadFailed: minutes.text = "30"
+ }
+
+ Column {
+ id: texts
+ anchors {
+ left: parent.left
+ right: controls.left
+ rightMargin: 12
+ verticalCenter: parent.verticalCenter
+ }
+ spacing: 2
+
+ Text {
+ text: "Snooze"
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: true }
+ color: Theme.text
+ }
+
+ Text {
+ width: parent.width
+ wrapMode: Text.WordWrap
+ text: row.active ? "All notification balloons are held until snooze ends."
+ : "Hold every notification balloon for a number of minutes."
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ color: Theme.subtext
+ }
+ }
+
+ Row {
+ id: controls
+ anchors { right: parent.right; verticalCenter: parent.verticalCenter }
+ spacing: 8
+
+ TextField {
+ id: minutes
+ width: 48
+ height: 28
+ text: "30"
+ horizontalAlignment: TextInput.AlignHCenter
+ color: Theme.text
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ background: Rectangle {
+ radius: 6
+ color: Qt.alpha(Theme.surface, 0.9)
+ border.width: 1
+ border.color: Qt.alpha(Theme.text, 0.15)
+ }
+ validator: IntValidator { bottom: 1; top: 1440 }
+ }
+
+ Switch {
+ id: sw
+ checked: row.active
+ onToggled: row.apply(!row.active)
+ }
+ }
+
+ onNowChanged: sw.checked = row.active
+}
diff --git a/desktop/modules/status/StatusPage.qml b/desktop/modules/status/StatusPage.qml
index 850cc73..2fbdc9b 100644
--- a/desktop/modules/status/StatusPage.qml
+++ b/desktop/modules/status/StatusPage.qml
@@ -40,4 +40,14 @@ Column {
description: "Do not disturb, no screen lock, breaktimer paused."
value: Status.presentation
}
+
+ Rectangle {
+ width: page.width
+ height: 1
+ color: Qt.alpha(Theme.text, 0.08)
+ }
+
+ SnoozeRow {
+ width: page.width
+ }
}