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