The officially official Devuan Forum!

You are not logged in.

#51 2019-02-16 00:07:44

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

MiyoLinux wrote:
franko wrote:

Are you sure? If I understand that syntax right, that means every 3:45 h since a computer is started. I believe 3 would mean at 3 am, and */3 means every 3 hours since you start a computer... Am I wrong about it? At least, that's what it seems to work like here on my machine...

I'm gonna have a brain-jerkdown thinking about this. LOL! tongue

According to my cron log, mine is working as I described. For instance, if I turn my computer on at 8:30 am (and using the 45 */3 * * * example), the cron job will do its first run at 9:45 am...despite the computer has only been on an hour and 15 minutes. However, the update-notifier.py script won't run until the computer has been on for 4 hours.

That's how mine is working...never know though...I might've jinxed it. LOLOLOL! tongue

Edited to add...

It's almost time for the cron job to run...I'll reboot and double-check. I'll report back.

Okay...it's working as I described. I'm doing the final testing of the i3 release today, so this cron log is from it.

RED = When the computer is turned on (notice I turned it on after the 6:45 am mark, but it still ran the first cron at 9:45. The second time in RED is when I rebooted to make sure that I knew what I was talking about. LOL! big_smile  Computer on at 6:20 pm, and the cron ran at 6:45 pm.

YELLOW = the cron job for the updater.

Feb 15 06:50:25 localhost cron[1386]: (CRON) INFO (pidfile fd = 3)
Feb 15 06:50:25 localhost cron[1387]: (CRON) STARTUP (fork ok)
Feb 15 06:50:25 localhost cron[1387]: (CRON) INFO (Running @reboot jobs)

Feb 15 06:55:01 localhost CRON[2835]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 07:05:01 localhost CRON[3939]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 07:15:01 localhost CRON[5020]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 07:17:01 localhost CRON[5231]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 07:25:01 localhost CRON[6083]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 07:30:01 localhost CRON[6638]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Feb 15 07:35:01 localhost CRON[7189]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 07:45:01 localhost CRON[8233]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 07:55:01 localhost CRON[9322]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 08:05:01 localhost CRON[10344]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 08:15:01 localhost CRON[11372]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 08:17:01 localhost CRON[11583]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 08:25:01 localhost CRON[12388]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 08:35:01 localhost CRON[13416]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 08:45:01 localhost CRON[14420]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 08:55:01 localhost CRON[15417]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 09:05:01 localhost CRON[16414]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 09:15:01 localhost CRON[17415]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 09:17:01 localhost CRON[17610]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 09:25:01 localhost CRON[18398]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 09:35:01 localhost CRON[19394]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 09:45:01 localhost CRON[20393]: (root) CMD (/usr/bin/apt-get update)
Feb 15 09:45:01 localhost CRON[20394]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 09:45:17 localhost CRON[20390]: (CRON) info (No MTA installed, discarding output)
Feb 15 09:55:01 localhost CRON[21645]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 10:05:01 localhost CRON[22635]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 10:15:01 localhost CRON[23611]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 10:17:01 localhost CRON[23814]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 10:25:01 localhost CRON[24602]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 10:35:01 localhost CRON[25594]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 10:45:01 localhost CRON[26594]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 10:55:01 localhost CRON[27587]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 11:05:01 localhost CRON[28572]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 11:15:01 localhost CRON[29552]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 11:17:01 localhost CRON[29748]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 11:25:01 localhost CRON[30540]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 11:35:01 localhost CRON[31520]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 11:45:01 localhost CRON[32516]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 11:55:01 localhost CRON[1038]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 12:05:01 localhost CRON[2166]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 12:15:01 localhost CRON[3162]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 12:17:01 localhost CRON[3357]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 12:25:01 localhost CRON[4137]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 12:35:01 localhost CRON[5126]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 12:45:01 localhost CRON[6107]: (root) CMD (/usr/bin/apt-get update)
Feb 15 12:45:01 localhost CRON[6108]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 12:45:07 localhost CRON[6106]: (CRON) info (No MTA installed, discarding output)
Feb 15 12:55:01 localhost CRON[7362]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 13:05:01 localhost CRON[8347]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 13:15:01 localhost CRON[9339]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 13:17:01 localhost CRON[9539]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 13:25:01 localhost CRON[10412]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 13:35:01 localhost CRON[11401]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 13:45:01 localhost CRON[12389]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 13:55:01 localhost CRON[13369]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 14:05:01 localhost CRON[14358]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 14:15:01 localhost CRON[15338]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 14:17:01 localhost CRON[15542]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 14:25:01 localhost CRON[16330]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 14:35:01 localhost CRON[17314]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 14:45:01 localhost CRON[18298]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 14:55:01 localhost CRON[19289]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 15:05:01 localhost CRON[20269]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 15:15:01 localhost CRON[21270]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 15:17:01 localhost CRON[21469]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 15:25:01 localhost CRON[22250]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 15:35:01 localhost CRON[23242]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 15:45:01 localhost CRON[24233]: (root) CMD (/usr/bin/apt-get update)
Feb 15 15:45:01 localhost CRON[24234]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 15:45:06 localhost CRON[24232]: (CRON) info (No MTA installed, discarding output)
Feb 15 15:55:01 localhost CRON[25471]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 16:05:01 localhost CRON[26471]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 16:15:01 localhost CRON[27455]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 16:17:01 localhost CRON[27654]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 16:25:01 localhost CRON[28443]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 16:35:01 localhost CRON[29423]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 16:45:01 localhost CRON[30413]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 16:55:01 localhost CRON[31389]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 17:05:01 localhost CRON[32365]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 17:15:01 localhost CRON[888]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 17:17:01 localhost CRON[1091]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 17:25:01 localhost CRON[2017]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 17:35:01 localhost CRON[3006]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 17:45:01 localhost CRON[3984]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 17:55:01 localhost CRON[4974]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 18:05:01 localhost CRON[5958]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 18:15:01 localhost CRON[6946]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 18:17:01 localhost CRON[7146]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 15 18:20:45 localhost cron[1397]: (CRON) INFO (pidfile fd = 3)
Feb 15 18:20:45 localhost cron[1398]: (CRON) STARTUP (fork ok)
Feb 15 18:20:45 localhost cron[1398]: (CRON) INFO (Running @reboot jobs)

Feb 15 18:25:01 localhost CRON[2646]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 18:35:01 localhost CRON[3703]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 18:45:01 localhost CRON[4732]: (root) CMD (/usr/bin/apt-get update)
Feb 15 18:45:01 localhost CRON[4733]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb 15 18:45:06 localhost CRON[4731]: (CRON) info (No MTA installed, discarding output)


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#52 2019-02-16 02:06:14

franko
Member
Registered: 2019-02-04
Posts: 33  

Re: Software update notifications in XFCE

I've been reading this guide, that brought me to my undestanding: https://code.tutsplus.com/tutorials/sch … --net-8800

Where do you get that log? I've been just observing when do I get the aforementioned mail from the cron job...

My cron job for the update is set like this: 0 */3 * * * root /usr/bin/apt-get update

According to what you say and what seems from that log, it would mean it would be done at 3 am, 6 am etc... But I received that mail some time after midnight and before 3 am -- of that I'm sure. So I believe it counts 3 hours since the computer boot up, and than again, and again... I will give more precise attention to it tomorrow.

It IS confusing...

Last edited by franko (2019-02-16 02:09:27)

Offline

#53 2019-02-16 03:48:23

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

franko wrote:

I've been reading this guide, that brought me to my undestanding: https://code.tutsplus.com/tutorials/sch … --net-8800

Where do you get that log? I've been just observing when do I get the aforementioned mail from the cron job...

My cron job for the update is set like this: 0 */3 * * * root /usr/bin/apt-get update

According to what you say and what seems from that log, it would mean it would be done at 3 am, 6 am etc... But I received that mail some time after midnight and before 3 am -- of that I'm sure. So I believe it counts 3 hours since the computer boot up, and than again, and again... I will give more precise attention to it tomorrow.

It IS confusing...

I don't know...perhaps the mail only goes out once a day?

Regarding the location of the log...I'm on my phone, so I'm doing this from memory...

I don't remember the actual name of the cron log file...but it's located in /var/log/ and it has "cron" in the name.

EDITED: Of all things, it's called cron.log   LOLOLOL! tongue

If it's not already there, check to see if cron is commented out in the rsyslog.conf file...found in /etc/rsyslog.conf.

I think you may have to reboot after uncommenting cron in the rsyslog.conf file for it to show up in /var/log.

Last edited by MiyoLinux (2019-02-16 12:33:49)


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#54 2019-02-16 12:43:34

xinomilo
Member
Registered: 2017-07-02
Posts: 65  

Re: Software update notifications in XFCE

cron.log is not always available. not by default IIRC. depends on log daemon/settings.
as root :
# grep CRON  /var/log/syslog

Feb 15 18:45:06 localhost CRON[4731]: (CRON) info (No MTA installed, discarding output)

this means there is no way to send email. you need an MTA installed. (i use ssmtp on laptop for that.)

Offline

#55 2019-02-16 17:19:36

franko
Member
Registered: 2019-02-04
Posts: 33  

Re: Software update notifications in XFCE

MiyoLinux wrote:

I don't know...perhaps the mail only goes out once a day?

Regarding the location of the log...I'm on my phone, so I'm doing this from memory...

I don't remember the actual name of the cron log file...but it's located in /var/log/ and it has "cron" in the name.

EDITED: Of all things, it's called cron.log   LOLOLOL! tongue

If it's not already there, check to see if cron is commented out in the rsyslog.conf file...found in /etc/rsyslog.conf.

I think you may have to reboot after uncommenting cron in the rsyslog.conf file for it to show up in /var/log.

No, the mail is delivered every time a root cron job is done... But you ARE right in the end. Last night I was sleepy and I deleted the mail before I checked it, and then commented basing myself on loose observation. Today I was brighter, and I checked the mail and when the various messages were sent: 15:00 and 18:00 h, for now.... and my laptop was on since about 13:00, So it's obvious I was in error. :-D Sorry for raising confusion. XD But I learned something. :-)

Offline

#56 2019-02-16 17:29:23

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

franko wrote:

No, the mail is delivered every time a root cron job is done...

Sorry for raising confusion. XD But I learned something. :-)

