Created
May 13, 2020 19:01
-
-
Save codebymikey/0dd5a59a2b5c98051abf6d892e9d989e to your computer and use it in GitHub Desktop.
(wsl-notify) WSL notify-send shim.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Inspiration: https://codelearn.me/2019/01/13/wsl-windows-toast.html | |
# Shim https://ss64.com/bash/notify-send.html for WSL. | |
# Just add an alias for it: | |
# alias notify-send='wsl-notify' | |
POSITIONAL=() | |
urgency='terminal' | |
expire_time='' | |
icon='' | |
category='' | |
hint='' | |
# No extra options have been implemented. | |
extra_args='' | |
while [[ $# -gt 0 ]]; | |
do | |
case "$1" in | |
--urgency=*|-u=*) | |
urgency="${1#*=}" | |
;; | |
--urgency|-u) | |
urgency="$2"; | |
shift; | |
;; | |
--expire-time=*|-t=*) | |
expire_time="${1#*=}" | |
;; | |
--expire-time|-t) | |
expire_time="$2"; | |
shift; | |
;; | |
--icon=*|-i=*) | |
icon="${1#*=}" | |
;; | |
--icon|-i) | |
icon="$2"; | |
shift 2; | |
;; | |
--category=*|-c=*) | |
category="${1#*=}" | |
;; | |
--category|-c) | |
category="$2"; | |
shift; | |
;; | |
--help|-?) | |
echo 'Help message for wsl-notify'; | |
exit 0; | |
;; | |
--hint=*|-h=*) | |
hint="${1#*=}" | |
;; | |
--hint|-h) | |
hint="$2"; | |
shift; | |
;; | |
*) | |
POSITIONAL+=("$1") | |
;; | |
esac | |
shift | |
done | |
set -- "${POSITIONAL[@]}" # restore unmatched positional parameters | |
messages=$(echo "${POSITIONAL[@]}") | |
powershell.exe "New-BurntToastNotification -Text \"$messages\" $extra_args" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment