tazpkg view tazpkg-notify @ rev 558

Remove old tazpkg-notify po files (all strings have changed)
author Christophe Lincoln <pankso@slitaz.org>
date Fri Mar 02 15:14:11 2012 +0100 (2012-03-02)
parents d8750abd87bd
children da3bd3962a3e
line source
1 #!/bin/sh
2 #
3 # TazPKG Notify - Notification icon for Tazpkg packages. Recharging pkgs
4 # list can be done automatically at boot, so notifies users if some
5 # updates are available. Also notifies users if the packages list is too
6 # old and out-of-date or if no packages list found. This script should
7 # be run by the WM autostart script or ~/.xsession and needs a systray to
8 # sit in like in LXpanel or Tint2.
9 #
10 # Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2
11 #
12 # Authors : Christophe Lincoln <pankso@slitaz.org>
13 #
15 # I18n
16 . /usr/bin/gettext.sh
17 TEXTDOMAIN='tazpkg-notify'
18 export TEXTDOMAIN
20 fifo=/tmp/$(basename $0).fifo
21 panel="http://tazpanel:82/pkgs.cgi"
22 db="/var/lib/tazpkg"
23 doc="/usr/share/doc/tazpkg/tazpkg.html"
24 installed=$(ls $db/installed | wc -l)
25 text="$(gettext "Installed packages") <b>$installed</b>"
26 [ -f "$db/packages.list" ] && mtime=$(find $db/packages.list -mtime +10;)
27 [ -f "$db/packages.up" ] && up=$(cat $db/packages.up | wc -l)
29 # Notification icon
30 listen() {
31 # Manage the I/O redirection from SHell
32 rm -f $fifo && mkfifo $fifo
33 # Attach a file descriptor
34 exec 3<> $fifo
35 # Notification icon
36 yad --notification --listen --image="tazpkg" \
37 --text="Checking packages lists - $text" <&3
38 # Clean-up
39 rm -f $fifo
40 }
42 # Notication menu (right click)
43 menu() {
44 cat << EOT
45 menu:\
46 $(gettext "My packages")!tazweb $panel?list!tazpkg|\
47 $(gettext "Recharge lists")!tazweb $panel?recharge!tazpkg-up|\
48 $(gettext "Check upgrade")!tazweb $panel?up!tazpkg-up|\
49 $(gettext "TazPKG SHell")!terminal -e tazpkg shell!xterm|\
50 $(gettext "TazPKG manual")!tazweb $doc!text-html|\
51 $(gettext "Close notification")!quit!gtk-close
52 EOT
53 }
55 case $1 in
56 usage|help|*-h)
57 gettext "Usage:"; echo " $(basename $0)" ;;
58 *)
59 # Sleep before displaying the notification icon and
60 # sleep to let user read the tooltips.
61 sleep 4
62 listen &
63 sleep 2
64 menu > $fifo
65 sleep 6
66 # Missing packages list
67 if [ ! -f $db/packages.list ]; then
68 tooltip=$(eval_gettext \
69 "No packages list found - \$text")
70 echo "action:tazweb $panel?recharge" > $fifo
71 echo "tooltip:$tooltip" > $fifo
72 echo "icon:tazpkg-up" > $fifo && exit 0
73 fi
74 # Too old packages list
75 if [ "$mtime" ]; then
76 tooltip=$(gettext "Your packages list is older than 10 days")
77 echo "action:tazweb $panel?recharge" > $fifo
78 echo "tooltip:$tooltip" > $fifo
79 echo "icon:tazpkg-up" > $fifo && exit 0
80 fi
81 # Avalaible upgrades
82 if [ "$up" -gt 0 ]; then
83 tooltip=$(eval_gettext \
84 "There are <b>\$up</b> upgradeable packages")
85 echo "action:tazweb $panel?up" > $fifo
86 echo "tooltip:$tooltip" > $fifo
87 echo "icon:tazpkg-up" > $fifo && exit 0
88 fi
89 # Nothing to do, close notification
90 tooltip=$(eval_gettext "System is up to date - \$text")
91 echo "tooltip:$tooltip" > $fifo
92 sleep 10
93 echo "quit" > $fifo ;;
94 esac
95 exit 0