I also learned something. I have no mail. So, what you pointed out is good for me to know.

I didn't see it as confusion. smile


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#57 2019-02-16 17:47:39

chris2be8
Member
Registered: 2018-08-11
Posts: 56  

Re: Software update notifications in XFCE

Seeing the cron log reminded me that cron tries to email output from cron jobs to the user it runs as. So if you don't want the emails just redirect the output to /dev/null (much as the output from the debian-sa1 job is). Or redirect it to a file so you can see it if you want.

Chris

Offline

#58 2019-03-23 16:23:28

vasilis74
Member
Registered: 2019-03-15
Posts: 3  

Re: Software update notifications in XFCE

Hi all! This is my first post in the forum, glad to be here!

I have followed the instructions for Update Notifier, now I am waiting for some updates to see how it works.
If I understood right, update-notifier.py starts at boot time, but does the first apt-get update after 4 hours; or I am wrong and it does the first apt-get update at boot time, and then every 4 hours? If the first is correct, could something be added, so there is an apt-get update 2-3 or 5 minutes after boot time?

I also have a problem after installing pk-update-icon and unattended-upgrades, before I found Update Notifier in this thread. Now I have uninstalled pk-update-icon and unattended-upgrades, but in Synaptic, when I click Settings>Repositories, the repositories window does not pop-up, but a "Repositories Changed" window appears. Now I can only use /etc/apt/sources.list to manage repositories.
Can someone help here, or I should better open another thread?

