Page 1 of 1

Can shell script pop up system notification?

Posted: Tue May 24, 2022 10:56 am
by miltonx

Can shell script pop up notification like this blue box in puppy linux? (This blue box appears when a video is opened in slacko7_64.)
Or, if not, is shell script able to produce any other kind of popup notification (when the script is running in background)?


Re: Can shell script pop up system notification?

Posted: Tue May 24, 2022 1:13 pm
by rockedge

I use gxmessage for notifications from a script. Something like

Code: Select all

gxmessage This is a message -font 16 -center -timeout 4
Screenshot_2022-05-24_09-12-32.png
Screenshot_2022-05-24_09-12-32.png (157.24 KiB) Viewed 1037 times

For more of a "technical retro" look try using :

Code: Select all

xmessage This is a message -center -timeout 6
Screenshot_2022-05-24_09-16-34.png
Screenshot_2022-05-24_09-16-34.png (213.71 KiB) Viewed 1036 times

For another way to generate notifications perhaps using dunst might work, which would be a box like the example in the first post


Re: Can shell script pop up system notification?

Posted: Tue May 24, 2022 1:47 pm
by HerrBert

The blue box shown can be created with notify-send "This is a message"
Like rockedge, i often use xmessage and sometimes yaf-splash


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 12:45 am
by miltonx

Nice to have these different options! Thanks!

xmessage/gxmessage works more like a traditional dialog box. By default, it needs to be closed. But there appears to be many other options available.

notify-send works just like the one in the screenshot I attached. It seems to be widely used for system notification in Linux in general, with facilities to format its text.

yaf-splash looks more like, well, a splash. Very interesting to have!


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 2:40 am
by miltonx

I noticed that notify-send messages can be closed by pressing ctrl+space. I checked jwm settings and did not find this shortcut. Is it a built-in feature of notify-send? Can it be modified?


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 4:27 am
by user1234

Puppy uses dunst notification daemon. When you use notify-send it automatically calls dunst.

To modify any of its behaviour, you can use the graphical dunst settings editor of dunst, or else modify its configuration file manually.

I see that keyboard bindings can't be changed from the graphical dunst settings editor provided by puppy-linux. So for changing them, you'd have to modify the dunst configuration file manually.

In puppy, dunst config file is located at /root/.config/dunst/dunstrc.

I found dunst documentation for editing configurations here. You can go to the Keyboard shortcuts (X11 only) heading in the webpage.


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 6:27 am
by MochiMoppel
miltonx wrote: Wed May 25, 2022 12:45 am

notify-send works just like the one in the screenshot I attached. It seems to be widely used for system notification in Linux in general,

At least in older Puppies it may not work, e.g. doesn't work in Slacko 5.6 and isn't even installed in Lupu 5.2.8.

When gxmessage is configured without buttons it may look almost like notify-send. Close with ESC key or wait for the optional time-out:

Code: Select all

gxmessage -bo -c -tim 5 -fn 'bold 10' -bg '#285577' -fg '#FFF' -bu '' $'\n\n  A buttonless gxmessage'

Related topic:
How to pop-up boxes and notifications from scripts?


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 7:51 am
by HerrBert

yaf-splash can be customized by command...


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 9:34 am
by greengeek
MochiMoppel wrote: Wed May 25, 2022 6:27 am

When gxmessage is configured without buttons it may look almost like notify-send. Close with ESC key or wait for the optional time-out:

Code: Select all

gxmessage -bo -c -tim 5 -fn 'bold 10' -bg '#285577' -fg '#FFF' -bu '' $'\n\n  A buttonless gxmessage'

Thanks. Very handy


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 9:39 am
by greengeek
HerrBert wrote: Wed May 25, 2022 7:51 am

yaf-splash can be customized by command...

Code: Select all

yaf-splash -timeout 8 -bg_gradient false -bg steelblue4 -fg white -margin 16 -fontsize 11 -align left -placement bottom-right -text $'yaf-splash message looking\nlike a notification'

Thanks. Archived for later use... cheers!


Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 9:52 am
by miltonx

The ~/.config/dunst/dunstrc works after killing dunst. (It does not need to be manually restarted, as notify-send seems to call it.)

However, trying to configure dunst in terminal failed, with the errors:

Code: Select all

# dunst -key ctrl+space
WARNING: BadAccess (attempt to access private resource denied)
WARNING: BadAccess (attempt to access private resource denied)
WARNING: Unable to grab key 'ctrl+grave'.
CRITICAL: Cannot acquire 'org.freedesktop.Notifications': Name is acquired by 'dunst' with PID '5618'.

Edit:
Well, just after posting this, I realized that configuring dunst in terminal also requires killing it first. This works:

Code: Select all

pkill dunst
dunst -key ctrl+space &

Re: Can shell script pop up system notification?

Posted: Wed May 25, 2022 11:21 am
by mikewalsh

Personally, I make a lot of use of either gxmessage or gtk-dialog/box_splash for notifications.

I have all Puppies set-up - via custom scripting - to create a back-up of the PuppyPin file prior to passing control back to wmpoweroff/wmrestart. As part of this, a gxmessage box pops-up to let me know that file has been copied. Having to manually close it is fine, because the shut-down/re-boot process won't go any further until I do. Keeps me aware of what's happening, and I'm SO used to it, it's just part of my normal shutdown routine by now.

