summarylogtreecommitdiffstats
path: root/pacgui.sh
blob: 725746336d185c60afd3384cd797835e6b472222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash

pacman_error () {
zenity --error --text="Error: $1"
killall zenity
exit 
}

updates=$(checkupdates)
if [ $? -eq 0 ]; then

	zenity --info --width=400\
		  --text="Updated packages:\n$(echo "$updates" | awk '{if(FNR <= 10) {print $1} }')"

	zenity --question \
	--text="Do yout want to continue with the updates?" --width=400

	if [ $? -eq 0 ]; then
	    echo "Upgrade starten!"
		(
			echo "10" ; sleep 1
			echo "# Sync Databases" 
			echo "30" ; nice -15 sudo -S pacman -Syy --noconfirm || pacman_error "Sync"
			echo "# Downloading Packages" ; sleep 1
			echo "60" ; nice -15 sudo -S pacman -Syw --noconfirm || pacman_error "Download"
			echo "# Installing updates" ; sleep 1
			echo "80" ; nice -15 sudo -S pacman -Syu --noconfirm || pacman_error "Update"
			echo "# Finished with the updates"
			echo "100"
		) |
		zenity --progress \
		  --title="System Update" \
		  --text="Databases will be updated …" \
		  --percentage=0 --width=400 || pacman_error
		
			
	elif [ $? -eq 1 ]; then
	    echo "Upgrades stopped!"
	else
	    echo "An unexpected error was encountered."
	fi

else
	zenity --info --text="No updates available." --width=400 
	exit
fi