Offline

#59 2019-03-25 19:54:45

geki
Member
Registered: 2019-02-04
Posts: 20  

Re: Software update notifications in XFCE

Just for the curious, I ported update notifier to pygobject using glib and gio. There is no longer a status icon. Also posting my cron files for completeness to show how to delay after boot and get an update after some minutes. I have neither seen an update after boot with the pygtk2 version.

I set my update interval to one hour.

$ cat /etc/cron.d/update_notifier 
@reboot root /etc/cron.hourly/update_notifier
$ cat /etc/cron.hourly/update_notifier 
#!/bin/sh

# wait up to 180 seconds to run apt-get

MAILTO=""

test -x /usr/bin/apt-get || exit 0
/usr/bin/python3 -c 'import random; import time; time.sleep(random.random() * 180)' \
	&& /usr/bin/apt-get update
$ cat /usr/share/update-notifier/update-notifier.py
#!/usr/bin/env python3

################################################################################
# Configuration Section Begins Here                                            #
################################################################################

c = dict(
    # The title to be shown on the pop-up and the icon tooltip.
    title = "Updates Available",

    # The message to be shown in the pop-up.
    message = "There are updates available to install.",

    # Icon to use in the system tray and pop-up.
    icon = "/usr/share/update-notifier/updates.svg",

    # Frequency to check for available updates.
    #interval = 900, # 15 minutes
    #interval = 14400, # 4 hours
    interval = 3600, # 1 hour

    # Command to run to check for available updates, and the expected status
    # code that indicates updates are available.
    check = "/usr/bin/apt-get -s dist-upgrade | /bin/grep -c '^Inst '",
)

