tazpkg diff tazpkg-notify @ rev 893

repack-config: add boot/cmdline
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Dec 19 14:09:22 2015 +0100 (2015-12-19)
parents 21ac83abe572
children 54ebb19d4cc6
line diff
     1.1 --- a/tazpkg-notify	Mon Nov 09 04:54:02 2015 +0200
     1.2 +++ b/tazpkg-notify	Sat Dec 19 14:09:22 2015 +0100
     1.3 @@ -21,6 +21,7 @@
     1.4  
     1.5  fifo=/tmp/$(basename $0).fifo
     1.6  doc="file:///usr/share/doc/tazpkg/tazpkg.html"
     1.7 +tp='http://127.0.0.1:82/user/pkgs.cgi'
     1.8  
     1.9  installed=$(wc -l < "$PKGS_DB/installed.info")
    1.10  text="$(_p \
    1.11 @@ -32,6 +33,19 @@
    1.12  up=0; [ -f "$PKGS_DB/packages.up" ] && up=$(wc -l < "$PKGS_DB/packages.up")
    1.13  
    1.14  
    1.15 +# Standard notification, if available
    1.16 +
    1.17 +notify() {
    1.18 +	if [ -n "$(which notify-send)" ]; then
    1.19 +		case $2 in
    1.20 +			info) icon='dialog-information'; urgency='normal';;
    1.21 +			*)    icon='dialog-warning';     urgency='critical';;
    1.22 +		esac
    1.23 +		notify-send -i $icon -u $urgency 'TazPkg' "$1" &
    1.24 +	fi
    1.25 +}
    1.26 +
    1.27 +
    1.28  # Notification icon
    1.29  
    1.30  listen() {
    1.31 @@ -42,8 +56,9 @@
    1.32  	exec 3<> $fifo
    1.33  
    1.34  	# Notification icon
    1.35 -	yad --notification --listen --image='software-update-available' \
    1.36 -		--text="$(_ 'Checking packages lists - %s' "$text")" <&3
    1.37 +	tooltip="$(_ 'Checking packages lists - %s' "$text")"
    1.38 +	notify "$tooltip" 'info' &
    1.39 +	yad --notification --listen --image='software-update-available' --text="$tooltip" <&3
    1.40  
    1.41  	# Clean-up
    1.42  	rm -f $fifo
    1.43 @@ -81,6 +96,7 @@
    1.44  		# Missing packages list
    1.45  		if [ ! -f "$PKGS_DB/packages.info" ]; then
    1.46  			tooltip="$(_ 'No packages list found - %s' "$text")"
    1.47 +			notify "$tooltip\n<a href=\"$tp?recharge\">$(_n 'Recharge lists')</a>" &
    1.48  			(echo "action:tazbox su tazpanel pkgs#recharge"
    1.49  			 echo "tooltip:$tooltip"
    1.50  			 echo "icon:software-update-urgent") > $fifo
    1.51 @@ -90,6 +106,7 @@
    1.52  		# Too old packages list
    1.53  		if [ -n "$mtime" ]; then
    1.54  			tooltip="$(_ 'Your packages list is older than 10 days')"
    1.55 +			notify "$tooltip\n<a href=\"$tp?recharge\">$(_n 'Recharge lists')</a>" &
    1.56  			(echo "action:tazbox su tazpanel pkgs#recharge"
    1.57  			 echo "action:quit"
    1.58  			 echo "tooltip:$tooltip"
    1.59 @@ -103,6 +120,7 @@
    1.60  				'There is %s upgradeable package' \
    1.61  				'There are %s upgradeable packages' "$up" \
    1.62  				"<b>$up</b>")"
    1.63 +			notify "$tooltip\n<a href=\"$tp?up\">$(_n 'Check upgrade')</a>" &
    1.64  			(echo "action:tazbox su tazpanel pkgs#up"
    1.65  			 echo "tooltip:$tooltip"
    1.66  			 echo "icon:software-update-urgent") > $fifo
    1.67 @@ -111,6 +129,7 @@
    1.68  
    1.69  		# Nothing to do, close notification
    1.70  		tooltip="$(_ 'System is up to date - %s' "$text")"
    1.71 +		notify "$tooltip" 'info' &
    1.72  		echo "tooltip:$tooltip" > $fifo
    1.73  		sleep 10
    1.74  		echo "quit" > $fifo