tazpkg view tazpkg-notify @ rev 468
Update tazpkg xhtml-list to look better...
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Apr 08 15:19:52 2011 +0200 (2011-04-08) |
parents | |
children | 7e0df4f72628 |
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 notify user if some
5 # update are available. Also notify user if the packages list is too
6 # old and out-of-date or if no packages list found. This script should
7 # be run ny the WM autostart script or ~/.xsession and need a systray to
8 # site in like in LXpanel or Tint2.
9 #
10 # Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v2
11 #
12 # Authors : Christophe Lincoln <pankso@slitaz.org>
13 #
15 . /etc/slitaz/tazpkg.conf
16 LOCALSTATE="/var/lib/tazpkg"
18 # Include gettext helper script.
19 . /usr/bin/gettext.sh
21 # Export package name for gettext.
22 TEXTDOMAIN='tazpkg-notify'
23 export TEXTDOMAIN
25 up=`cat $LOCALSTATE/upgradeable-packages.list | wc -l`
26 rel=`cat /etc/slitaz-release`
28 # Kill the notification icon after user pressed on it.
29 kill_notification() {
30 for p in `ps | grep "yad --notification" | awk '{print $1}'`
31 do
32 kill -9 $p 2>/dev/null
33 done
34 }
36 # Message for upgradeable
37 upgradeable_msg() {
38 eval_gettext "<b>There is \$up upgradeable packages for your SliTaz \$ver</b>
39 You should upgrade your system to get all latest fixes
40 and improvments from SliTaz contributors"
41 }
43 # Message for list older than 10 days
44 old_list_msg() {
45 eval_gettext "<b>Your SliTaz \$ver packages list is older than 10 days.</b>
46 You should recharge the list to check for updates"
47 }
49 # Message if packages.list is missing
50 no_list_msg() {
51 eval_gettext "<b>No packages list found on your SliTaz \$rel system.</b>
52 You will need to recharge the list of mirrored packages
53 if you want to install packages or upgrade your system"
54 }
56 #
57 # Main GUI box for upgradeable packages
58 #
59 upgradeable_main() {
60 yad --text --width=400 \
61 --geometry="$NOTIFY_GEOM" \
62 --undecorated \
63 --title="TazPKG Notification" \
64 --image="tazpkg" \
65 --image-on-top \
66 --on-top \
67 --text="`upgradeable_msg`" \
68 --button="`gettext \"Upgrade:2\"`" \
69 --button="gtk-close:1"
70 }
72 # Notification icon for upgradeable packages
73 upgradeable_notify() {
74 yad --notification \
75 --image=tazpkg \
76 --text="`upgradeable_msg`" \
77 --command="tazpkg-notify upgrade"
78 }
80 # Main upgradeable function
81 upgradeable() {
82 # Store box results
83 main=`upgradeable_main`
84 ret=$?
85 kill_notification
86 # Deal with --button values
87 case $ret in
88 1) exit 0 ;;
89 #tazweb http://tazpanel:8090/pkgs.cgi?upgradeable &
90 2) subox tazpkgbox & ;;
91 *) continue ;;
92 esac
93 }
95 #
96 # Main GUI box for missing packages.list
97 #
98 old_list_main() {
99 yad --text --width=400 \
100 --geometry="$NOTIFY_GEOM" \
101 --undecorated \
102 --title "TazPKG Notification" \
103 --image="tazpkg" \
104 --image-on-top \
105 --on-top \
106 --text "`old_list_msg`" \
107 --button="`gettext \"Recharge now:2\"`" \
108 --button="gtk-close:1"
109 }
111 # Notification icon if no packages.list
112 old_list_notify() {
113 yad --notification \
114 --image=tazpkg \
115 --text="`old_list_msg`" \
116 --command="tazpkg-notify no-list"
117 }
119 # Main missing packages.list function
120 old_list() {
121 # Store box results
122 main=`old_list_main`
123 ret=$?
124 kill_notification
125 # Deal with --button values
126 case $ret in
127 1) exit 0 ;;
128 # tazweb http://tazpanel:8090/pkgs.cgi?recharge &
129 2) subox tazpkgbox & ;;
130 *) continue ;;
131 esac
132 }
134 #
135 # Main GUI box for missing packages.list
136 #
137 no_list_main() {
138 yad --text --width=400 \
139 --geometry="$NOTIFY_GEOM" \
140 --undecorated \
141 --show-uri \
142 --title="TazPKG Notification" \
143 --image="tazpkg" \
144 --image-on-top \
145 --on-top \
146 --text "`no_list_msg`" \
147 --button="`gettext \"Recharge now:2\"`" \
148 --button="gtk-close:1"
149 }
151 # Notification icon if no packages.list
152 no_list_notify() {
153 yad --notification \
154 --image=tazpkg \
155 --text="`no_list_msg`" \
156 --command="tazpkg-notify no-list"
157 }
159 # Main missing packages.list function
160 no_list() {
161 # Store box results
162 main=`no_list_main`
163 ret=$?
164 kill_notification
165 # Deal with --button values
166 case $ret in
167 1) exit 0 ;;
168 # tazweb http://tazpanel:8090/pkgs.cgi?recharge &
169 2) subox tazpkgbox & ;;
170 *) continue ;;
171 esac
172 }
174 #
175 # Script commands
176 #
178 case $1 in
179 upgrade)
180 upgradeable ;;
181 old-list)
182 old_list ;;
183 no-list)
184 no_list ;;
185 *)
186 # Sleep first to let tazpkg upgrade on boot finish. Check if
187 # any upgrade, then for an old list and then if any list at all
188 # (live or first boot)
189 #sleep 15
190 [ "$up" -gt 0 ] && upgradeable_notify && exit 0
191 mtime=`find /var/lib/tazpkg/packages.list -mtime +10;`
192 [ "$mtime" ] && old_list_notify && exit 0
193 [ ! -f $LOCALSTATE/packages.list ] && no_list_notify \
194 && exit 0 ;;
195 esac
197 exit 0