A menu entry under Menu->Desktop allows me to reset things very quickly & easily, along with an auto-restart of 'X', in the now unlikely event that PuppyPin goes AWOL.

(I had a spell, a few years back, when most Puppies seemed to "lose" their PuppyPin file on a regular basis, so I cobbled this stuff together to make sure that never happened again. It's a right PITA having to set your desktop up again at every boot, especially when they're as highly-customized as mine are.

It was around the same time that I realized the PuppyPin file was "dynamic", i.e., it reflected changes immediately, in real-time, as you made them.....so it really DID keep the thing 'up-to-date' on every shutdown. )

-------------------------------

@HerrBert / @MochiMoppel :-

Thanks for the info about yaf-splash & the "buttonless" gxmessage, guys. Nice to have further options!

HerrBert:- Is yaf-splash standard with Puppies, or does it need installing? (EDIT:- Answered my own question. Seems it's a sym-link to gtk-splash.)

Cheers.

Mike. ;)


Re: Can shell script pop up system notification?

Posted: Fri May 27, 2022 1:11 pm
by MochiMoppel
mikewalsh wrote: Wed May 25, 2022 11:21 am

HerrBert:- Is yaf-splash standard with Puppies, or does it need installing? (EDIT:- Answered my own question. Seems it's a sym-link to gtk-splash.)

I'm not @HerrBert ,but let me answer anyway because it's more complicated than you think.

yaf-splash is a tiny 25K binary written by John Morton in 2003 and was included in all Puppies up to 4.xx , usually in the directory /usr/X11R7/bin. Many scripts used it for splash messages.

In 2010 forum member mave posted a little script, named gtkdialog-splash that was supposed to mimick the original yaf-splash, though it still lacked many of the original's options.It remains unclear, why he felt a need to replace yaf-splash but the idea sparked the interest of other members who subsequently added more options.

In the following Golden Age of rock solid Puppies (Lupu, Slacko 5.x etc.) gtkdialog-splash was added to /usr/bin, together with a symlink named - you guessed it - yaf-splash. The original binary was left in /usr/X11R7/bin, probably for nostalgic reasons.

With the advent of woofCE the directory /usr/X11R7 was discarded, together with the yaf-splash binary. The gtkdialog-splash script was replaced by /usr/lib/gtkdialog/box_splash and gtkdialog-splash turned into a mere wrapper script for box_splash. Box_splash claims to be "compatible with yaf-splash" - which it is not.

Fast forward to 2021: yaf-splash is back as a binary in /usr/bin in @BarryK's EasyOS. BK explained the reason in this blog post. I'm not sure why he replaced all references to yaf-splash with references to gtkdialog-splash. IMHO yaf-splash has clear advantages over gtkdialog-splash.

The weak point of gtkdialog-splash, apart from its slowness, is its inability to splash a message "always-on-top" other windows, but this ability is crucial for alert messages. Here is where yaf-splash excels. It pops up on top of fullscreen windows and even keeps on top after a new "layer above" window tries to cover its area. It simply can't be covered by windows or trays.

The real yaf-splash has weak points too. It is Unicode agnostic and the syntax for the -font option can be very tricky but without customizing the font the message tends to look very ugly. It seems to run fine in other 32bit distros (I "borrowed" a copy from my Slacko 5.6 and placed it into Xenial 7.5 and it worked).

Here the usage info. Note the interesting and partly odd options:

Code: Select all

Usage: yaf-splash [ options ]
Where options include:

  -text                         Message to display.
  -timeout                      How long to display the message before
                                exiting. Default is 0, which means forever.
  -clock                        Enable clock display.
  -12                           Display twelve hour time (default).
  -24                           Display twenty-four hour time.
  -seconds                      Display seconds (default).
  -noseconds                    Don't display seconds.
  -countdown <date>             Display a countdown instead of a clock.
                                Run `-countdown foo' to see date syntax.
  -countdownquit                Quit after the countdown has reached
                                zero (default).
  -nocountdownquit              Keep counting after reaching zero.
  -geometry <geometry>          Size and position of window.
  -placement <placement name>   A screen location, one of center, top,
                                bottom, right, left, top-right, top-left,
                                bottom-left, bottom-right. Defaults to center.
                                A specified placement will override -geometry.
  -font <font>                  Name of an X font to use.
  -transparent                  Make the window background be transparent,
                                if possible.
  -nontransparent               Don't (default).
  -mirror                       Flip the text about the y axis. Useful for
                                back projection.
  -nomirror                     Don't (default).
  -fg                           Set the forground text colour (default: black).
  -bg                           Set the background colour (default: white).
  -bd                           Set the border colour (default: black).
  -bw                           Set the border width (default: 2).
  -outline                      Set the text outline width (default: 1).
  -margin                       Set the margin size (default: 0).

I think it's best to regard yaf-splash and gtkdialog-splash as 2 distinctly different tools, each with its own cons and pros.


Re: Can shell script pop up system notification?

Posted: Fri May 27, 2022 1:24 pm
by mikewalsh

@MochiMoppel :-

Thanks for the clarifications & explanations. That's very much appreciated.

I had no idea there were quite so many notification options available to us.....or have been, over the years. As you say, they all appear to have their good & bad points.

I've seen many references to yaf-splash over the years, but never really investigated further; my own needs were always covered by gxmessage and gtkdialog/box_splash.

Cheers. :thumbup:

Mike. ;)