[howto] code a popup

Post here if you are a new Porteus member and you're looking for some help.
User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[howto] code a popup

Post#1 by Rava » 26 Jan 2021, 12:19

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.
Cheers!
Yours Rava

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3924
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

howto code a popup?

Post#2 by ncmprhnsbl » 26 Jan 2021, 13:28

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
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

howto code a popup?

Post#3 by Rava » 26 Jan 2021, 16:21

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.
Cheers!
Yours Rava

Kulle
Warlord
Warlord
Posts: 594
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

[howto] code a popup

Post#4 by Kulle » 29 Jan 2021, 10:26

Hi Rava,
notify-send -i info ....
The option "-i info" creates a icon (letter i on blue circle)
Are other icons possible? Which?
Thanks

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[howto] code a popup

Post#5 by Rava » 29 Jan 2021, 11:40

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.
Cheers!
Yours Rava

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

[howto] code a popup

Post#6 by Rava » 10 Feb 2021, 17:15

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
Cheers!
Yours Rava

Post Reply