tazpkg diff tazpkg-notify @ rev 455
Fix VERSION again (why some beta tags ? and why missing archive on mirror ?)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Apr 06 01:33:21 2011 +0200 (2011-04-06) |
parents | |
children | 7e0df4f72628 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tazpkg-notify Wed Apr 06 01:33:21 2011 +0200 1.3 @@ -0,0 +1,197 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# TazPKG Notify - Notification icon for Tazpkg packages. Recharging pkgs 1.7 +# list can be done automatically at boot, so notify user if some 1.8 +# update are available. Also notify user if the packages list is too 1.9 +# old and out-of-date or if no packages list found. This script should 1.10 +# be run ny the WM autostart script or ~/.xsession and need a systray to 1.11 +# site in like in LXpanel or Tint2. 1.12 +# 1.13 +# Copyright (C) 2011 SliTaz GNU/Linux - GNU gpl v2 1.14 +# 1.15 +# Authors : Christophe Lincoln <pankso@slitaz.org> 1.16 +# 1.17 + 1.18 +. /etc/slitaz/tazpkg.conf 1.19 +LOCALSTATE="/var/lib/tazpkg" 1.20 + 1.21 +# Include gettext helper script. 1.22 +. /usr/bin/gettext.sh 1.23 + 1.24 +# Export package name for gettext. 1.25 +TEXTDOMAIN='tazpkg-notify' 1.26 +export TEXTDOMAIN 1.27 + 1.28 +up=`cat $LOCALSTATE/upgradeable-packages.list | wc -l` 1.29 +rel=`cat /etc/slitaz-release` 1.30 + 1.31 +# Kill the notification icon after user pressed on it. 1.32 +kill_notification() { 1.33 + for p in `ps | grep "yad --notification" | awk '{print $1}'` 1.34 + do 1.35 + kill -9 $p 2>/dev/null 1.36 + done 1.37 +} 1.38 + 1.39 +# Message for upgradeable 1.40 +upgradeable_msg() { 1.41 + eval_gettext "<b>There is \$up upgradeable packages for your SliTaz \$ver</b> 1.42 +You should upgrade your system to get all latest fixes 1.43 +and improvments from SliTaz contributors" 1.44 +} 1.45 + 1.46 +# Message for list older than 10 days 1.47 +old_list_msg() { 1.48 + eval_gettext "<b>Your SliTaz \$ver packages list is older than 10 days.</b> 1.49 +You should recharge the list to check for updates" 1.50 +} 1.51 + 1.52 +# Message if packages.list is missing 1.53 +no_list_msg() { 1.54 + eval_gettext "<b>No packages list found on your SliTaz \$rel system.</b> 1.55 +You will need to recharge the list of mirrored packages 1.56 +if you want to install packages or upgrade your system" 1.57 +} 1.58 + 1.59 +# 1.60 +# Main GUI box for upgradeable packages 1.61 +# 1.62 +upgradeable_main() { 1.63 + yad --text --width=400 \ 1.64 + --geometry="$NOTIFY_GEOM" \ 1.65 + --undecorated \ 1.66 + --title="TazPKG Notification" \ 1.67 + --image="tazpkg" \ 1.68 + --image-on-top \ 1.69 + --on-top \ 1.70 + --text="`upgradeable_msg`" \ 1.71 + --button="`gettext \"Upgrade:2\"`" \ 1.72 + --button="gtk-close:1" 1.73 +} 1.74 + 1.75 +# Notification icon for upgradeable packages 1.76 +upgradeable_notify() { 1.77 + yad --notification \ 1.78 + --image=tazpkg \ 1.79 + --text="`upgradeable_msg`" \ 1.80 + --command="tazpkg-notify upgrade" 1.81 +} 1.82 + 1.83 +# Main upgradeable function 1.84 +upgradeable() { 1.85 + # Store box results 1.86 + main=`upgradeable_main` 1.87 + ret=$? 1.88 + kill_notification 1.89 + # Deal with --button values 1.90 + case $ret in 1.91 + 1) exit 0 ;; 1.92 + #tazweb http://tazpanel:8090/pkgs.cgi?upgradeable & 1.93 + 2) subox tazpkgbox & ;; 1.94 + *) continue ;; 1.95 + esac 1.96 +} 1.97 + 1.98 +# 1.99 +# Main GUI box for missing packages.list 1.100 +# 1.101 +old_list_main() { 1.102 + yad --text --width=400 \ 1.103 + --geometry="$NOTIFY_GEOM" \ 1.104 + --undecorated \ 1.105 + --title "TazPKG Notification" \ 1.106 + --image="tazpkg" \ 1.107 + --image-on-top \ 1.108 + --on-top \ 1.109 + --text "`old_list_msg`" \ 1.110 + --button="`gettext \"Recharge now:2\"`" \ 1.111 + --button="gtk-close:1" 1.112 +} 1.113 + 1.114 +# Notification icon if no packages.list 1.115 +old_list_notify() { 1.116 + yad --notification \ 1.117 + --image=tazpkg \ 1.118 + --text="`old_list_msg`" \ 1.119 + --command="tazpkg-notify no-list" 1.120 +} 1.121 + 1.122 +# Main missing packages.list function 1.123 +old_list() { 1.124 + # Store box results 1.125 + main=`old_list_main` 1.126 + ret=$? 1.127 + kill_notification 1.128 + # Deal with --button values 1.129 + case $ret in 1.130 + 1) exit 0 ;; 1.131 + # tazweb http://tazpanel:8090/pkgs.cgi?recharge & 1.132 + 2) subox tazpkgbox & ;; 1.133 + *) continue ;; 1.134 + esac 1.135 +} 1.136 + 1.137 +# 1.138 +# Main GUI box for missing packages.list 1.139 +# 1.140 +no_list_main() { 1.141 + yad --text --width=400 \ 1.142 + --geometry="$NOTIFY_GEOM" \ 1.143 + --undecorated \ 1.144 + --show-uri \ 1.145 + --title="TazPKG Notification" \ 1.146 + --image="tazpkg" \ 1.147 + --image-on-top \ 1.148 + --on-top \ 1.149 + --text "`no_list_msg`" \ 1.150 + --button="`gettext \"Recharge now:2\"`" \ 1.151 + --button="gtk-close:1" 1.152 +} 1.153 + 1.154 +# Notification icon if no packages.list 1.155 +no_list_notify() { 1.156 + yad --notification \ 1.157 + --image=tazpkg \ 1.158 + --text="`no_list_msg`" \ 1.159 + --command="tazpkg-notify no-list" 1.160 +} 1.161 + 1.162 +# Main missing packages.list function 1.163 +no_list() { 1.164 + # Store box results 1.165 + main=`no_list_main` 1.166 + ret=$? 1.167 + kill_notification 1.168 + # Deal with --button values 1.169 + case $ret in 1.170 + 1) exit 0 ;; 1.171 + # tazweb http://tazpanel:8090/pkgs.cgi?recharge & 1.172 + 2) subox tazpkgbox & ;; 1.173 + *) continue ;; 1.174 + esac 1.175 +} 1.176 + 1.177 +# 1.178 +# Script commands 1.179 +# 1.180 + 1.181 +case $1 in 1.182 + upgrade) 1.183 + upgradeable ;; 1.184 + old-list) 1.185 + old_list ;; 1.186 + no-list) 1.187 + no_list ;; 1.188 + *) 1.189 + # Sleep first to let tazpkg upgrade on boot finish. Check if 1.190 + # any upgrade, then for an old list and then if any list at all 1.191 + # (live or first boot) 1.192 + #sleep 15 1.193 + [ "$up" -gt 0 ] && upgradeable_notify && exit 0 1.194 + mtime=`find /var/lib/tazpkg/packages.list -mtime +10;` 1.195 + [ "$mtime" ] && old_list_notify && exit 0 1.196 + [ ! -f $LOCALSTATE/packages.list ] && no_list_notify \ 1.197 + && exit 0 ;; 1.198 +esac 1.199 + 1.200 +exit 0