Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-02-12 07:57:37

superlinux
Member
From: Germany
Registered: 2016-02-12
Posts: 9

New updates as notification?

Hello,
i'm using Xubuntu 15.10. Is it possible to see a notification (notify-send) when
new updates available? I see only the task-icon in the windowlist.
Hope you have an idea!
Thanks a lot!

Offline

#2 2016-02-12 12:14:03

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,949

Re: New updates as notification?

Hello and welcome.

I don't believe you can get the built-in update-notifier to send a notification bubble when updates are available.

Here is what I use instead:

1. Add the following command to the bottom of your ~/.bashrc file (this is required because I run the check in my cron and it needs access to these user session variables):

export | egrep "DBUS_SESSION_BUS_ADDRESS|DISPLAY" > ~/.xsession-export

2. Either log out and back in again or run that command manually to create the ~/.xsession-export file:

export | egrep "DBUS_SESSION_BUS_ADDRESS|DISPLAY" > ~/.xsession-export

3. Create the following script file:

#!/bin/bash

# get X session variables
#    need to have: export | egrep "DBUS_SESSION_BUS_ADDRESS|DISPLAY" > ~/.xsession-export
#	at the end of your ~/.bashrc file
. $HOME/.xsession-export

# The results
result1=`apt-get -s upgrade | grep "not upgraded" | cut -d" " -f1`
result2=`apt-get -s upgrade | grep "not upgraded" | cut -d" " -f3`
result3=`apt-get -s upgrade | grep "not upgraded" | cut -d" " -f6`
result4=`apt-get -s upgrade | grep "not upgraded" | cut -d" " -f10`

let result=$result1+$result2+$result3+$result4

if [ $result -gt 0 ]; then
     notify-send -i dialog-information "Update Notification" "$result1   to be upgraded\n$result2   to be newly installed\n$result3   to be removed\n$result4   require dist-upgrade"
fi

exit 0

...and make it executable.

4. Create a cron entry to run this script (this cron entry runs every hour - change that to suit your needs):

0 * * * * /path/to/my/script

...and change "/path/to/my/script" to point to the script file you created.

screenshot2016-02-1207-07-40.png


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2016-02-12 13:37:49

superlinux
Member
From: Germany
Registered: 2016-02-12
Posts: 9

Re: New updates as notification?

Hello ToZ.

Wow - that's more than i want! It looks fantastic - a notification with some details - great!
Thank you very much!

Offline

#4 2016-02-12 13:58:11

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,949

Re: New updates as notification?

No worries. I added an if statement to the script so that the notification bubble only displays if there are updates available.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2016-02-12 14:24:35

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,949

Re: New updates as notification?

Here is another version of the script file that uses the built-in update-notifier processes to check for updates. It executes a little faster and provides update information in a similar manner as the update-notifier:

#!/bin/bash

# get X session variables
#    need to have: export | egrep "DBUS_SESSION_BUS_ADDRESS|DISPLAY" > ~/.xsession-export
#	at the end of your ~/.bashrc file
. $HOME/.xsession-export

# get update-notifier available updates
/usr/lib/update-notifier/apt_check.py > /tmp/av 2>&1

result1=$(cat /tmp/av | awk 'BEGIN {FS = ";" } ; { print $1 }')
result2=$(cat /tmp/av | awk 'BEGIN {FS = ";" } ; { print $2 }')

let result=$result1+$result2

if [ $result -gt 0 ]; then
	notify-send -i dialog-information "Updates Available" "$result1   packages can be updated\n$result2   updates are security updates"
fi

exit 0

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 2016-02-13 07:12:32

superlinux
Member
From: Germany
Registered: 2016-02-12
Posts: 9

Re: New updates as notification?

Hello ToZ.
Thank you for your answers! I'll try both versions and see wich one is the right for me.

Offline

Board footer

Powered by FluxBB