tazpkg view tazpkg-notify @ rev 633

Add Polish translation (thanks Pawel Pyrczak); merge tazpkg, tazpkg-notify and other *pkg* translations into one; simplify plural translations using $num; normalize name (Tazpkg, TazPKG -> TazPkg); move markup outside translations; re-use categories names in tazpkg and tazpanel; other tiny improvements.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Jul 25 01:47:48 2013 +0300 (2013-07-25)
parents de952705379e
children 0daa5fc6754f
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 export TEXTDOMAIN='tazpkg'
19 fifo=/tmp/$(basename $0).fifo
20 panel="http://tazpanel:82/pkgs.cgi"
21 db="/var/lib/tazpkg"
22 doc="file:///usr/share/doc/tazpkg/tazpkg.html"
24 installed=$(ls $db/installed | wc -l)
25 num="<b>$installed</b>"
26 text="$(eval_ngettext \
27 '$num installed package' \
28 '$num installed packages' $installed)"
29 icon="/usr/share/pixmaps/tazpkg.png"
30 [ -f "$db/packages.list" ] && mtime=$(find $db/packages.list -mtime +10;)
31 [ -f "$db/packages.up" ] && up=$(cat $db/packages.up | wc -l)
33 # Notification icon
34 listen() {
35 # Manage the I/O redirection from SHell
36 rm -f $fifo && mkfifo $fifo
37 # Attach a file descriptor
38 exec 3<> $fifo
39 # Notification icon
40 yad --notification --listen --image=$icon \
41 --text="$(eval_gettext 'Checking packages lists - $text')" <&3
42 # Clean-up
43 rm -f $fifo
44 }
46 # Notication menu (right click)
47 menu() {
48 cat << EOT
49 menu:\
50 $(gettext "My packages")!tazweb $panel?list!tazpkg|\
51 $(gettext "Recharge lists")!tazweb $panel?recharge!tazpkg-up|\
52 $(gettext "Check upgrade")!tazweb $panel?up!tazpkg-up|\
53 $(gettext "TazPkg SHell")!terminal -e tazpkg shell!xterm|\
54 $(gettext "TazPkg manual")!tazweb $doc!text-html|\
55 $(gettext "Close notification")!quit!gtk-close
56 EOT
57 }
59 case $1 in
60 usage|help|*-h)
61 gettext "Usage:"; echo " $(basename $0)" ;;
62 *)
63 # Sleep before displaying the notification icon and
64 # sleep to let user read the tooltips.
65 sleep 4
66 listen &
67 sleep 2
68 menu > $fifo
69 sleep 6
70 # Missing packages list
71 if [ ! -f $db/packages.list ]; then
72 tooltip=$(eval_gettext 'No packages list found - $text')
73 echo "action:tazweb $panel?recharge" > $fifo
74 echo "tooltip:$tooltip" > $fifo
75 echo "icon:tazpkg-up" > $fifo && exit 0
76 fi
77 # Too old packages list
78 if [ "$mtime" ]; then
79 tooltip=$(gettext "Your packages list is older than 10 days")
80 echo "action:tazweb $panel?recharge" > $fifo
81 echo "tooltip:$tooltip" > $fifo
82 echo "icon:tazpkg-up" > $fifo && exit 0
83 fi
84 # Available upgrades
85 if [ "$up" -gt 0 ]; then
86 num="<b>$up</b>"
87 tooltip=$(eval_ngettext \
88 'There is $num upgradeable package' \
89 'There are $num upgradeable packages' $up)
90 echo "action:tazweb $panel?up" > $fifo
91 echo "tooltip:$tooltip" > $fifo
92 echo "icon:tazpkg-up" > $fifo && exit 0
93 fi
94 # Nothing to do, close notification
95 tooltip=$(eval_gettext 'System is up to date - $text')
96 echo "tooltip:$tooltip" > $fifo
97 sleep 10
98 echo "quit" > $fifo ;;
99 esac
100 exit 0