tazpkg view tazpkg-notify @ rev 846
Remove "busybox" "prefixes" (thanks llev)
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Oct 09 13:14:01 2015 +0300 (2015-10-09) |
parents | 636b4e8dcf6a |
children | 21ac83abe572 |
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # tazpkg-notify - part of TazPkg
4 # Notification icon for TazPkg packages
6 # Recharging pkgs list can be done automatically at boot, so notifies users
7 # if some updates are available. Also notifies users if the packages list is too
8 # old and out-of-date or if no packages list found. This script should
9 # be run by the WM autostart script or ~/.xsession and needs a systray to
10 # sit in like in LXpanel or Tint2.
12 # Copyright (C) 2012-2015 SliTaz - GNU General Public License v3.
13 # Authors: See the AUTHORS files
16 . /lib/libtaz.sh
17 . /etc/slitaz/slitaz.conf
19 # I18n
20 export TEXTDOMAIN='tazpkg'
22 fifo=/tmp/$(basename $0).fifo
23 doc="file:///usr/share/doc/tazpkg/tazpkg.html"
25 installed=$(wc -l < "$PKGS_DB/installed.info")
26 text="$(_p \
27 '%s installed package' \
28 '%s installed packages' "$installed" \
29 "<b>$installed</b>")"
31 [ -f "$PKGS_DB/IDs" ] && mtime=$(find "$PKGS_DB/IDs" -mtime +10;)
32 up=0; [ -f "$PKGS_DB/packages.up" ] && up=$(wc -l < "$PKGS_DB/packages.up")
35 # Notification icon
37 listen() {
38 # Manage the I/O redirection from SHell
39 rm -f $fifo; mkfifo $fifo
41 # Attach a file descriptor
42 exec 3<> $fifo
44 # Notification icon
45 yad --notification --listen --image='TazPkg' \
46 --text="$(_ 'Checking packages lists - %s' "$text")" <&3
48 # Clean-up
49 rm -f $fifo
50 }
53 # Notification menu (right click)
55 menu() {
56 cat << EOT
57 menu:\
58 $(_n 'My packages' )!tazpanel pkgs#list!TazPkg|\
59 $(_n 'Recharge lists' )!tazbox su tazpanel pkgs#recharge!tazpkg-up|\
60 $(_n 'Check upgrade' )!tazbox su tazpanel pkgs#up!tazpkg-up|\
61 $(_n 'TazPkg SHell' )!terminal -e tazpkg shell!utilities-terminal|\
62 $(_n 'TazPkg manual' )!tazweb --notoolbar $doc!slitaz-doc|\
63 $(_n 'Close notification')!quit!gtk-close
64 EOT
65 }
68 case $1 in
69 usage|help|*-h)
70 _n "Usage:"; echo " $(basename $0)"
71 ;;
72 *)
73 # Sleep before displaying the notification icon and
74 # sleep to let user read the tooltips.
75 sleep 4
76 listen &
77 sleep 2
78 menu > $fifo
79 sleep 6
81 # Missing packages list
82 if [ ! -f "$PKGS_DB/packages.info" ]; then
83 tooltip="$(_ 'No packages list found - %s' "$text")"
84 (echo "action:tazbox su tazpanel pkgs#recharge"
85 echo "tooltip:$tooltip"
86 echo "icon:tazpkg-up") > $fifo
87 exit 0
88 fi
90 # Too old packages list
91 if [ -n "$mtime" ]; then
92 tooltip="$(_ 'Your packages list is older than 10 days')"
93 (echo "action:tazbox su tazpanel pkgs#recharge"
94 echo "action:quit"
95 echo "tooltip:$tooltip"
96 echo "icon:tazpkg-up") > $fifo
97 exit 0
98 fi
100 # Available upgrades
101 if [ "$up" -gt 0 ]; then
102 tooltip="$(_p \
103 'There is %s upgradeable package' \
104 'There are %s upgradeable packages' "$up" \
105 "<b>$up</b>")"
106 (echo "action:tazbox su tazpanel pkgs#up"
107 echo "tooltip:$tooltip"
108 echo "icon:tazpkg-up") > $fifo
109 exit 0
110 fi
112 # Nothing to do, close notification
113 tooltip="$(_ 'System is up to date - %s' "$text")"
114 echo "tooltip:$tooltip" > $fifo
115 sleep 10
116 echo "quit" > $fifo
117 ;;
118 esac
119 exit 0