Skip to content

Commit a910b5d

Browse files
committed
Give reminders an indicator and a full QS flow
1 parent 60fbb2a commit a910b5d

12 files changed

Lines changed: 364 additions & 71 deletions

File tree

‎bin/omarchy-notification-send‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# omarchy:summary=Send an Omarchy desktop notification
44
# omarchy:args=[-g <glyph>] [-u <low|normal|critical>] <headline> [description] [notify-send options]
5-
# omarchy:examples=omarchy notification send "Reminder" "5 minutes are up" -g 󰔛 -u critical
5+
# omarchy:examples=omarchy notification send "Reminder" "5 minutes are up" -g 󰢌
66

77
set -euo pipefail
88

‎bin/omarchy-reminder‎

Lines changed: 99 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

33
# omarchy:summary=Set and show lightweight desktop notification reminders
4-
# omarchy:args=<minutes> [message] | show | clear
5-
# omarchy:examples=omarchy reminder 5 | omarchy reminder 30 "Check the oven" | omarchy reminder show | omarchy reminder clear
4+
# omarchy:args=[-i|--interactive] | <minutes> [message] | show [-j|--json] | clear
5+
# omarchy:examples=omarchy reminder -i | omarchy reminder 5 | omarchy reminder 30 "Check the oven" | omarchy reminder show | omarchy reminder show --json | omarchy reminder clear
66

77
set -euo pipefail
88

@@ -20,42 +20,38 @@ format_remaining() {
2020
fi
2121
}
2222

23-
parse_systemd_timespan() {
24-
local timespan="$1"
25-
local total=0
26-
local value unit whole
23+
active_reminder_timers() {
24+
local now=${1:-$(date +%s)}
25+
local timer next
2726

28-
while read -r value unit; do
29-
whole=${value%.*}
27+
while IFS=$'\t' read -r timer next; do
28+
[[ -z $timer || -z $next ]] && continue
29+
30+
next=$((next / 1000000))
31+
((next <= now)) && continue
3032

31-
case $unit in
32-
d) total=$((total + whole * 86400)) ;;
33-
h) total=$((total + whole * 3600)) ;;
34-
min) total=$((total + whole * 60)) ;;
35-
s) total=$((total + whole)) ;;
36-
ms | us) ;;
37-
esac
38-
done < <(grep -oE '[0-9]+([.][0-9]+)?(d|h|min|s|ms|us)' <<<"$timespan" | sed -E 's/^([0-9.]+)([a-z]+)$/\1 \2/')
33+
printf "%s\t%s\n" "$timer" "$next"
34+
done < <(systemctl --user list-timers --all --output=json "omarchy-reminder-*.timer" 2>/dev/null | jq -r '.[] | [.unit, .next] | @tsv')
35+
}
3936

40-
echo "$total"
37+
refresh_indicator() {
38+
omarchy-shell -q omarchy.indicators refresh >/dev/null 2>&1 || true
39+
}
40+
41+
open_interactive() {
42+
omarchy-shell shell summon omarchy.reminders "{}"
4143
}
4244