################################################################################
# Configuration Section Ends Here                                              #
################################################################################

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, GLib

import subprocess
from time import time
from random import random

def on_activate(data):
    '''do nothing'''

def main_loop():
    global next_check
    if (int(time()) >= next_check):
        status = subprocess.getoutput(c['check'])

        # Updates?
        if (status != "0"):
            global app
            icon = Gio.Icon.new_for_string(c['icon'])
            notifier = Gio.Notification.new(c['title'])
            notifier.set_body(c['message'])
            notifier.set_icon(icon)

            app.send_notification('update.popup', notifier)

        next_check = next_check + c['interval'] + int(random() * 300)

    return GLib.SOURCE_CONTINUE;

# + 200 for cron job to run after boot
next_check = int(time()) + 200 + int(random() * 300)

# service to run only one instance and allow to functioning as-is
app = Gio.Application.new('update.notifier', Gio.ApplicationFlags.IS_SERVICE)

# either notification action or app activate signal
app.connect('activate', on_activate)

try:
    if (app.register() == True):
        source_id = GLib.timeout_add_seconds(60, main_loop)

        GLib.MainLoop().run()

        GLib.source_remove(source_id)
except GLib.Error as e:
    print('Failed to register service: {0} ({1})'.format(e.message, e.code))

# vim:expandtab

Last edited by geki (2019-04-15 14:53:58)

Offline

#60 2019-04-16 09:50:34

geki
Member
Registered: 2019-02-04
Posts: 20  

Re: Software update notifications in XFCE

I added AppIndicator3 as tray icon. UPDATE Got my problems sorted out. Reorder updating of notification and tray indicator and using Gio.SimpleAction as callback mechanism. UPDATE #2 Depend on packages ayatana-indicator-application and mate-indicator-applet or xfce-indicator-plugin.  A round of cleanup. UPDATE #3 mate-indicator-applet needs a patch to send the "secondary-activate" event. I send the patch to Debian maintainer. Hopefully we will see an update to the package with the patch applied. xfce4-indicator-plugin already generates the "secondary-activate" event.

#!/usr/bin/env python3

################################################################################
# Configuration Section Begins Here                                            #
################################################################################

config = dict(
    # The title to be shown on the pop-up and the icon tooltip.
    title = "Updates Available",

    # The message to be shown in the pop-up.
    message = "There are updates available to install.",

    # Icon to use in the system tray and pop-up.
    icon = "/usr/share/update-notifier/updates.svg",

    # Frequency to check for available updates.
    #interval = 900, # 15 minutes
    #interval = 14400, # 4 hours
    interval = 3600, # 1 hour

    # Command to run to check for available updates, and the expected status
    # code that indicates updates are available.
    check = "/usr/bin/apt-get -s dist-upgrade | /bin/grep -c '^Inst '",
)

################################################################################
# Configuration Section Ends Here                                              #
################################################################################

try:
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gio, GLib, Gtk
    gi.require_version('AyatanaAppIndicator3', '0.1')
    from gi.repository import AyatanaAppIndicator3 as appindicator

    import sys
    import subprocess
    from time import time
    from random import random
except ImportError:
    print("Failed to import Gio, GLib, Gtk or AyatanaAppIndicator3 or other helpers")
    raise NotImplementedError

# hide tray icon from application
def on_action_hide(action, parameter):
    global tray
    tray.set_status(appindicator.IndicatorStatus.PASSIVE)

# hide tray icon from app indicator
def on_menu_hide(menu_item):
    global tray
    tray.set_status(appindicator.IndicatorStatus.PASSIVE)

def on_connect_changed(indicator, connected):
    global app
    if (connected == False):
        print('packages missing: ayatana-indicator-application and mate-indicator-applet for MATE not installed (other DEs may have similar indicator-applet package for ayatana indicators)')
        app.quit()

