Detect new upgrades graphically (XFCE and others DE)

Other talk about Salix
User avatar
JRD
Salix Warrior
Posts: 950
Joined: 7. Jun 2009, 22:52
Location: Lyon, France

Detect new upgrades graphically (XFCE and others DE)

Post 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
Image
User avatar
gapan
Salix Wizard
Posts: 6373
Joined: 6. Jun 2009, 17:40

Re: Script to detect new upgrades graphically on XFCE

Post by gapan »

Very nice! Thanks! :ugeek:
Image
Image
User avatar
Akuna
Salix Wizard
Posts: 1038
Joined: 14. Jun 2009, 12:25

Re: Script to detect new upgrades graphically on XFCE

Post by Akuna »

Maybe something to add to the settings package?
Image
What really matters is where you are going, not where you come from.
User avatar
fredg
Posts: 232
Joined: 3. Oct 2009, 16:50
Location: Lyon, France
Contact:

Re: Script to detect new upgrades graphically on XFCE

Post by fredg »

So cool ! :)
It should be installed by default.

++
User avatar
JRD
Salix Warrior
Posts: 950
Joined: 7. Jun 2009, 22:52
Location: Lyon, France

Re: Script to detect new upgrades graphically on XFCE

Post 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.
Image
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Script to detect new upgrades graphically on XFCE

Post 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.
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
gapan
Salix Wizard
Posts: 6373
Joined: 6. Jun 2009, 17:40

Re: Script to detect new upgrades graphically on XFCE

Post 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
Image
Image
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Script to detect new upgrades graphically on XFCE

Post by thenktor »

IMHO a XFCE specific solution is no good idea. It should work with every systray (gnome, kde, tint2 & other panels).
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
User avatar
damNageHack
Posts: 663
Joined: 24. Sep 2009, 17:07

Re: Script to detect new upgrades graphically on XFCE

Post 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.
Image
This is the oppinion of the author, it does not force you to share and is signed automatically.
You are free to keep them all errors for your own. Linux is the best game I ever played.
User avatar
thenktor
Salix Wizard
Posts: 2426
Joined: 6. Jun 2009, 14:47
Location: Franconia
Contact:

Re: Script to detect new upgrades graphically on XFCE

Post by thenktor »

Popup of course is crap but an icon in systray IMHO is ok.
Image
burnCDDA (burns audio CDs)
geBIERt (German beer blog)
Post Reply