Skip to content

Commit eb24b59

Browse files
authored
Update flattool
Allow flattool update-check to skip the last update comparison to fix the bug of not being able to update after checking for one Add ability to use trash-cli, default to gio then rm if neither are available Bump version to 1.1.1
1 parent 1e6eb0b commit eb24b59

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

flattool

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ asLastUpdateCheck="0000000000"
77
asAutoCheckUpdate="false"
88

99
# Global variables
10-
versionNumber="1.1.0"
10+
versionNumber="1.1.1"
1111
owner="heliguy4599"
1212
repo="flattool"
1313
appID=''
@@ -94,6 +94,19 @@ checkArgLength() {
9494
exit 1
9595
fi
9696
}
97+
98+
trashFile() {
99+
if command -v trash-put >/dev/null 2>&1; then
100+
trash-put "$1"
101+
return
102+
fi
103+
if command -v gio >/dev/null 2>&1; then
104+
gio trash "$1"
105+
return
106+
fi
107+
rm -rf "$1"
108+
return
109+
}
97110
# ====================================================================================
98111

99112
printMasterHelp() {
@@ -129,7 +142,7 @@ printSubcommandHelp() {
129142
purge)
130143
echo -e " purge - usage: flattool purge <app-query>"
131144
echo -e " can also be ran with '-p'"
132-
echo -e " about: Uninstalls a flatpak app and trashes its user data folder\n"
145+
echo -e " about: Uninstalls a flatpak app and deletes its user data folder\n"
133146
;;
134147
search)
135148
echo -e " search - usage: flattool search <app-query>"
@@ -211,9 +224,9 @@ removeApp() {
211224

212225
purgeApp() {
213226
identifyByQuery "$1"
214-
userConsent "Are you sure you want to uninstall ${boldTxt}${appID}${normalTxt} and move its user data to the trash?"
227+
userConsent "Are you sure you want to uninstall ${boldTxt}${appID}${normalTxt} and delete its user data?"
215228
flatpak uninstall "$appID"
216-
gio trash "${HOME}/.var/app/${appID}"
229+
trashFile "${HOME}/.var/app/${appID}"
217230
}
218231

219232
fixOrphans() {
@@ -236,7 +249,7 @@ fixOrphans() {
236249

237250
echo "What would you like to do with these folders?"
238251
echo " 1) Attempt to install matching flatpaks"
239-
echo " 2) Move these folders to the trash"
252+
echo " 2) Delete these folders"
240253

241254
totalOfOrphans=${#orphanedAppsList[@]}
242255
maxChoices=2
@@ -261,9 +274,9 @@ fixOrphans() {
261274
installApp "${orphanedAppsList[@]}"
262275
;;
263276
2)
264-
echo "Trashing..."
277+
echo "Deleting..."
265278
for element in "${orphanedAppsList[@]}"; do
266-
gio trash "${HOME}/.var/app/${element}"
279+
trashFile "${HOME}/.var/app/${element}"
267280
done
268281
;;
269282
3)
@@ -274,8 +287,8 @@ fixOrphans() {
274287
read -r answer
275288
case "$answer" in
276289
[Tt])
277-
echo "Trashing..."
278-
gio trash "${HOME}/.var/app/${element}"
290+
echo "Deleting..."
291+
trashFile "${HOME}/.var/app/${element}"
279292
break
280293
;;
281294
[Ii])
@@ -324,7 +337,19 @@ if [ "$asFirstRun" == "true" ]; then
324337
*)
325338
sed -i 's/^asAutoCheckUpdate="false"$/asAutoCheckUpdate="true"/' "$(which flattool)"
326339
;;
327-
esac
340+
esac
341+
342+
# Check which trashing methods, if any, are avaialable
343+
if command -v trash-put >/dev/null 2>&1; then
344+
echo "flattool found trash-cli on your system, nice! Any deleted data will be moved to your trash."
345+
else
346+
if command -v gio >/dev/null 2>&1; then
347+
echo "flattool found gio on your system, nice! Any deleted data will be moved to your trash."
348+
echo "flattool also works with trash-cli, by the way."
349+
else
350+
echo "Sadly flattool found no supported method for trashing your files. And deleted data will be ${bold}perminantly deleted${normal}."
351+
fi
352+
fi
328353
fi
329354

330355
# Setting the subcommand
@@ -442,6 +467,7 @@ case "$subcommand" in
442467
fi
443468
;;
444469
update-check)
470+
asLastUpdateCheck="0000000000"
445471
checkForNewVersion
446472
case $? in
447473
0)
@@ -453,9 +479,6 @@ case "$subcommand" in
453479
echo "Installing new version..."
454480
wget -N -P "$(dirname "$(which flattool)")" "https://raw.githubusercontent.com/${owner}/${repo}/main/flattool"
455481
;;
456-
2)
457-
echo "Due to GitHub API restrictions, can only check for updates once an hour"
458-
;;
459482
esac
460483
exit 0
461484
;;

0 commit comments

Comments
 (0)