# app indicator tray icon
def tray_icon():
    global config
    tray = appindicator.Indicator.new('update.notifier.tray', config['icon'],
        appindicator.IndicatorCategory.SYSTEM_SERVICES)
    tray.set_title(config['title'])
    tray.connect('connection-changed', on_connect_changed)

    # minimalistic menu for tray
    menu = Gtk.Menu()
    item_hide = Gtk.MenuItem.new_with_label('Hide')
    item_hide.connect('activate', on_menu_hide)
    menu.append(item_hide)
    menu.show_all()
    tray.set_menu(menu)
    tray.set_secondary_activate_target(item_hide)
    return tray

def query_update():
    global app, tray, config, next_check

    # keep application running
    app.hold()

    if (int(time()) >= next_check):
        status = subprocess.getoutput(config['check'])

        # Updates?
        if (status != "0"):
            # show tray icon
            tray.set_status(appindicator.IndicatorStatus.ACTIVE)

            # show notification popup
            icon = Gio.Icon.new_for_string(config['icon'])
            notifier = Gio.Notification.new(config['title'])
            notifier.set_body(config['message'])
            notifier.set_default_action('app.hide')
            notifier.set_icon(icon)

            app.send_notification('update-notifier-popup', notifier)

        next_check = next_check + config['interval'] + int(random() * 300)

    # keep application running
    app.release()

    return GLib.SOURCE_CONTINUE;

# + 200 for cron job to run at boot
next_check = int(time()) + 200 + int(random() * 300)

# service to run only one instance and allow to functioning as-is
app = Gio.Application.new('update.notifier.app', Gio.ApplicationFlags.IS_SERVICE)

# have a globally accessible tray instance 
tray = None

try:
    if (app.register() == True):
        # keep application running
        app.hold()

        # application hide action
        action_hide = Gio.SimpleAction.new('hide')
        action_hide.connect('activate', on_action_hide)

        app.add_action(action_hide)

        # keep application running
        app.set_inactivity_timeout(180000)

        # hidden tray icon
        tray = tray_icon()

        source_id = GLib.timeout_add_seconds(60, query_update)

        # keep application running
        app.release()
        app.run(sys.argv)

        GLib.source_remove(source_id)
except GLib.Error as e:
    print('Failed to register service: {0} ({1})'.format(e.message, e.code))

# vim:expandtab

Last edited by geki (2019-04-20 08:18:38)

Offline

#61 2019-04-16 17:11:02

geki
Member
Registered: 2019-02-04
Posts: 20  

Re: Software update notifications in XFCE

Tried to map [0][1] to python3, with Gio.Application and its dbus connection, but it seems to need a bit more knowledge. Though, an indicator should be possible without Gtk and AppIndicator3. I just need my basic variant.

If anyone is interested:

[0] https://askubuntu.com/questions/690769/ … 750#752750
[1] https://github.com/sneetsher/mysystemin … -service.c

Offline

#62 2019-04-29 20:22:07

farmatito
Member
Registered: 2019-04-29
Posts: 5  

Re: Software update notifications in XFCE

Hi to all,
a simpler solution I used with KDE and use now with XFCE is to install the cron-apt package for taking care of the updating part
and to add this script to the application autostart settings of the DE:

#!/bin/sh
NAME=`basename $0`
LIST=`pgrep $NAME`
# Sometimes this process is not killed 
# when you log out of the DE so kill
# any leftovers
for ITEM in $LIST
do
        if [ $ITEM -ne $$ ] ; then
               # I suppose you cannot kill other people's processes
               # ....unless you are root
                /bin/kill $ITEM
        fi
done

# at KDE start wait 30 secs
sleep 30

while true
do
        NUM=$(aptitude search "~U" | wc -l)
        if [ $NUM -eq 1 ] ; then
                notify-send  -t 590000 "There is $NUM update" &
        fi
        if [ $NUM -gt 1 ] ; then
                notify-send -t 590000 "There are $NUM updates" &
        fi
        sleep 600
done

This could eventually be enhanced to display a list of updates as shown in previous posts and an icon.
If I recall correctly notify-send cannot launch an application by clicking on the notification dialog or at least
I was not able to find a way do so.

Just my 2 cents.

Offline

#63 2019-06-05 06:32:01

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

Hello everyone; I hope you're doing well! smile

I've created  a .deb package for the update notifier that has been discussed here...

It's a simple notifier that checks for updates every 4 hours. When updates are available, a desktop notification will appear as well as a system tray notification. If you click on the icon in the system tray, a notification window will open that presents the updates that are available (thanks fsr!). Please be aware that you will still have to update manually through your terminal or Synaptic...it's just a notifier. smile  I chose this route, because I wanted the user to be able to decide if they wanted to install the updates "now" or "later".

