Skip to content

Commit

Permalink
add multi-uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
theofficialgman committed May 16, 2022
1 parent 79cd861 commit 97f0c7c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
52 changes: 52 additions & 0 deletions api
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,58 @@ $(head -n1 "${DIRECTORY}/apps/$app/description")"
fi
}

multi_uninstall_gui() { #graphical interface to uninstall multiple apps from a list.

#get list of apps that are installed
local apps="$(list_apps installed)"

local IFS=$'\n'
local app

apps="$(for app in $apps ;do
echo "FALSE
${DIRECTORY}/apps/$app/icon-24.png
$app
$(head -n1 "${DIRECTORY}/apps/$app/description")"
done | sed 's/&/&/g' | yad "${yadflags[@]}" --list --checklist \
--width=300 --height=500 \
--hide-column=4 --print-column=3 --tooltip-column=4 --no-headers \
--text="Uninstall everything you want!"$'\n'"Note: apps that are not installed are not shown." \
--column=:chk --column=:img --column=name --column=:tip \
--button=Cancel!"${DIRECTORY}/icons/exit.png":1 --button='Uninstall selected'!"${DIRECTORY}/icons/uninstall.png":0)"

if [ $? == 0 ] && [ ! -z "$apps" ];then
#remove empty lines from yad's output
apps="$(grep . <<<"$apps")"
echo "Will uninstall these apps:"$'\n'"$apps"

#set the terminal title text
title="Uninstalling $(wc -l <<<"$apps") apps"

#in a terminal, first get the api functions, display the pi-apps logo, run the manage script, and refresh the app list if the $pipe variable is set
"${DIRECTORY}/etc/terminal-run" '
DIRECTORY="'"$DIRECTORY"'"
source "${DIRECTORY}/api"
generate_logo
"${DIRECTORY}/manage" multi-uninstall "'"$apps"'"
exitcode=$?
if [ $exitcode == 0 ];then
echo
#display countdown
for i in {30..1} ;do
echo -en "You can close this window now. Auto-closing in $i seconds.\e[0K\r"
sleep 1
done
else
echo -e "\nClose this window to exit."
read enter #technically you could press Enter to exit.
fi' "$title"

fi
}

#command interceptors - functions that enhance a command
enable_module() { #Permanent equivalent to modprobe, this will load the module on every future startup
local module="$1"
Expand Down
3 changes: 2 additions & 1 deletion settings
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ $(echo "$params" | grep -vx "$curval")"
"${tooltips[@]}" \
--field='Categories'!"${DIRECTORY}/icons/categories.png"!"Does an App belong in Editors instead of Tools? This lets you move it.":FBTN "bash -c '${DIRECTORY}/etc/categoryedit 1>&2'" \
--field='Log files'!"${DIRECTORY}/icons/log-file.png"!"View past installation logs. Useful for debugging, or to see what you installed yesterday.":FBTN "bash -c '${DIRECTORY}/etc/logviewer 1>&2'" \
--field='Multi-Select'!"${DIRECTORY}/icons/multi-select.png"!"Install multiple apps at the same time.":FBTN "bash -c '${DIRECTORY}/api multi_install_gui 1>&2'" \
--field='Multi-Install'!"${DIRECTORY}/icons/multi-select.png"!"Install multiple apps at the same time.":FBTN "bash -c '${DIRECTORY}/api multi_install_gui 1>&2'" \
"${yadparams[@]}" \
--field='New App'!"${DIRECTORY}/icons/create.png"!"Make your own app! It's pretty easy if you follow the instructions.":FBTN "bash -c '${DIRECTORY}/createapp 1>&2'" \
--field='Import App'!"${DIRECTORY}/icons/download.png"!"Did someone else make an app but it's not on Pi-Apps yet? Import it here.":FBTN "bash -c '${DIRECTORY}/etc/import-app 1>&2'" \
--field='Multi-Uninstall'!"${DIRECTORY}/icons/multi-select.png"!"Uninstall multiple apps at the same time.":FBTN "bash -c '${DIRECTORY}/api multi_uninstall_gui 1>&2'" \
--button='Reset'!"${DIRECTORY}/icons/backup.png"!'Reset all settings to their defaults':2 \
--button=Cancel!"${DIRECTORY}/icons/exit.png":1 \
--button=Save!"${DIRECTORY}/icons/check.png":0 \
Expand Down

0 comments on commit 97f0c7c

Please # to comment.