Page 1 of 5

Detect new upgrades graphically (XFCE and others DE)

Posted: 15. Nov 2009, 22:13
by JRD
I share here the way I detect when there are updates available.

First install the following packages (avail. on Salix):
- xfce4-genmon-plugin
- libnotify
- ktsuss (already installed normally)
- slapt-get (already installed normally)
- gslapt (already installed normally, and this could be another graphical package manager)

First, create a "bin" folder in your home directory if not already done.
Then create the file SalixCheckUpdates whith exec permission:

Code: Select all

$ cat <<'EOF' > ~/bin/SalixCheckUpdates
#!/bin/sh
CFG=~/.config/SalixCheckUpdates
if [ ! -e $CFG ]; then
  mkdir -p $CFG
fi
CHECKCMD=$(cat $CFG/check_command 2>/dev/null || echo "PKGS=(\$(/usr/sbin/slapt-get -s --upgrade|grep '^  ')) ; echo \${#PKGS[@]}")
N=$(bash -c "$CHECKCMD")
PKGM=$(cat $CFG/package_manager 2>/dev/null || echo gslapt)
if [ $N == 0 ]; then
  echo "<img>/usr/share/icons/gnome-colors-common/24x24/status/updates-notifier-inactive.png</img><click>gksu $PKGM</click>"
else
  echo "<img>/usr/share/icons/gnome-colors-common/24x24/status/updates-notifier.png</img><click>gksu $PKGM</click><tool>$N updates !</tool>"
  C=0
  if [ -r $CFG/count ]; then
    C=$(cat $CFG/count)
  fi
  if [ "$C" != "$N" ]; then
    notify-send 'Salix Check Updates' "$N packages to upgrade !"
  fi
fi
echo $CHECKCMD > $CFG/check_command
echo $PKGM > $CFG/package_manager
echo $N > $CFG/count
EOF
$ chmod +x ~/bin/SalixCheckUpdates
Add a "Generic Monitor" plugin in a XFCE panel with the following configuration:
Command : /home/$USER/bin/SalixCheckUpdates
Label : SCU
Period : 600 (every 10 min)

Last, in superuser, create the following file:

Code: Select all

# cat <<'EOF' > /etc/cron.hourly/slaptget
#!/bin/sh
ionice -c3 nice -n 19 /usr/sbin/slapt-get -u
EOF
You're done !

Here is two screenshots:
Image

Image

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 05:32
by gapan
Very nice! Thanks! :ugeek:

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 06:32
by Akuna
Maybe something to add to the settings package?

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 08:17
by fredg
So cool ! :)
It should be installed by default.

++

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 09:46
by JRD
Thanks. I just dropped it here, I'm a bit surprise and pleased of the reaction ^_^
For putting in default in a settings package, the script should be rather place in /usr/bin/
If you find a way to enhance this script....that's good.

Oh, this script in under GPLv3+ if you ask.

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 12:37
by thenktor

Code: Select all

# cat <<'EOF' > /etc/cron.hourly/slaptget
#!/bin/sh
ionice -c3 nice -n 19 /usr/sbin/slapt-get -u
EOF
Are you sure this works correctly? I wonder if slapt-get really is started with ionice -c3 then. I guess nice is started with ionice -c3 which is useless then.

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 12:56
by gapan
It would take some work to make a package out of it. For example, I think it treats excluded packages as upgrades as it is. And it needs a specific xfce panel plugin to be installed and configured. A solution that would display a notification icon in the tray would be cleaner. And I think just launching gslapt is not too helpful, it would be a lot better if it just did the upgrades, without the need for gslapt. There is already slapt-update-notifier that is supposed to do the same thing exactly, but it never worked during my tests, the daemon that it launches keeps dying for no apparent reason. Perhaps I'll have to ask its developer.

Or... maybe I can cook something of my own. :D

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 17:31
by thenktor
IMHO a XFCE specific solution is no good idea. It should work with every systray (gnome, kde, tint2 & other panels).

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 19:48
by damNageHack
I am - as an user of Salix - against automatic updates or even automated "updates available" notifications.

Such things are more obstructive than helpful for normal work. How often and when will the notifier pop up?

Somebody knowing this feature from Ubuntu.

EDIT
Better would be:

Code: Select all

notify-send "You have new spam"
I hope you can understand the irony in it.

Re: Script to detect new upgrades graphically on XFCE

Posted: 16. Nov 2009, 22:27
by thenktor
Popup of course is crap but an icon in systray IMHO is ok.