tazpkg annotate tazpkg-notify @ rev 543
tazpkg-box: Use terminal to extract or install
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Feb 29 20:25:51 2012 +0100 (2012-02-29) |
parents | 9bf228335345 |
children | b52c1a1105e2 |
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@542 | 10 # Copyright (C) 2012 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@505 | 25 up=$(cat $LOCALSTATE/packages.up | wc -l) |
pankso@505 | 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@505 | 89 2) tazweb http://tazpanel:82/pkgs.cgi?up & ;; |
pankso@451 | 90 *) continue ;; |
pankso@451 | 91 esac |
pankso@451 | 92 } |
pankso@451 | 93 |
pankso@451 | 94 # |
pankso@451 | 95 # Main GUI box for missing packages.list |
pankso@451 | 96 # |
pankso@451 | 97 old_list_main() { |
pankso@451 | 98 yad --text --width=400 \ |
pankso@451 | 99 --geometry="$NOTIFY_GEOM" \ |
pankso@451 | 100 --undecorated \ |
pankso@451 | 101 --title "TazPKG Notification" \ |
pankso@479 | 102 --image="tazpkg-up" \ |
pankso@451 | 103 --image-on-top \ |
pankso@451 | 104 --on-top \ |
pankso@451 | 105 --text "`old_list_msg`" \ |
pankso@451 | 106 --button="`gettext \"Recharge now:2\"`" \ |
pankso@451 | 107 --button="gtk-close:1" |
pankso@451 | 108 } |
pankso@451 | 109 |
pankso@451 | 110 # Notification icon if no packages.list |
pankso@451 | 111 old_list_notify() { |
pankso@451 | 112 yad --notification \ |
pankso@451 | 113 --image=tazpkg \ |
pankso@451 | 114 --text="`old_list_msg`" \ |
pankso@451 | 115 --command="tazpkg-notify no-list" |
pankso@451 | 116 } |
pankso@451 | 117 |
pankso@451 | 118 # Main missing packages.list function |
pankso@451 | 119 old_list() { |
pankso@451 | 120 # Store box results |
pankso@505 | 121 main=$(old_list_main) |
pankso@451 | 122 ret=$? |
pankso@451 | 123 kill_notification |
pankso@451 | 124 # Deal with --button values |
pankso@451 | 125 case $ret in |
pankso@451 | 126 1) exit 0 ;; |
pankso@505 | 127 2) tazweb http://tazpanel:82/pkgs.cgi?recharge & ;; |
pankso@451 | 128 *) continue ;; |
pankso@451 | 129 esac |
pankso@451 | 130 } |
pankso@451 | 131 |
pankso@451 | 132 # |
pankso@451 | 133 # Main GUI box for missing packages.list |
pankso@451 | 134 # |
pankso@451 | 135 no_list_main() { |
pankso@451 | 136 yad --text --width=400 \ |
pankso@451 | 137 --geometry="$NOTIFY_GEOM" \ |
pankso@451 | 138 --undecorated \ |
pankso@451 | 139 --show-uri \ |
pankso@451 | 140 --title="TazPKG Notification" \ |
pankso@479 | 141 --image="tazpkg-up" \ |
pankso@451 | 142 --image-on-top \ |
pankso@451 | 143 --on-top \ |
pankso@451 | 144 --text "`no_list_msg`" \ |
pankso@451 | 145 --button="`gettext \"Recharge now:2\"`" \ |
pankso@451 | 146 --button="gtk-close:1" |
pankso@451 | 147 } |
pankso@451 | 148 |
pankso@451 | 149 # Notification icon if no packages.list |
pankso@451 | 150 no_list_notify() { |
pankso@451 | 151 yad --notification \ |
pankso@451 | 152 --image=tazpkg \ |
pankso@451 | 153 --text="`no_list_msg`" \ |
pankso@451 | 154 --command="tazpkg-notify no-list" |
pankso@451 | 155 } |
pankso@451 | 156 |
pankso@451 | 157 # Main missing packages.list function |
pankso@451 | 158 no_list() { |
pankso@451 | 159 # Store box results |
pankso@505 | 160 main=$(no_list_main) |
pankso@451 | 161 ret=$? |
pankso@451 | 162 kill_notification |
pankso@451 | 163 # Deal with --button values |
pankso@451 | 164 case $ret in |
pankso@451 | 165 1) exit 0 ;; |
pankso@505 | 166 2) tazweb http://tazpanel:82/pkgs.cgi?recharge & ;; |
pankso@451 | 167 *) continue ;; |
pankso@451 | 168 esac |
pankso@451 | 169 } |
pankso@451 | 170 |
pankso@451 | 171 # |
pankso@451 | 172 # Script commands |
pankso@451 | 173 # |
pankso@451 | 174 |
pankso@451 | 175 case $1 in |
pankso@451 | 176 upgrade) |
pankso@471 | 177 up ;; |
pankso@451 | 178 old-list) |
pankso@451 | 179 old_list ;; |
pankso@451 | 180 no-list) |
pankso@451 | 181 no_list ;; |
pankso@451 | 182 *) |
pankso@451 | 183 # Sleep first to let tazpkg upgrade on boot finish. Check if |
paul@477 | 184 # any upgrades, then for an old list and then if any lists at all |
pankso@451 | 185 # (live or first boot) |
pankso@471 | 186 sleep 10 |
pankso@471 | 187 [ "$up" -gt 0 ] && up_notify && exit 0 |
pankso@505 | 188 mtime=$(find /var/lib/tazpkg/packages.list -mtime +10;) |
pankso@451 | 189 [ "$mtime" ] && old_list_notify && exit 0 |
pankso@451 | 190 [ ! -f $LOCALSTATE/packages.list ] && no_list_notify \ |
pankso@451 | 191 && exit 0 ;; |
pankso@451 | 192 esac |
pankso@451 | 193 |
pankso@451 | 194 exit 0 |