tazpkg view tazpkg-notify @ rev 603

**tazpkg**: add common output functions: action, title, footer; change the way category translate, localized categories can include spaces; implement boldify, emsg & confirm functions from new libtaz; rename log function to log_pkg; fix check_root invocation; fix convert_rpm function; implement plural i18n messages; list-mirror: --text|--txt|--raw|* produces same output; extract: check for errors in final message; list-config --box: do we need it?; repack-config: date/time in receipt in local format; '--help-up' changed to 'help-up' due to error with new libtaz. **tazpkg-box**: add i18n preamble; fix actions. **tazpkg-notify**: implement plural. **Makefile**: support new functions & tazpkg-box. **po/**: Make pot & msgmerge. Add Russian translation. Add Spanish translation for tazpkg-notify (thanks Kevin Fabian Quintero).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Jun 23 00:51:57 2012 +0000 (2012-06-23)
parents 7d8d81c885c3
children 5317ffe7bfbb
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="file:///usr/share/doc/tazpkg/tazpkg.html"
24 installed=$(ls $db/installed | wc -l)
25 text="$(eval_ngettext \
26 '<b>$installed</b> installed package' \
27 '<b>$installed</b> installed packages' $installed)"
28 icon="/usr/share/pixmaps/tazpkg.png"
29 [ -f "$db/packages.list" ] && mtime=$(find $db/packages.list -mtime +10;)
30 [ -f "$db/packages.up" ] && up=$(cat $db/packages.up | wc -l)
32 # Notification icon
33 listen() {
34 # Manage the I/O redirection from SHell
35 rm -f $fifo && mkfifo $fifo
36 # Attach a file descriptor
37 exec 3<> $fifo
38 # Notification icon
39 yad --notification --listen --image=$icon \
40 --text="$(eval_gettext 'Checking packages lists - $text')" <&3
41 # Clean-up
42 rm -f $fifo
43 }
45 # Notication menu (right click)
46 menu() {
47 cat << EOT
48 menu:\
49 $(gettext "My packages")!tazweb $panel?list!tazpkg|\
50 $(gettext "Recharge lists")!tazweb $panel?recharge!tazpkg-up|\
51 $(gettext "Check upgrade")!tazweb $panel?up!tazpkg-up|\
52 $(gettext "TazPKG SHell")!terminal -e tazpkg shell!xterm|\
53 $(gettext "TazPKG manual")!tazweb $doc!text-html|\
54 $(gettext "Close notification")!quit!gtk-close
55 EOT
56 }
58 case $1 in
59 usage|help|*-h)
60 gettext "Usage:"; echo " $(basename $0)" ;;
61 *)
62 # Sleep before displaying the notification icon and
63 # sleep to let user read the tooltips.
64 sleep 4
65 listen &
66 sleep 2
67 menu > $fifo
68 sleep 6
69 # Missing packages list
70 if [ ! -f $db/packages.list ]; then
71 tooltip=$(eval_gettext 'No packages list found - $text')
72 echo "action:tazweb $panel?recharge" > $fifo
73 echo "tooltip:$tooltip" > $fifo
74 echo "icon:tazpkg-up" > $fifo && exit 0
75 fi
76 # Too old packages list
77 if [ "$mtime" ]; then
78 tooltip=$(gettext "Your packages list is older than 10 days")
79 echo "action:tazweb $panel?recharge" > $fifo
80 echo "tooltip:$tooltip" > $fifo
81 echo "icon:tazpkg-up" > $fifo && exit 0
82 fi
83 # Available upgrades
84 if [ "$up" -gt 0 ]; then
85 tooltip=$(eval_ngettext \
86 'There is <b>$up</b> upgradeable package' \
87 'There are <b>$up</b> upgradeable packages' $up)
88 echo "action:tazweb $panel?up" > $fifo
89 echo "tooltip:$tooltip" > $fifo
90 echo "icon:tazpkg-up" > $fifo && exit 0
91 fi
92 # Nothing to do, close notification
93 tooltip=$(eval_gettext 'System is up to date - $text')
94 echo "tooltip:$tooltip" > $fifo
95 sleep 10
96 echo "quit" > $fifo ;;
97 esac
98 exit 0