From fd300003800fdc959e0764fafffa3ed95bd10ef3 Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Wed, 20 Mar 2024 01:30:27 +0100 Subject: [PATCH] Added urgency functionality when events are present --- status-notification.nu | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/status-notification.nu b/status-notification.nu index 3116052..8d86075 100755 --- a/status-notification.nu +++ b/status-notification.nu @@ -38,8 +38,11 @@ def get_batteries [] { } # Documentation for notify -def notify [message: string] { - notify-send "Status" $message +def notify [message: string, urgent: bool] { + match $urgent { + true => (notify-send "Status" $message -u critical) + false => (notify-send "Status" $message) + } } def calendar [hours: int] { @@ -52,15 +55,14 @@ def calendar [hours: int] { } # Documentation for construct_string -def construct_string [] { - [ $dateString - $discordianDate - (calendar 2) - (get_batteries) - ] | str join "\n\n" -} - -# Documentation for main def main [] { - notify (construct_string) + let calendar_status = calendar 2 + let urgent = not ($calendar_status | str starts-with "No events") + notify ( + [ $dateString + $discordianDate + $calendar_status + (get_batteries) + ] | str join "\n\n" + ) $urgent }