web-dev-qa-db-ja.com

Ubuntuでbashスクリプトからの通知を表示する方法はありますか?

ほとんどのアプリケーションでは、画面の右上隅に表示されるイベントについて適切にフォーマットされた通知を表示できます。私はバックグラウンドで妖精の長い処理をするであろうbashスクリプトを書きようとしています、そしてそれがいつ終わったか本当に知りたいです。 bashスクリプトからそのNice通知をどのように表示できますか?

100
vava

Jauntyで新しい通知システムを使用している場合は、notify-sendコマンドが必要です。

notify-send - a program to send desktop notifications

SYNOPSIS

With notify-send you can sends desktop notifications to the user via
a notification daemon from the command line.  These notifications can be
used to inform the user about an event or display some form of information
without getting in the user's way.

OPTIONS

-u, --urgency=LEVEL
Specifies the urgency level (low, normal, critical).

-t, --expire-time=TIME
    Specifies the timeout in milliseconds at which to expire the notification.
-i, --icon=ICON[,ICON...]
    Specifies an icon filename or stock icon to display.
-c, --category=TYPE[,TYPE...]
    Specifies the notification category.
118
nagul

別の方法を見つけました。 Zenity

echo 'message:hi' | zenity --notification --listen

(これには既にUbuntuにインストールされているという利点もあります。)

28
vava

ウィンドウをポップアップさせるxmessageもあるので、どのX11システムでも動作するはずです。

プロ: 対話的にユーザーにボタンでプロンプトを出すこともできます。

Con: 他のポップアップアラートと同じように、通常フォーカスがあるので、入力中であればメッセージを読む前に消えてしまう可能性があります。

12
NVRAM

KDEユーザーの場合:

$ kdialog --title "Long process completed!" --passivepopup "This popup will disappear in 5 seconds" 5 &
10
kolypto

Yfiton というクロスプラットフォームのソリューションがあります。

$ yfiton -n desktop -Pmessage="Lunch time!" -Pposition=TOP_RIGHT
3
Laurent

10秒後に自動的に閉じるポップアップ通知

notify-send "Hello world"

ソース: https://superuser.com/a/31919/425838

クリックするボタンがあるポップアップウィンドウ:

[ウィンドウがオートフォーカスにならない]

notify-send -t 0 "Hello world"

出典:私自身。注:-tは、0 - how stupid 以外のすべての値で無視されます。 :(


OR
[ウィンドウはオートフォーカスを取得します]

zenity --info --title "Hello" --text "World"

出典: https://askubuntu.com/a/804475/327339


OR

[ウィンドウが秒単位で指定された--timeoutの後に自動的に閉じるため、MY FAVORITE]

zenity --info --title "Hello" --text "World" --timeout=2

出典:私自身がmanページを読んでいる:man zenity


OR
[超醜い]

xmessage 'hello world'

出典: http://www.linux-commands-examples.com/xmessage

3
Gabriel Staples

シェルスクリプトでは、libxosdからosd_catユーティリティを呼び出すこともできます。

2
geek