tazpkg diff tazpkg-notify @ rev 712

tazpkg: backup "official" configuration files with "--newconf" anyway.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon Dec 15 04:33:27 2014 +0200 (2014-12-15)
parents 1ab24812ad7e
children 0bda827841cd
line diff
     1.1 --- a/tazpkg-notify	Sat Dec 13 16:31:09 2014 +0200
     1.2 +++ b/tazpkg-notify	Mon Dec 15 04:33:27 2014 +0200
     1.3 @@ -12,35 +12,45 @@
     1.4  # Authors : Christophe Lincoln <pankso@slitaz.org>
     1.5  #
     1.6  
     1.7 +. /lib/libtaz.sh
     1.8 +. /etc/slitaz/slitaz.conf
     1.9 +
    1.10  # I18n
    1.11 -. /lib/libtaz.sh
    1.12  export TEXTDOMAIN='tazpkg'
    1.13 +_()  { local T="$1"; shift; printf "$(gettext "$T")" "$@"; echo; }
    1.14 +_n() { local T="$1"; shift; printf "$(gettext "$T")" "$@"; }
    1.15 +_p() {
    1.16 +	local S="$1" P="$2" N="$3"; shift; shift; shift;
    1.17 +	printf "$(ngettext "$S" "$P" "$N")" "$@"; }
    1.18 +
    1.19  
    1.20  fifo=/tmp/$(basename $0).fifo
    1.21  panel="http://tazpanel:82/pkgs.cgi"
    1.22 -db="/var/lib/tazpkg"
    1.23  doc="file:///usr/share/doc/tazpkg/tazpkg.html"
    1.24  
    1.25 -installed=$(ls $db/installed | wc -l)
    1.26 +installed=$(wc -l < $PKGS_DB/installed.info)
    1.27  text="$(_p \
    1.28  		'%s installed package' \
    1.29  		'%s installed packages' $installed \
    1.30  		"<b>$installed</b>")"
    1.31 -icon="/usr/share/pixmaps/tazpkg.png"
    1.32 -[ -f "$db/packages.list" ] && mtime=$(find $db/packages.list -mtime +10;)
    1.33 -[ -f "$db/packages.up" ] && up=$(cat $db/packages.up | wc -l)
    1.34 +
    1.35 +[ -f "$PKGS_DB/packages.list" ] && mtime=$(find $PKGS_DB/packages.list -mtime +10;)
    1.36 +up=0; [ -f "$PKGS_DB/packages.up" ] && up=$(cat $PKGS_DB/packages.up | wc -l)
    1.37  
    1.38  
    1.39  # Notification icon
    1.40  
    1.41  listen() {
    1.42  	# Manage the I/O redirection from SHell
    1.43 -	rm -f $fifo && mkfifo $fifo
    1.44 +	rm -f $fifo; mkfifo $fifo
    1.45 +
    1.46  	# Attach a file descriptor
    1.47  	exec 3<> $fifo
    1.48 +
    1.49  	# Notification icon
    1.50 -	yad --notification --listen --image=$icon \
    1.51 -		--text="$(_ 'Checking packages lists - %s' $text)" <&3
    1.52 +	yad --notification --listen --image='TazPkg' \
    1.53 +		--text="$(_ 'Checking packages lists - %s' "$text")" <&3
    1.54 +
    1.55  	# Clean-up
    1.56  	rm -f $fifo
    1.57  }
    1.58 @@ -51,19 +61,19 @@
    1.59  menu() {
    1.60  	cat << EOT
    1.61  menu:\
    1.62 -$(_ 'My packages'       )!tazweb $panel?list!tazpkg|\
    1.63 -$(_ 'Recharge lists'    )!tazweb $panel?recharge!tazpkg-up|\
    1.64 -$(_ 'Check upgrade'     )!tazweb $panel?up!tazpkg-up|\
    1.65 -$(_ 'TazPkg SHell'      )!terminal -e tazpkg shell!xterm|\
    1.66 -$(_ 'TazPkg manual'     )!tazweb $doc!text-html|\
    1.67 -$(_ 'Close notification')!quit!gtk-close
    1.68 +$(_n 'My packages'       )!tazweb $panel?list!TazPkg|\
    1.69 +$(_n 'Recharge lists'    )!tazweb $panel?recharge!tazpkg-up|\
    1.70 +$(_n 'Check upgrade'     )!tazweb $panel?up!tazpkg-up|\
    1.71 +$(_n 'TazPkg SHell'      )!terminal -e tazpkg shell!utilities-terminal|\
    1.72 +$(_n 'TazPkg manual'     )!tazweb $doc!slitaz-doc|\
    1.73 +$(_n 'Close notification')!quit!gtk-close
    1.74  EOT
    1.75  }
    1.76  
    1.77  
    1.78  case $1 in
    1.79  	usage|help|*-h)
    1.80 -		_ "Usage:"; echo " $(basename $0)"
    1.81 +		_n "Usage:"; echo " $(basename $0)"
    1.82  		;;
    1.83  	*)
    1.84  		# Sleep before displaying the notification icon and
    1.85 @@ -73,35 +83,39 @@
    1.86  		sleep 2
    1.87  		menu > $fifo
    1.88  		sleep 6
    1.89 +
    1.90  		# Missing packages list
    1.91 -		if [ ! -f $db/packages.list ]; then
    1.92 -			tooltip="$(_ 'No packages list found - %s' $text)"
    1.93 -			echo "action:tazweb $panel?recharge" > $fifo
    1.94 -			echo "tooltip:$tooltip" > $fifo
    1.95 -			echo "icon:tazpkg-up" > $fifo
    1.96 +		if [ ! -f $PKGS_DB/packages.list ]; then
    1.97 +			tooltip="$(_ 'No packages list found - %s' "$text")"
    1.98 +			(echo "action:tazweb $panel?recharge"
    1.99 +			 echo "tooltip:$tooltip"
   1.100 +			 echo "icon:tazpkg-up") > $fifo
   1.101  			exit 0
   1.102  		fi
   1.103 +
   1.104  		# Too old packages list
   1.105  		if [ "$mtime" ]; then
   1.106  			tooltip="$(_ 'Your packages list is older than 10 days')"
   1.107 -			echo "action:tazweb $panel?recharge" > $fifo
   1.108 -			echo "tooltip:$tooltip" > $fifo
   1.109 -			echo "icon:tazpkg-up" > $fifo
   1.110 +			(echo "action:tazweb $panel?recharge"
   1.111 +			 echo "tooltip:$tooltip"
   1.112 +			 echo "icon:tazpkg-up") > $fifo
   1.113  			exit 0
   1.114  		fi
   1.115 +
   1.116  		# Available upgrades
   1.117  		if [ "$up" -gt 0 ]; then
   1.118  			tooltip="$(_p \
   1.119  				'There is %s upgradeable package' \
   1.120  				'There are %s upgradeable packages' $up \
   1.121  				"<b>$up</b>")"
   1.122 -			echo "action:tazweb $panel?up" > $fifo
   1.123 -			echo "tooltip:$tooltip" > $fifo
   1.124 -			echo "icon:tazpkg-up" > $fifo
   1.125 +			(echo "action:tazweb $panel?up"
   1.126 +			 echo "tooltip:$tooltip"
   1.127 +			 echo "icon:tazpkg-up") > $fifo
   1.128  			exit 0
   1.129  		fi
   1.130 +
   1.131  		# Nothing to do, close notification
   1.132 -		tooltip="$(_ 'System is up to date - %s' $text)"
   1.133 +		tooltip="$(_ 'System is up to date - %s' "$text")"
   1.134  		echo "tooltip:$tooltip" > $fifo
   1.135  		sleep 10
   1.136  		echo "quit" > $fifo