Also, please be aware that if you're using an obscure window manager (such as i3), you will need to add the update-notifier.py to your autostart file. The update-notifier.py will be found in /usr/share/update-notifier/

I would appreciate anyone who is willing to test it for me. smile  After installing it, you will need to at least log out and log in for it to start working.

It can be downloaded from...

https://sourceforge.net/projects/miyoli … deb_files/

Last edited by MiyoLinux (2019-06-05 06:45:59)


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#64 2019-06-07 18:00:13

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 280  
Website

Re: Software update notifications in XFCE

Lintian has some comments about your .deb package:

E485:~$ lintian --no-tag-display-limit miyo-update-notifier_1.0_all.deb 
E: miyo-update-notifier: changelog-file-missing-in-native-package
E: miyo-update-notifier: file-in-etc-not-marked-as-conffile etc/cron.d/update_notifier
E: miyo-update-notifier: file-in-etc-not-marked-as-conffile etc/xdg/autostart/update-notifier.desktop
E: miyo-update-notifier: no-copyright-file
W: miyo-update-notifier: description-synopsis-starts-with-article
W: miyo-update-notifier: description-too-long
E: miyo-update-notifier: extended-description-is-empty
E: miyo-update-notifier: maintainer-address-missing MiyoLinux
W: miyo-update-notifier: essential-no-not-needed
W: miyo-update-notifier: no-section-field
E: miyo-update-notifier: wrong-file-owner-uid-or-gid etc/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid etc/cron.d/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid etc/cron.d/update_notifier 1000/1002
E: miyo-update-notifier: bad-permissions-for-etc-cron.d-script etc/cron.d/update_notifier 0755 != 0644
E: miyo-update-notifier: wrong-file-owner-uid-or-gid etc/xdg/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid etc/xdg/autostart/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid etc/xdg/autostart/update-notifier.desktop 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/bin/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/bin/show-updates 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/share/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/share/update-notifier/ 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/share/update-notifier/update-notifier.py 1000/1002
E: miyo-update-notifier: wrong-file-owner-uid-or-gid usr/share/update-notifier/updates.svg 1000/1002
W: miyo-update-notifier: binary-without-manpage usr/bin/show-updates
E: miyo-update-notifier: python-script-but-no-python-dep usr/share/update-notifier/update-notifier.py #!python
W: miyo-update-notifier: executable-not-elf-or-script etc/xdg/autostart/update-notifier.desktop
W: miyo-update-notifier: executable-not-elf-or-script etc/cron.d/update_notifier
W: miyo-update-notifier: executable-not-elf-or-script usr/share/update-notifier/updates.svg
E485:~1$

So I think you need to correct the ownership & permissions for the various files, make the desktop file & .svg non-executable, add a debian/copyright file (GPL ftw!) and debian/conffiles[1] listing the cron & autostart entries.

For the description try this in debian/control:

Description: basic update notifier
 A basic update notifier that checks for updates every four hours.
 .
 When updates are available, a notification and icon will appear in the system 
 tray and on the desktop. Clicking the icon in the system tray will present a 
 notification on the desktop that tells what updates are available.
 .
 The user will still need to upgrade their system via the terminal or Synaptic.

HTH

EDIT: corrected typo in the description.

Last edited by Head_on_a_Stick (2019-06-07 18:45:07)


Fabricando fit faber

Offline

#65 2019-06-07 21:21:41

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

YIKES! 

Thank you so much HoaS!

....now where did I put that chmod?

big_smile tongue


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#66 2019-06-07 21:42:40

Dutch_Master
Member
Registered: 2018-05-31
Posts: 81  

Re: Software update notifications in XFCE

MiyoLinux wrote:

....now where did I put that chmod?

big_smile tongue

I think you'd need to look for it in Lost + Found wink big_smile

