-
Notifications
You must be signed in to change notification settings - Fork 1
/
pacstall-gui
executable file
·114 lines (91 loc) · 4.89 KB
/
pacstall-gui
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/bash
TMP="$(mktemp -d "/tmp/pacstall-gui-XXX")"
export TMP
if ! [ -f "$HOME/.config/pacstall-gui/settings.sh" ]; then
mkdir -p $HOME/.config/pacstall-gui
echo -e "THEME=Adwaita:light
KEEPTMP=false" > $HOME/.config/pacstall-gui/settings.sh
fi
source "$HOME/.config/pacstall-gui/settings.sh"
function trap_ctrlc() {
echo "The program has been interrupted, exiting"
if [[ "$KEEPTMP" == false ]]
then
rm -rf "$TMP"
fi
}
trap "trap_ctrlc" 2
function search() {
source "$HOME/.config/pacstall-gui/settings.sh"
if GTK_THEME=$THEME yad --entry --text=Search --on-top --ricon=find > ./search.txt
then
pacstall -S $(cat ./search.txt) > tmpfile
mv -f tmpfile search.txt
sed -i '/no package/d' ./search.txt
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" ./search.txt | tr -dc '[[:print:]]\n' > search-formatted.txt
sed -i 's/\ .*/ /' ./search-formatted.txt
sed -i ':a;N;$!ba;s/\n/ /g' ./search-formatted.txt
#Some how unable to reproduce below with [*]
sed -i 's/[[*]]//g' ./search-formatted.txt
sed -i 's/[[]//g' ./search-formatted.txt
yad --list --print-all --multiple --column="Package Name":TXT $(cat ./search-formatted.txt) --title="package list" --button=Return:0 --buttons-layout=start --center --dclick-action="echo" --multiple --compact --title="Search Results" > /dev/null
#In case user wants to search again...
rm -rf "./search-formatted.txt" "./search.txt"
return 0
else
rm -rf "./search-formatted.txt" "./search.txt"
return 1
fi
}
export -f search
function settings() {
source "$HOME/.config/pacstall-gui/settings.sh"
if GTK_THEME=$THEME yad --form --field="Theme (currently is $(echo "$THEME" | sed 's/\<Adwaita\>//g' | sed 's/[:]//g')):":CB 'light!dark' --separator='\n' --field="Keep TMP (currently is $(echo "$KEEPTMP"))":CB 'false!true' > ./setting-noformat.txt
then
sed -i '1s/^/THEME=Adwaita:/' ./setting-noformat.txt
sed -i '2s/^/KEEPTMP=/' ./setting-noformat.txt
mv -f ./setting-noformat.txt "$HOME/.config/pacstall-gui/settings.sh"
else
rm -rf "./setting-noformat.txt"
fi
source "$HOME/.config/pacstall-gui/settings.sh"
}
export -f settings
function list() {
source "$HOME/.config/pacstall-gui/settings.sh"
pacstall -L > ./installed
echo "$(awk '{print "0 "$0}' ./installed)" > ./installed
sed -i ':a;N;$!ba;s/\n/ /g' ./installed
sed -ri 's/.{50}//' ./installed
if GTK_THEME=$THEME yad --list --column="Remove":CHK --print-all --multiple --column="Package Name":TXT $(cat ./installed) --title="currently installed pacscripts" --button=Remove:0 --buttons-layout=center --dclick-action="true" > ./remove;
then
sed -i '/FALSE/d' ./remove
sed -i 's/|//g' ./remove && sed -i 's/TRUE//g' ./remove
sed -i ':a;N;$!ba;s/\n/ /g' ./remove
pkexec $TMP/pacstall-patched -PR $(cat $TMP/remove) | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | GTK_THEME=$THEME yad --form --field="Detailed view":TXT --text="Removing $(cat $TMP/remove)..." --title="Removing $(cat $TMP/remove) pacscripts" --scroll --cycle-read --button=Abort/End:1 --text="You can close this window once all pacscripts are removed. You can tell by INFO: Package removed successfully." --on-top --width="300" --height="300"
fi
rm -rf ./installed ./remove
}
export -f list
function about() {
yad --about --copyright=2023 --pname=pacstall-gui --pversion=$(date -I) --website='https://github.com/cat-master21/pacstall-gui' --website-label='https://github.com/cat-master21/pacstall-gui' --authors=cat-master21 --comments='pacstall-gui is a frontend for Pacstall' --on-top --splash --icon=desktop
}
export -f about
cd "$TMP" || exit 1
wget -q "$(cat /usr/share/pacstall/repo/pacstallrepo)/packagelist"
printf "$(awk '{print "0 "$0}' ./packagelist)" > ./packagelist
sed -i ':a;N;$!ba;s/\n/ /g' ./packagelist
sed '/# Error out when run as root/,+5 d' /usr/bin/pacstall > ./pacstall-patched
sed -i 's!axel -ao!axel -qao!' ./pacstall-patched
chmod +x ./pacstall-patched
if GTK_THEME=$THEME yad --list --column="Install":CHK --print-all --multiple --column="Package Name":TXT $(cat ./packagelist) --title="package list" --button=Install:0 --buttons-layout=start --center --dclick-action="true" --multiple --button=Search:"bash -c search" --button=Settings:"bash -c settings" --button="Installed":"bash -c list" --button="About pacstall-gui":"bash -c about" --window-icon=system-software-install > ./install-packages; then
sed -i '/FALSE/d' ./install-packages
sed -i 's/|//g' ./install-packages && sed -i 's/TRUE//g' ./install-packages
sed -i ':a;N;$!ba;s/\n/ /g' ./install-packages
pkexec $TMP/pacstall-patched --disable-prompts -I $(cat $TMP/install-packages) | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | GTK_THEME=$THEME yad --form --field="Detailed view":TXT --text="Installing $(cat $TMP/install-packages)..." --title="Installing Pacscripts" --scroll --cycle-read --button=Abort/End:1 --text="You can close this window once all pacscripts are installed." --on-top --width="300" --height="300"
fi
if [[ "$KEEPTMP" == false ]]
then
rm -rf "$(pwd)"
fi
exit 0