4345
show_reminders() {
44-
local timer next remaining body=""
46+
local timer next remaining reminder reminder_minutes body=""
4547
local reminder_dir="${XDG_RUNTIME_DIR:-/tmp}/omarchy-reminders"
4648
local reminder_message=""
4749
local now=$(date +%s)
4850

4951
while IFS=$'\t' read -r timer next; do
50-
[[ -z $timer || -z $next ]] && continue
51-
52-
next=$((next / 1000000))
53-
((next <= now)) && continue
54-
5552
remaining=$((next - now))
5653
reminder=${timer%.timer}
5754
reminder=${reminder#omarchy-reminder-}
58-
set_at=${reminder##*-}
5955
reminder_minutes=${reminder%%m-*}
6056
reminder_message=""
6157
[[ -f $reminder_dir/${timer%.timer}.message ]] && reminder_message=$(<"$reminder_dir/${timer%.timer}.message")
@@ -65,13 +61,60 @@ show_reminders() {
6561
else
6662
body+="${reminder_minutes}-min reminder in $(format_remaining $remaining) ($(date -d "@$next" +%-H:%M))"$'\n'
6763
fi
68-
done < <(systemctl --user list-timers --all --output=json "omarchy-reminder-*.timer" 2>/dev/null | jq -r '.[] | [.unit, .next] | @tsv')
64+
done < <(active_reminder_timers "$now")
6965

7066
if [[ -z $body ]]; then
71-
omarchy-notification-send -g 󰔛 "Upcoming reminders" "No outstanding reminders"
67+
omarchy-notification-send -g 󰢌 "Upcoming reminders" "No outstanding reminders"
7268
else
73-
omarchy-notification-send -g 󰔛 "Upcoming reminders" "${body%$'\n'}"
69+
omarchy-notification-send -g 󰢌 "Upcoming reminders" "${body%$'\n'}"
70+
fi
71+
}
72+
73+
show_json() {
74+
local timer next remaining reminder reminder_minutes unit reminder_message label item_json reminders_json="[]"
75+
local reminder_dir="${XDG_RUNTIME_DIR:-/tmp}/omarchy-reminders"
76+
local now=$(date +%s)
77+
local count=0
78+
local tooltip="Set Reminder"
79+
80+
while IFS=$'\t' read -r timer next; do
81+
count=$((count + 1))
82+
83+
unit=${timer%.timer}
84+
reminder=${unit#omarchy-reminder-}
85+
reminder_minutes=${reminder%%m-*}
86+
[[ ! $reminder_minutes =~ ^[0-9]+$ ]] && reminder_minutes=0
87+
remaining=$((next - now))
88+
reminder_message=""
89+
[[ -f $reminder_dir/$unit.message ]] && reminder_message=$(<"$reminder_dir/$unit.message")
90+
91+
if [[ -n $reminder_message ]]; then
92+
label=$reminder_message
93+
else
94+
label="${reminder_minutes}-min reminder"
95+
fi
96+
97+
item_json=$(jq -cn \
98+
--arg unit "$unit" \
99+
--arg timer "$timer" \
100+
--arg label "$label" \
101+
--arg message "$reminder_message" \
102+
--arg remaining "$(format_remaining "$remaining")" \
103+
--arg atTime "$(date -d "@$next" +%-H:%M)" \
104+
--argjson minutes "$reminder_minutes" \
105+
--argjson at "$next" \
106+
--argjson remainingSeconds "$remaining" \
107+
'{unit:$unit,timer:$timer,minutes:$minutes,message:$message,label:$label,remaining:$remaining,remainingSeconds:$remainingSeconds,at:$at,atTime:$atTime}')
108+
reminders_json=$(jq -cn --argjson reminders "$reminders_json" --argjson item "$item_json" '$reminders + [$item]')
109+
done < <(active_reminder_timers "$now")
110+
111+
if ((count == 1)); then
112+
tooltip="1 reminder"
113+
elif ((count > 1)); then
114+
tooltip="$count reminders"
74115
fi
116+
117+
jq -cn --argjson count "$count" --arg tooltip "$tooltip" --argjson reminders "$reminders_json" '{count:$count,active:($count > 0),tooltip:$tooltip,reminders:$reminders}'
75118
}
76119

77120
clear_reminders() {
@@ -85,12 +128,35 @@ clear_reminders() {
85128
fi
86129

87130
rm -f "$reminder_dir"/omarchy-reminder-*.message 2>/dev/null || true
88-
omarchy-notification-send -g 󰔛 "All reminders have been cleared"
131+
refresh_indicator
132+
omarchy-notification-send -g 󰢌 "All reminders have been cleared"
133+
}
134+
135+
usage() {
136+
echo "Usage: omarchy-reminder [-i|--interactive]"
137+
echo " omarchy-reminder <minutes> [message]"
138+
echo " omarchy-reminder show [-j|--json]"
139+
echo " omarchy-reminder clear"
89140
}
90141

91142
case ${1:-} in
143+
-i | --interactive)
144+
open_interactive
145+
exit 0
146+
;;
92147
show | list)
93-
show_reminders
148+
case ${2:-} in
149+
-j | --json)
150+
show_json
151+
;;
152+
"")
153+
show_reminders
154+
;;
155+
*)
156+
usage
157+
exit 1
158+
;;
159+
esac
94160
exit 0
95161
;;
96162
clear)
@@ -105,9 +171,7 @@ message="$*"
105171
custom_message="$message"
106172

