-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate
More file actions
executable file
·147 lines (126 loc) · 5.34 KB
/
update
File metadata and controls
executable file
·147 lines (126 loc) · 5.34 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
if [[ $(xrandr --current) =~ "connected primary" ]]; then
resolution=$(xrandr --current | grep " connected primary" | awk '{print $4}' | cut -d'+' -f1)
else
resolution=$(xrandr --current | grep " connected" | awk '{print $3}' | cut -d'+' -f1)
fi
horizontal=$(echo $resolution | cut -d'x' -f1)
vertical=$(echo $resolution | cut -d'x' -f2)
check_for_updates() {
#kill $(pgrep -f "title=App Details")
local repository_path="./apps"
local installed_scripts_path="$HOME/.linstore/installscripts"
local updates=()
mkdir -p "$installed_scripts_path"
# Show progress dialog
(
echo "# Checking for updates"
sleep 1
# Clean up previous installation
rm -rf ~/.linstore/tmp
echo "# Cloning repository"
git clone https://github.com/techguy16/linstore ~/.linstore/tmp > /dev/null 2>&1
sleep 1
echo "# Moving new app installation scripts"
rm -rf ./apps
mv ~/.linstore/tmp/apps ./apps
sleep 1
# Clean up
# rm -rf ~/.linstore/tmp
echo "# Finished"
) | yad --center --title "Updater" --text "Checking for app updates" --progress --pulsate --width=300 --height=75 \
--enable-log="Log" --log-expanded --auto-kill --borders=10 --auto-close --no-buttons
# check for LinStore updates
local fileupdates=""
for file in gui api createapp settings update; do
if diff "./$file" "$HOME/.linstore/tmp/$file" > /dev/null 2>&1; then
./api info "No updates available for $file"
else
./api warning "Update available for $file"
fileupdates+="$file, "
fi
done
if [ "$fileupdates" != "" ]; then
updates+=(TRUE "images/logo/logo-16.png" "<b>LinStore</b> ($(echo $fileupdates | sed 's/[[:space:]]*$//' | sed 's/,$//'))")
fi
for installed_script in "$installed_scripts_path"/*; do
app_name=$(basename "$installed_script")
# Ignore specific files
if [[ "$app_name" == "test" ]]; then
continue
fi
app_directory="$repository_path/$app_name"
app_script=$(./api whatscript "$app_directory" "$app_name")
script="$app_directory/$app_script"
if [ -d "$app_directory" ]; then
needs_update=true
if [ -e "$script" ]; then
if diff -q "$installed_script" "$script" >/dev/null; then
needs_update=false
fi
fi
if $needs_update; then
icon_path="$app_directory/icon-16.png"
updates+=(TRUE "$icon_path" "$app_name")
fi
# unneeded - linstore is useless without the app directory
#else
# updates+=(FALSE "" "$app_name (No directory found)")
fi
done
buttons=()
buttons_noupd=()
pos=$(wmctrl -lG | grep "LinStore" | awk '{print $3,$4}')
if xdotool search --name "^LinStore$" >/dev/null 2>&1; then
./api info "Running with LinStore GUI open"
buttons+=("--button=Recheck Updates!edit-find:2")
buttons+=("--button=<b>Update Selected</b>:0")
buttons_noupd+=("--button=Recheck Updates!edit-find:2")
buttons_noupd+=("--button=Finish!go-next:3")
x2=$((horizontal / 2 - 65))
else
./api info "Running without LinStore open"
buttons+=("--button=Return to LinStore!edit-undo:1")
buttons+=("--button=Recheck Updates!edit-find:2")
buttons+=("--button=<b>Update Selected</b>!view-refresh:0")
buttons_noupd+=("--button=Return to LinStore!edit-undo:1")
buttons_noupd+=("--button=Recheck Updates!edit-find:2")
buttons_noupd+=("--button=Finish!go-next:3")
x2=$((horizontal / 2 - 265))
fi
y2=$((vertical / 2 - 320))
if [ ${#updates[@]} -eq 0 ]; then
kill $(pgrep -f "title=App Details") > /dev/null 2>&1
GDK_BACKEND=x11 yad --info --class="LinStore" --title="LinStore Updates" --text="<big><b>All apps are up to date!</b></big>" --text-align=center --geometry=450x600+${x2}+${y2} "${buttons_noupd[@]}"
response=$?
else
kill $(pgrep -f "title=App Details") > /dev/null 2>&1
updates_list=$(GDK_BACKEND=x11 yad --list --class="LinStore" --title="LinStore Updates" --column="Select":CHK --column="Icon":IMG --column="App" \
"${updates[@]}" --checklist --geometry=450x600+${x2}+${y2} --no-header "${buttons[@]}") #i regret programming
response=$?
fi
if [ $response -eq 0 ]; then
IFS=$'\n' read -d '' -r -a selected_apps <<<"$updates_list"
for selected in "${selected_apps[@]}"; do
if [[ "$selected" == TRUE* ]]; then
app_name=$(echo "$selected" | cut -d '|' -f 3 | sed 's/<\/\?b>//g')
echo "Updating selected: $app_name"
if [[ "$(echo $app_name | awk -F" " '{print $1}')" == "LinStore" ]]; then
bash -c "x-terminal-emulator -e './api update'"
else
./api info "Updating app: $app_name"
app_directory="$repository_path/$app_name"
install=$(./api install "$app_directory" "$app_name")
bash -c "${install}"
fi
fi
done
./update
elif [ $response -eq 1 ]; then
./gui
elif [ $response -eq 2 ]; then
./update
fi
}
# Call the function
check_for_updates