-1

I´ve got a question regarding zenity.

What I want to do is display my total data usage of my web-stick for the current day in a message box. I found a solution using notify-send:

set name ( vnstat --iface ppp0 -s | sed '1,6d' | head -n1 | awk '{ print  $8 }' );and notify-send -t 5000 "Info" "bisheriger Verbrauch: $name MB"

Another method, which allows me to display an icon in addition to the data, is the usage of zenity:

set name ( vnstat --iface ppp0 -s | sed '1,6d' | head -n1 | awk '{ print  $8 }' );and zenity --notification --window-icon=/home/rosika/Schreibtisch/work/Downloads/status_on.png --text="bisheriger Verbrauch für ppp0: $name MB"

I use fish as standard shell. Therefore the slightly different syntax.

zenity --notification displays an additional button whis says: "Do default Action". When clicking on it the message box vanishes instantly. Otherwiswe it vanishes after 10 seconds.

My question is: Does clicking on "Do default Action" cause anything other than closing the message box? I don´t want my system to run into any kind of trouble after all.

Rosika
  • 575
  • 1
    Which desktop environment are you using that you get a notification with a button on it? Which version of Ubuntu? – muru Jul 04 '18 at 13:54
  • Please create an MCVE, because I cannot reproduce this on my machine. – wjandrea Jul 04 '18 at 13:57
  • @ wjandrea: In order to produce the respective button just type zenity --notification --text "Hamster" in the terminal. This is just an example but it produces the button "Do Default Action". – Rosika Jul 04 '18 at 15:46
  • @ muru: Hi, sorry I forgot to mention my system specs. I am using Lubuntu 16.04.4 LTS, 64bit. So I´ve got the LXDE-environment. – Rosika Jul 04 '18 at 15:49
  • I don't see that button, just "Cancel" and "OK". I'm using Ubuntu 14.04, so maybe this is LXDE-specific? – wjandrea Jul 04 '18 at 16:06
  • 1
    @wjandrea: O.K., thanks for your effort. With me there´s neither "Cancel" nor "OK", just "Do Default Action" and the respective text of course. Like you said it´s probably LXDE-specific. Tnx a lot anyway. – Rosika Jul 04 '18 at 16:11
  • @ wjandrea: Tnx. Yeah notify-send works alright (see my post). I was just interested in learning about that zenity-button. Alas the link mentioned (https://help.gnome.org/users/zenity/stable/notification.html.en) won´t grant me access to the page. – Rosika Jul 06 '18 at 11:17

1 Answers1

2

My question is: Does clicking on "Do default Action" cause anything other than closing the message box? I don´t want my system to run into any kind of trouble after all.

Here's what it does, from the zenity src/notification.c file:

on_notification_default_action (NotifyNotification *n,
                                const char         *action,
                                void               *user_data)
{
  ZenityData *zen_data;

  zen_data = (ZenityData *)user_data;
  notify_notification_close (n, NULL);

  zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);

  gtk_main_quit ();
}

So no, clicking the button appears to just close the notification and exit with ZENITY_OK status.

Whether the button shows at all seems to be distribution-dependent - I see it in the Budgie (Solus) desktop but others apparently don't.

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • Tnx for the explanation. That´s reassuring. I tried to look it up myself but couldn´t find src/notification.c. Perhaps the respective config-file has another name in Lubuntu 16.04. Like you said it seems to be distro-dependent. Greetings. – Rosika Jul 06 '18 at 11:12