107173
if [[ -z $minutes ]] || [[ ! $minutes =~ ^[0-9]+$ ]] || ((minutes == 0)); then
108-
echo "Usage: omarchy-reminder <minutes> [message]"
109-
echo " omarchy-reminder show"
110-
echo " omarchy-reminder clear"
174+
usage
111175
exit 1
112176
fi
113177

@@ -131,6 +195,7 @@ if [[ -n $custom_message ]]; then
131195
fi
132196

133197
systemd-run --user --quiet --collect --on-active="${minutes}m" --unit="$unit" \
134-
bash -c 'omarchy-notification-send -g 󰔛 "Reminder" "$1" -u critical; rm -f "$2"' bash "$message" "$message_file"
198+
bash -c 'omarchy-notification-send -g 󰢌 "Reminder" "$1"; rm -f "$2"; omarchy-shell -q omarchy.indicators refresh >/dev/null 2>&1 || true' bash "$message" "$message_file"
135199

136-
omarchy-notification-send -g 󰔛 "$confirmation_title" "$confirmation"
200+
refresh_indicator
201+
omarchy-notification-send -g 󰢌 "$confirmation_title" "$confirmation"

‎bin/omarchy-reminder-set-interactive‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎default/omarchy/omarchy-menu.jsonc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"learn.bash": {"icon":"󱆃","label":"Bash","keywords":"shell cheatsheet","action":"omarchy-launch-webapp 'https://devhints.io/bash'"},
4444

4545
// Trigger
46-
"trigger.reminder": {"icon":"󰔛","label":"Reminder","aliases":["reminder"],"keywords":"timer notification remind"},
46+
"trigger.reminder": {"icon":"󰢌","label":"Reminder","aliases":["reminder"],"keywords":"timer notification remind"},
4747
"trigger.capture": {"icon":"","label":"Capture","aliases":["capture","screenshot","screenrecord","screen-record","screenrecording"],"keywords":"color text extraction"},
4848
"trigger.capture.screenshot": {"icon":"","label":"Screenshot","keywords":"picture","action":"omarchy-capture-screenshot"},
4949
"trigger.capture.screenrecord.stop": {"icon":"","label":"Stop Screenrecording","keywords":"recording video","when":"pgrep -f '^gpu-screen-recorder' >/dev/null","action":"omarchy-capture-screenrecording --stop-recording"},
@@ -67,9 +67,9 @@
6767
"trigger.hardware.touchpad-haptics.mid": {"icon":"󰌌","label":"mid","keywords":"medium","when":"omarchy-hw-dell-xps-haptic-touchpad >/dev/null && omarchy-cmd-present dell-xps-touchpad-haptics","checked":"[[ \"$(dell-xps-touchpad-haptics get)\" == \"mid\" ]]","action":"dell-xps-touchpad-haptics set mid"},
6868
"trigger.hardware.touchpad-haptics.high": {"icon":"󰌌","label":"high","when":"omarchy-hw-dell-xps-haptic-touchpad >/dev/null && omarchy-cmd-present dell-xps-touchpad-haptics","checked":"[[ \"$(dell-xps-touchpad-haptics get)\" == \"high\" ]]","action":"dell-xps-touchpad-haptics set high"},
6969
"trigger.hardware.touchscreen": {"icon":"󰆽","label":"Touchscreen","keywords":"tablet","when":"omarchy-hw-touchscreen >/dev/null","action":"omarchy-toggle-touchscreen"},
70-
"trigger.reminder.set": {"icon":"󰔛","label":"Set one","aliases":["reminder-set","remind"],"keywords":"timer","action":"omarchy-reminder-set-interactive"},
71-
"trigger.reminder.show": {"icon":"󰔛","label":"Show all","keywords":"list","action":"omarchy-reminder show"},
72-
"trigger.reminder.clear": {"icon":"󰔛","label":"Clear all","keywords":"delete","action":"omarchy-reminder clear"},
70+
"trigger.reminder.set": {"icon":"󰢌","label":"Set one","aliases":["reminder-set","remind"],"keywords":"timer","action":"omarchy-reminder -i"},
71+
"trigger.reminder.show": {"icon":"󰢌","label":"Show all","keywords":"list","action":"omarchy-reminder show"},
72+
"trigger.reminder.clear": {"icon":"󰢌","label":"Clear all","keywords":"delete","action":"omarchy-reminder clear"},
7373
"trigger.share.clipboard": {"icon":"","label":"Clipboard","action":"omarchy-menu-share clipboard"},
7474
"trigger.share.file": {"icon":"","label":"File","action":"xdg-terminal-exec --app-id=org.omarchy.terminal bash -c 'omarchy-menu-share file'"},
7575
"trigger.share.folder": {"icon":"","label":"Folder","keywords":"directory","action":"xdg-terminal-exec --app-id=org.omarchy.terminal bash -c 'omarchy-menu-share folder'"},

