Skip to content

Instantly share code, notes, and snippets.

@dbalabka
Last active July 16, 2024 17:04
Show Gist options
  • Save dbalabka/20907893ba33f9ceebff3aaa8182f9c8 to your computer and use it in GitHub Desktop.
Save dbalabka/20907893ba33f9ceebff3aaa8182f9c8 to your computer and use it in GitHub Desktop.
Send notification from Windows WSL console similar to original Linux notify-send command πŸŽΆπŸ””
  1. Create a file in C:\bin\toast.ps1 from source https://gist.github.com/dend/5ae8a70678e3a35d02ecd39c12f99110:
    curl https://gist.githubusercontent.com/dend/5ae8a70678e3a35d02ecd39c12f99110/raw -o /mnt/c/bin/toast.ps1
  2. Create ~/.local/bin/notify-send from the following source:
    powershell.exe "& { . C:\\bin\\toast.ps1; Show-Notification -ToastTitle \"$1\" -ToastText \"$2\" }"
    like this:
    echo 'powershell.exe "& { . C:\\bin\\toast.ps1; Show-Notification -ToastTitle \"$1\" -ToastText \"$2\" }"' > ~/.local/bin/notify-send
  3. Add executable permission on script:
    chmod +x ~/.local/bin/notify-send

Usage example:

notify-send "Hello world!!!"
notify-send "Hello" "world!!!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment