トースト通知というの?
いくつかツールを試してみたメモ。
Growl For Windows
Windows 10 の通知ではなく独自の通知が実装されています。
Chocolatey でサクッとインストールできるかと思いきや、インストールに失敗します。
こっちからインストーラーをダウンロードすれば OK です。
Growl 自体はわかりませんが Growl For Windows はもメンテされていないようです。
notifu
コマンドラインで使うことが想定されたものだと思いますが /v や /? でダイアログが表示される。。。
toaster
リポジトリにまんまバイナリが入っているのでダウンロードすれば使えます(exe だけじゃなく dll も必要)
Welcome to toast.
Provide toast with a message and display it-
via the graphical notification system.
-Nels
---- Usage ----
toast <string>|[-t <string>][-m <string>][-p <string>]
---- Args ----
<string> | Toast <string>, no add. args will be read.
[-t] <title string> | Displayed on the first line of the toast.
[-m] <message string> | Displayed on the remaining lines, wrapped.
[-p] <image URI> | Display toast with an image
[-w] | Wait for toast to expire or activate.
? | Print these intructions. Same as no args.
Exit Status : Exit Code
Failed : -1
Success : 0
Hidden : 1
Dismissed : 2
Timeout : 3
---- Image Notes ----
Images must be .png with:
maximum dimensions of 1024x1024
size <= 200kb
These limitations are due to the Toast notification system.
This should go without saying, but windows style paths are required.
SnoreToast
下記からバイナリがダウンロードできます。
Welcome to SnoreToast 0.5.2.
A command line application which is capable of creating Windows Toast notifications.
---- Usage ----
SnoreToast [Options]
---- Options ----
[-t] <title string> | Displayed on the first line of the toast.
[-m] <message string> | Displayed on the remaining lines, wrapped.
[-p] <image URI> | Display toast with an image, local files only.
[-w] | Wait for toast to expire or activate.
[-id] <id> | sets the id for a notification to be able to close it later.
[-s] <sound URI> | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx.
[-silent] | Don't play a sound file when showing the notifications.
[-appID] <App.ID> | Don't create a shortcut but use the provided app id.
-close <id> | Closes a currently displayed notification, in order to be able to close a notification the parameter -w must be used to create the notification.
-install <path> <application> <appID>| Creates a shortcut <path> in the start menu which point to the executable <application>, appID used for the notifications.
-v | Print the version and copying information.
-h | Print these instructions. Same as no args.
Exit Status : Exit Code
Failed : -1
Success : 0
Hidden : 1
Dismissed : 2
Timeout : 3
---- Image Notes ----
Images must be .png with:
maximum dimensions of 1024x1024
size <= 200kb
These limitations are due to the Toast notification system.
This should go without saying, but windows style paths are required.
Powershell
Powershell だけでもできるようです。
さいごに
SnoreToast がバイナリポンで動くのと使い勝手が良さそうだったので、とりあえず下記のようなスクリプトをかまして使ってみます。
#!/bin/bash if [[ $# -eq 0 ]]; then message="$(cat -)" else message="$*" fi /mnt/c/path/to/SnoreToast/SnoreToast.exe -close SnoreToast >/dev/null /mnt/c/path/to/SnoreToast/SnoreToast.exe -t SnoreToast -m "$message" -silent -w -id SnoreToast >/dev/null &
連続で表示したとき、普通にやると最初の通知を非表示にするまで次の通知が表示されないのですが、↑のように -id で ID を付ける& -w で通知が消えるまで待機しつつ、次の通知を表示する前に -close で ID を指定すれば、前の通知を非表示&次の通知をすぐ表示、とできます。
次のように使います。
# 引数でメッセージを指定 toast this is toast message # 標準入力からメッセージを読む ls | toast
標準入力から読めるようにしてみたものの、サイズ的に先頭の4行しか表示できないもよう。