‎shell/plugins/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ User-installed plugins live alongside these conceptually but on disk under
1717
| Image picker | `omarchy.image-picker` | `overlay` | `image-picker/ImagePicker.qml` |
1818
| Emojis | `omarchy.emojis` | `overlay` | `emojis/Emojis.qml` |
1919
| Clipboard mgr | `omarchy.clipboard` | `overlay` | `clipboard/Clipboard.qml` |
20+
| Reminders | `omarchy.reminders` | `overlay` | `reminders/ReminderFlow.qml` |
2021
| Omarchy menu | `omarchy.menu` | `menu`, `bar-widget` | `menu/Menu.qml`, `menu/BarWidget.qml` |
2122
| Notifications | `omarchy.notifications` | `service`, `bar-widget` | `notifications/Service.qml`, `notifications/BarWidget.qml` |
2223
| Media | `omarchy.media` | `service`, `bar-widget` | `services/media/Service.qml`, `services/media/BarWidget.qml` |

‎shell/plugins/bar/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Example `shell.json` (bar subtree only shown):
7272
| `omarchy.bluetooth` | Bluetooth icon + popup with device list, connect/disconnect, battery | left = popup · right = toggle radio · middle = bluetoothctl TUI |
7373
| `omarchy.monitor` | Brightness and laptop display controls | left = popup |
7474

75-
The `omarchy.indicators` widget loads individual bar indicators from `indicators/`. Omit `items` (or set it to an empty array) to show all indicators in the default order, or set `items` to a subset such as `["Dnd", "NightLight"]`. Set `alwaysShow` to `true` to keep inactive indicators visible instead of revealing them only on hover. Multiple `omarchy.indicators` instances are allowed, so different sections can show different subsets.
75+
The `omarchy.indicators` widget loads individual bar indicators from `indicators/`. Omit `items` (or set it to an empty array) to show all indicators in the default order, or set `items` to a subset such as `["Dnd", "Reminder", "NightLight"]`. Set `alwaysShow` to `true` to keep inactive indicators visible instead of revealing them only on hover. Multiple `omarchy.indicators` instances are allowed, so different sections can show different subsets.
7676

