Skip to content

A nushell plugin to send notification to desktop using notify-rust

License

Notifications You must be signed in to change notification settings

FMotalleb/nu_plugin_desktop_notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔔 nu_plugin_desktop_notifications

A Nushell plugin for sending desktop notifications using notify-rust.


✨ Features

  • Send notifications with custom title, body, icon, and app name.
  • Supports macOS, Windows, and Linux (XDG Desktop).
  • Configurable timeout (for macOS and XDG desktops).
  • Error handling with optional crash reporting.

📌 Usage

Sending a Notification

notify -t "Test notification body" --summary "Test title"

Flags

  • -h, --help → Show help message.
  • -s, --summary <string> → Title of the notification.
  • -t, --body <string> → Body message of the notification.
  • --subtitle <string> → Subtitle (macOS & Windows only).
  • -a, --app-name <string> → App name for the notification.
  • -i, --icon <filepath> → Path to an icon for the notification.
  • --timeout <duration> → Duration before the notification disappears (macOS & XDG Desktop only). Defaults to system settings.
  • --crash-on-error <filepath> → Return an error if the notification fails.

🎯 Example: Notify on Task Completion

Send a notification after a task completes, displaying the elapsed time:

image

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 = $"Task completed in ($total)"
    notify -s "Task Finished" -t $body
    return $result
}

notify on done { port scan 8.8.8.8 53 }

🔧 Installation

🚀 Recommended: Using nupm

git clone https://github.com/FMotalleb/nu_plugin_desktop_notifications.git  
nupm install --path nu_plugin_desktop_notifications -f  

🛠️ Manual Compilation

git clone https://github.com/FMotalleb/nu_plugin_desktop_notifications.git  
cd nu_plugin_desktop_notifications  
cargo build -r  
register target/release/nu_plugin_desktop_notifications  

📦 Install via Cargo (using git)

cargo install --git https://github.com/FMotalleb/nu_plugin_desktop_notifications.git  
register ~/.cargo/bin/nu_plugin_desktop_notifications  

📦 Install via Cargo (crates.io) Not Recommended

Since I live in Iran and crates.io often restricts package updates, the version there might be outdated.

cargo install nu_plugin_desktop_notifications  
register ~/.cargo/bin/nu_plugin_desktop_notifications