2 #BANNER#######################################
4 ____ ____ __ _ _ _ __ __ _
5 (__ )( __)( ( \( \/ ) / _\ ( ( \
6 / _/ ) _) / // \/ \/ \/ /
7 (____)(____)\_)__)\_)(_/\_/\_/\_)__) v1.8
9 Zenity based frontend for pacman
10 <~Harvie (http://blog.harvie.cz)
15 #HELP/FEATURES################################
16 if [ "$1" == '--help' ]; then
19 - note this script is not much secure since it uses gksu to execute user defined scripts
20 - this is not good idea for server, but it should be OK for personal workstation
21 - root rights can be obtained by gksu anyway
22 - to defeat this risk please do not use 'remember password' in gksu
23 - zenman --help prints this help
24 - when zenman started, kills last zenman runned by this user
25 - you can kill zenman by zenman --stop (click on tray icon or wait after this)
26 - last pid is stored in ~/.config/zenman/zenman.pid
27 - shows splashscreen (can be disabled...)
28 - shows tray icon for each state (on mouse over shows state)
29 - system is up to date
30 - refreshing pacman database
32 - shows notification when updates available and listing them
33 - optionally can notify also using speech output
34 - clicking on icon will begin upgrade in new xterm
35 - this is disabled only when refreshing
36 - if pacman db is locked it will be automaticaly unlocked
37 - only if there is any pacman related process running
38 - if there is some pacman related operation, error message appears
39 - auto refreshing of pacman db is disabled (somebody will want to use cron)
40 - all settings are hardcoded to zenman (/usr/bin/zenman)
41 - all settings can be overrided
42 - system wide: /etc/zenman.conf
43 - single user only: ~/.config/zenman/zenman.conf
44 - you can also write your own translation to this files
47 ( Don't shy and get involved! ;o)
48 - Bugtracking/Bugfixing
49 - Port to another package managers
54 - Localization to your native language
59 #SETTINGS#####################################
60 #main#############################
61 zenman_caption
='ZenMan';
62 zenman_interval
=$
[10*60];
64 zenman_autorefresh
=false
;
66 zenman_configdir
=~
/.config
/zenman
;
67 zenman_pid
="$zenman_configdir/zenman.pid";
68 zenman_true_ico
='/usr/share/icons/gnome/48x48/status/software-update-urgent.png'; #software-update-available.svg
69 zenman_false_ico
='/usr/share/icons/gnome/48x48/emotes/face-cool.png';
70 zenman_refresh_ico
='/usr/share/icons/gnome/48x48/actions/view-refresh.png';
72 #files/commands###################
73 gksu
='gksu'; #gksu/gksudo/...
74 pacman
='/usr/bin/pacman'; #want to use pacman-color, yaourt or powerpill instead?
75 xterm
='/usr/bin/xterm'; #xterm/...
76 espeak
='/usr/bin/espeak' #espeak (for spoken notification)
77 pacman_refresh
='-Syuw'; # -Sy ?
78 pacman_upgrade
='-Syu'; # -Syuf ?
80 pacman_lock
='/var/lib/pacman/db.lck'; #file to delete, when pacman locked (only if not running)
82 #Translate here###################
83 zenman_true
='New package(s) found! ;-)\n\nPacman output follows:\n';
84 zenman_false
='No packages to update. ;-(';
85 zenman_refreshing
='Refreshing pacman database. ;-) Please wait...';
86 zenman_usage
="[i] $0 --stop to kill zenman\n[i] $0 --help to show help\n"
87 zenman_upgrade
="[*] ZenMan will now execute full system upgrade! ;-)\n\n'$pacman' '$pacman_upgrade'\n\n";
88 zenman_close
='[*] Press [ENTER] to close window...';
89 zenman_config
='[*] Loading configuration from: ';
91 zenman_locked
="ZenMan can't execute system upgrade! ;-(
92 Please stop all pacman related applications and try again.";
93 zenman_start
="ZenMan started! ;-)
95 For more informations please visit:
96 http://blog.harvie.cz/";
99 espeak_voice
='en'; #see: espeak --voices
100 espeak_volume
='200'; #0-200
101 speech_true
='New packages found!';
103 #INIT#########################################
104 if [ "$2" != '' ]; then zenman_configdir
="$2"; fi; #when called with --upgrade
105 mkdir
-p "$zenman_configdir"
106 touch "$zenman_configdir/zenman.conf"
107 #read configuration files (can contain localization also)...
110 "$zenman_configdir/zenman.conf"\
112 echo "$zenman_config" "$i";
113 source "$i" >/dev
/null
2>&1;
115 if [ "$2" != '' ]; then zenman_configdir
="$2"; fi; #when called with --upgrade
118 if [ ! -e "$zenman_true_ico" ]; then zenman_true_ico
='warning'; fi;
119 if [ ! -e "$zenman_false_ico" ]; then zenman_false_ico
='info'; fi;
120 if [ ! -e "$zenman_refresh_ico" ]; then zenman_false_ico
='question'; fi;
123 #CODE#########################################
125 if [ -e "$zenman_pid" ]; then
126 kill $
(cat "$zenman_pid") >/dev
/null
2>&1;
127 kill -KILL $
(cat "$zenman_pid") >/dev
/null
2>&1;
129 if [ "$1" == '--stop' ]; then
133 echo "$$" > "$zenman_pid";
135 #this procedure is called internally...
136 if [ "$1" == '--upgrade' ]; then
137 echo -ne "$zenman_upgrade";
138 "$pacman" $pacman_upgrade;
140 echo -e "\n$zenman_close";
149 echo -e "$zenman_usage"
150 if "$zenman_splash"; then
151 notify-send
-i info
--expire-time=5000 "$zenman_caption" "$zenman_start";
157 if "$zenman_speech" && [[ -x "$espeak" ]] ; then
158 "$espeak" -a "$espeak_volume" -v "$espeak_voice" "$1" &
163 zenman_force_unlock
() {
164 if [ -e "$pacman_lock" ]; then #check if db locked...
165 ps
-eo comm |
grep -i '^\(pacman\|yaourt\|powerpill\|gtkpacman\|pacupdate\|kpacupdate\|guzuta\|YAPG\|Shaman\)' >/dev
/null
; #check if pacman is running...
167 "$gksu" "rm -rf '$pacman_lock'";
169 return 1; #gksu failed ;-(
171 return 0; #unlocked!!!
174 return 1; #pacman is running ;-(
177 return 0; #no locked!!!
183 #uncomment next line if not running -Syuw from cron (and you better set higher zenman_interval)
184 if "$zenman_autorefresh"; then
185 echo -ne "$zenman_refreshing ";
186 zenity
--notification --text "$zenman_refreshing" --window-icon="$zenman_refresh_ico" &
188 "$gksu" "'$pacman' $pacman_refresh --noconfirm" >/dev
/null
2>&1
189 kill $
! >/dev
/null
2>&1;
190 kill -KILL $
! >/dev
/null
2>&1;
193 #check for new packages
194 pacman_new_packages
=$
("$pacman" $pacman_check --noconfirm 2>&1);
195 if [ $?
== 0 ] && [ "$pacman_new_packages" != '' ]; then #fixed pacman always returning 0 issue...
197 zenman_speech
"$speech_true";
198 notify-send
-i info
"$zenman_caption" "$(echo -e "$zenman_true" "$pacman_new_packages")"
199 zenity
--notification --timeout="$zenman_interval" --text "$(echo -e "$zenman_true" "$pacman_new_packages")" --window-icon="$zenman_true_ico";
201 #no packages to update
202 zenity
--notification --timeout="$zenman_interval" --text "$zenman_false" --window-icon="$zenman_false_ico";
205 #run full system upgrade if notification icon clicked
207 #try to unlock pacman db if locked and pacman is not running
211 "$gksu" " '$xterm' -T '$zenman_caption' -e '$0 --upgrade \\\\'$zenman_configdir\\\\\''" ###TODO: fix quotes and escaping for configdir here later!!!!
214 #show error if locked
215 notify-send
-i error
"$zenman_caption" "$zenman_locked";
This page took 0.786926 seconds and 4 git commands to generate.