7777
## Orientation
7878

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import QtQuick
2+
import Quickshell
3+
import Quickshell.Io
4+
import qs.Ui
5+
6+
BarIndicator {
7+
id: root
8+
9+
property int reminderCount: 0
10+
property string tooltip: ""
11+
12+
active: reminderCount > 0
13+
activeText: "󰢌"
14+
inactiveText: "󰢌"
15+
activeTooltipText: tooltip
16+
inactiveTooltipText: tooltip
17+
18+
function refresh() {
19+
if (!jsonProc.running) jsonProc.running = true
20+
}
21+
22+
function openReminderFlow() {
23+
Quickshell.execDetached(["omarchy-reminder", "-i"])
24+
}
25+
26+
function update(raw) {
27+
var data = extractData(raw)
28+
reminderCount = Number(data.count || 0)
29+
tooltip = String(data.tooltip || "")
30+
}
31+
32+
Component.onCompleted: refresh()
33+
34+
Connections {
35+
target: root.indicatorHost
36+
ignoreUnknownSignals: true
37+
function onRefreshRequested() { root.refresh() }
38+
}
39+
40+
Process {
41+
id: jsonProc
42+
command: ["omarchy-reminder", "show", "--json"]
43+
stdout: StdioCollector {
44+
waitForEnd: true
45+
onStreamFinished: root.update(text)
46+
}
47+
onExited: function(exitCode) {
48+
if (exitCode !== 0) {
49+
root.reminderCount = 0
50+
root.tooltip = ""
51+
}
52+
}
53+
}
54+
55+
onPressed: function() {
56+
if (root.reminderCount > 0) Quickshell.execDetached(["omarchy-reminder", "show"])
57+
else root.openReminderFlow()
58+
}
59+
}

‎shell/plugins/bar/widgets/Indicators.manifest.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
"label": "Do not disturb",
3232
"description": "Notification silencing"
3333
},
34+
{
35+
"value": "Reminder",
36+
"label": "Reminder",
37+
"description": "Queued reminder status"
38+
},
3439
{
3540
"value": "NightLight",
3641
"label": "Night light",

‎shell/plugins/bar/widgets/Indicators.qml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BarWidget {
99
moduleName: "omarchy.indicators"
1010

1111
readonly property int indicatorSlotExtent: Style.space(22)
12-
readonly property var defaultIndicatorEntries: [ "Dnd", "NightLight", "StayAwake", "ScreenRecording", "Dictation" ]
12+
readonly property var defaultIndicatorEntries: [ "Dnd", "Reminder", "NightLight", "StayAwake", "ScreenRecording", "Dictation" ]
1313
readonly property int inactiveSlotExtent: indicatorEntries.length * indicatorSlotExtent
1414
readonly property var indicatorEntries: indicatorEntriesFromSettings(settings)
1515
property var activeIndicatorIds: []

‎shell/plugins/menu/Menu.qml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ Item {
116116
resultProc.running = true
117117
}
118118

119+
function runAction(action) {
120+
var command = String(action || "")
121+
if (!command) return
122+
123+
Quickshell.execDetached(["bash", "-lc", command])
124+
}
125+
119126
function rowHeightForDetail(detail) {
120127
return root.filterText && detail ? root.detailRowHeight : root.baseRowHeight
121128
}
@@ -733,10 +740,11 @@ Item {
733740

734741
function applySelected(id, action) {
735742
if (!id) { cancel(); return }
743+
736744
applySerial = requestSerial
737745
opened = false
738746
filterText = ""
739-
if (action) Quickshell.execDetached(["bash", "-lc", action])
747+
root.runAction(action)
740748
}
741749

742750
function cancel() {
@@ -815,7 +823,7 @@ Item {
815823
// instead of opening an action with no children.
816824
if (entry && entry.kind === "action" && entry.action) {
817825
root.cancel()
818-
Quickshell.execDetached(["bash", "-lc", entry.action])
826+
root.runAction(entry.action)
819827
return "ok"
820828
}
821829
// If it's a link (a redirect to another menu), follow the link.

0 commit comments

Comments
 (0)