(sorry, couldn't resist!)

Offline

#67 2019-06-08 10:04:30

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

Dutch_Master wrote:
MiyoLinux wrote:

....now where did I put that chmod?

big_smile tongue

I think you'd need to look for it in Lost + Found wink big_smile

(sorry, couldn't resist!)

LOLOL!!! big_smile  Good one!

Okay, I've worked on the package, and this is the only warning that I'm getting...

W: miyo-update-notifier: binary-without-manpage usr/bin/show-updates

So, my question is...

Is this detrimental to whether the package can be trusted by people who may want to use it? Good grief...going in and fixing the issues caused other issues that caused me to have to fix other issues in order to fix the original issues...  tongue

I've looked at the man folder on my system to try and get some clue, but there are so many sub-folders, I'm not sure where to begin to put a man-page for the notifier!

Goodgrief'amightyIt'salmostasthoughDebianhassometypeofstandardsthattheywanttobemetforsomereasonStinkin'hotdogwithoutrelishandI'mabouttohaveanervous-jerkdownandmightymorphinpowerrangers!!!

tongue  big_smile

If anyone is willing to test it again, it is version 1.1, and it can be downloaded from...

https://sourceforge.net/projects/miyoli … deb_files/


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

#68 2019-06-08 10:27:24

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 280  
Website

Re: Software update notifications in XFCE

MiyoLinux wrote:

Okay, I've worked on the package, and this is the only warning that I'm getting...

W: miyo-update-notifier: binary-without-manpage usr/bin/show-updates

So, my question is...

Is this detrimental to whether the package can be trusted by people who may want to use it?

I don't think so, no. Man pages are nice but hardly essential for a script which has no options.

For scripts that do have options you can use the help2man package to generate a simple man page without having to actually write one yourself.

I would test your package but I use unattended-upgrades and I don't run the notification daemon, sorry.

It looks like it should work though, FWIW.

EDIT: if you wanted to add a man page then include it at (for example) debian/show-updates.1 and then add a file at debian/miyo-update-notifier.manpages with a line listing the location of the man page:

debian/show-updates.1

The page will then be placed correctly by dpkg-buildpackage.

That command should be listed under section 1 of the man pages, man man gives an overview of these in the DESCRIPTIONS section:

man man wrote:

       The  table below shows the section numbers of the manual followed by the types of pages they
       contain.

       1   Executable programs or shell commands
       2   System calls (functions provided by the kernel)
       3   Library calls (functions within program libraries)
       4   Special files (usually found in /dev)
       5   File formats and conventions eg /etc/passwd
       6   Games
       7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
       8   System administration commands (usually only for root)
       9   Kernel routines [Non standard]

Last edited by Head_on_a_Stick (2019-06-08 10:33:20)


Fabricando fit faber

Offline

#69 2019-06-08 10:51:24

MiyoLinux
Member
Registered: 2016-12-05
Posts: 904  

Re: Software update notifications in XFCE

Head_on_a_Stick wrote:
MiyoLinux wrote:

Okay, I've worked on the package, and this is the only warning that I'm getting...

W: miyo-update-notifier: binary-without-manpage usr/bin/show-updates

So, my question is...

Is this detrimental to whether the package can be trusted by people who may want to use it?

I don't think so, no. Man pages are nice but hardly essential for a script which has no options.

For scripts that do have options you can use the help2man package to generate a simple man page without having to actually write one yourself.

I would test your package but I use unattended-upgrades and I don't run the notification daemon, sorry.

It looks like it should work though, FWIW.

EDIT: if you wanted to add a man page then include it at (for example) debian/show-updates.1 and then add a file at debian/miyo-update-notifier.manpages with a line listing the location of the man page:

debian/show-updates.1

The page will then be placed correctly by dpkg-buildpackage.

That command should be listed under section 1 of the man pages, man man gives an overview of these in the DESCRIPTIONS section:

man man wrote:

       The  table below shows the section numbers of the manual followed by the types of pages they
       contain.

       1   Executable programs or shell commands
       2   System calls (functions provided by the kernel)
       3   Library calls (functions within program libraries)
       4   Special files (usually found in /dev)
       5   File formats and conventions eg /etc/passwd
       6   Games
       7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
       8   System administration commands (usually only for root)
       9   Kernel routines [Non standard]

Thank you HoaS!

I want to be like you when I grow up! smile

It works; I tested it before I uploaded it. It works perfectly. I think that I'll let it stand "as-is" for now. Thank you so much for your help...I learned a few things from what you posted. smile

EDITED TO CORRECT A WORD...  tongue

Last edited by MiyoLinux (2019-06-08 13:43:39)


I have been Devuanated, and my practice in the art of Devuanism shall continue until my Devuanization is complete. Until then, I will strive to continue in my understanding of Devuanchology, Devuanprocity, and Devuanivity.

Veni, vidi, vici vdevuaned. I came, I saw, I Devuaned. wink

Offline

Board footer