nuscripts/plugins/plugin_desktop_notification.nu

33 lines
804 B
Plaintext
Raw Normal View History

2024-01-13 10:50:06 +00:00
# https://github.com/FMotalleb/nu_plugin_desktop_notifications
cargo install nu_plugin_desktop_notifications
register ~/.cargo/bin/nu_plugin_desktop_notifications
notify -t "test notification body" --summary "test title"
# OTHER IMPLEMENTATION
def "notify_on_done" [
task: closure
] {
let start = date now
let result = do $task
let end = date now
let total = $end - $start | format duration sec
let body = $"given task finished in ($total)"
notify "task is done" $body
return $result
}
def notify [title message] {
# ^osascript -e 'display notification "' + $message + '" with title "' + $title + '"'
let msg = 'display notification "' + $message + '" with title "' + $title + '"'
$msg
^osascript -e $msg
}
notify_on_done { port scan 8.8.8.8 53 }