Page 1 of 1

[howto] code a popup

Posted: 26 Jan 2021, 12:19
by Rava
The howto is in reply #1 and #2. :) aka post #2 and #3 of this thread.

______________

Some weeks ago I found in a thread the code how the popup message is coded in Port, like the NetworkManager Applet "Connection established" one, and I did copy the code and played a bit with it.

But now that I want to incorporate the popup message into a script, silly me neither finds the thread (searched for "popup message remove" - since it was about how to remove the popup message that came on every boot) nor the locally saved code. :wall:

I know some of you know how to code such popup.

howto code a popup?

Posted: 26 Jan 2021, 13:28
by ncmprhnsbl
if you're talking about using a notification (daemon), that most of the 003-DE modules have (eg. xfce4-notifyd) :
at it's simplist:

Code: Select all

notify-send "a message"
for some more options:

Code: Select all

notify-send --help

howto code a popup?

Posted: 26 Jan 2021, 16:21
by Rava
ncmprhnsbl wrote:
26 Jan 2021, 13:28
notify-send "a message"
Indeed, that was it. Thanks.

Without the -t parameter set to 0 or at least 1000 nothing is to be seen, at least on an 8 core machine.

Sadly, not even man notify-send explains what the valid TYPE of

Code: Select all

--category=TYPE
are. Image

I search online for tutorials on notify-send.

Added in 4 minutes 34 seconds:
http://vaskovsky.net/notify-send/linux.html gives some tips. :)

e.g.

Code: Select all

notify-send -i info -t 0 "Encoding" "finished"
or

Code: Select all

notify-send -i info -t 0 "Downloading" "finished"
are both useful when its a long taking encoding or downloading session and even when away for a minute you want to see the notification, therefore -t 0 aka display until user clicks it away. ;)

Though in both cases "finished" might not be "successfully finished" - e.g. server downtime while downloading.

But that can be handled via examining $? of e.g. ffmpeg or wget.

[howto] code a popup

Posted: 29 Jan 2021, 10:26
by Kulle
Hi Rava,
notify-send -i info ....
The option "-i info" creates a icon (letter i on blue circle)
Are other icons possible? Which?
Thanks

[howto] code a popup

Posted: 29 Jan 2021, 11:40
by Rava
Kulle wrote:
29 Jan 2021, 10:26
The option "-i info" creates a icon (letter i on blue circle)
Are other icons possible? Which?
Its in the link I put in above…
Rava wrote:
26 Jan 2021, 16:25
http://vaskovsky.net/notify-send/linux.html gives some tips. :)
:
-i ICON, --icon=ICON: specifies an icon filename or stock icon to display, for example, info, important or error. Default: no icon.
[…]
-a, --app-name=APP_NAME: specifies the application name for the icon.

[howto] code a popup

Posted: 10 Feb 2021, 17:15
by Rava
Rava wrote:
26 Jan 2021, 16:25
But that can be handled via examining $? of e.g. ffmpeg or wget.
like with a one-liner:

Code: Select all

ffmpeg [whatever];if [ $? -eq 0 ];then notify-send -i info -t 0 "Encoding" "successfully finished";else notify-send -i info -t 0 "Encoding" "ended with error";fi
You can test it what it does in case of an error or in case of success like so: (true for success or zero return value, false for error or non zero return value)

Code: Select all

true;if [ $? -eq 0 ];then notify-send -i info -t 0 "Encoding" "successfully finished";else notify-send -i info -t 0 "Encoding" "ended with error";fi
false;if [ $? -eq 0 ];then notify-send -i info -t 0 "Encoding" "successfully finished";else notify-send -i info -t 0 "Encoding" "ended with error";fi