You are not logged in.
wrong title maybe
Need Pacman and Zenity
as root this (commands as work on my settup)
gksu gedit /etc/cron.hourly/sync-pacman and make sure the cron deamon is running on your system
#!/bin/bash
# color codes e.g. ${color3} are for the benefit of reading this info from conky e.g a conky command with ${execi 60 cat ThisFile}
# neither these or conky are required at all
# check for lock file and deal with it
mywait="0"
if [[ -f /var/lib/pacman/db.lck ]]
then
echo '${color4}Lock' > ~/bin/pacman-status
if pgrep pacman >/dev/null
then
echo ":: pacman seems to be running. waiting..." >&2
while [[ -f /var/lib/pacman/db.lck ]]; do
echo ":: waiting for pacman..."
echo '${color4}!!' > ~/bin/pacman-status
sleep 1m
mywait=$(expr $mywait + 1)
if [ $mywait -ge 45 ]
then
echo "!! forcing pacman, removing lock file..."
echo '${color3}>' > ~/bin/pacman-status
rm -f /var/lib/pacman/db.lck
fi
done
else
echo "!! forcing pacman, removing lock file..."
echo '${color3}>' > ~/bin/pacman-status
rm -f /var/lib/pacman/db.lck
fi
fi
pacman -Sy > /dev/null
numberof=$(pacman -Qu | wc -l)
if [ $numberof -ge 9 ]
then
#red
mycolour='${color4}'
else
if [ $numberof -ge 5 ]
then
# blue
mycolour='${color3}'
else
if [ $numberof -ge 1 ]
then
# green
mycolour='${color2}'
else
# grey / no colour
mycolour='${color1}'
fi
fi
fi
if [ $numberof -le 0 ]
then
rm -f ~/bin/pacman-status
else
echo $mycolour$numberof > ~/bin/pacman-status
fi
script called by keyboard shortcut SUPER+U
#!/bin/bash
# used to check if user realy wants to do updates
if [ -f ~/bin/pacman-status ]
then
PASSWD=$(zenity --title="System Update" --entry --text="Password to update system:" --hide-text --timeout="11")
case $? in
0)
gnome-terminal -x ~/bin/tawan-update $PASSWD
exit
;;
1)
exit
;;
-1)
exit
;;
esac
else
zenity --title="System Update" --warning --text="There is nothing to do" --timeout="3"
fi
update script saved (in my case as) ~/bin/tawan-update
#!/bin/bash
#
# if no password added then quit
if [ -z "$1" ]
then
exit
fi
# read password input from tawan-ask-update script
PASSWD=$1
# make root privialages for this script
echo $PASSWD | sudo -S echo "If you see this then the password failed. "
clear
#
# get and store the time of this update so that a script can later call a new update if set time has passed.
# get the hour now and store it
##date +%H > ~/bin/last-update-time.log
# anoter script (not made yet) will notice if 24 hours has passed with no update and call one.
# if another manual or auto update has happened then the new lapse will be 24 from then.
#
# check for lock file and deal with it
mywait="0"
if [[ -f /var/lib/pacman/db.lck ]]
then
echo '${color4}Lock' > /home/tawan/bin/pacman-status
if pgrep pacman >/dev/null
then
echo ":: pacman seems to be running. waiting..." >&2
while [[ -f /var/lib/pacman/db.lck ]]; do
echo ":: waiting for pacman..."
echo '${color4}Run' > /home/tawan/bin/pacman-status
sleep 10
mywait=$(expr $mywait + 1)
if [ $mywait -ge 30 ]
then
echo "!! forcing pacman, removing lock file..."
echo '${color3}Fix' > /home/tawan/bin/pacman-status
sudo -S rm -f /var/lib/pacman/db.lck
fi
done
else
echo "!! forcing pacman, removing lock file..."
echo '${color3}Fix' > /home/tawan/bin/pacman-status
sudo -S rm -f /var/lib/pacman/db.lck
fi
fi
#
# to business..
# does an update
echo ":: updating system..."
sudo -S pacman -Syu
echo " "
echo ":: update complete..."
echo " "
sleep 2s
# function to check for and remove orphan packages
# this function looped by the while loop later
function orphanage {
echo ":: checking if orphan packages exist on the system..."
echo " "
ORPHANS=`pacman -Qqdt`
if [ -z "$ORPHANS" ]
then
echo ":: system is clean, will exit..."
# signal to conky that no updates available
rm -f /home/tawan/bin/pacman-status
sleep 3s
exit
else
echo -e ":: orphans found on the system.\n$ORPHANS\n\n:: Removing..."
sudo -S pacman -R --nosave $ORPHANS
fi
}
# end of orphan function
#
#
# infinite loop to find and remove orphan packages
# script exits when none found
while [ 1 ]
do
orphanage
done
# end of loop
#
#
zenity --warning --text="Update script did not exit normally"
sleep 8s
exit
Last edited by tawan (2011-01-29 01:06:08)
Offline