Skip to content

Commit

Permalink
Merge pull request #920 from ivan-hc/dev
Browse files Browse the repository at this point in the history
Update sandboxes.am: refactoring
  • Loading branch information
ivan-hc authored Sep 3, 2024
2 parents 18eca35 + 6bc45f1 commit a703934
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions modules/sandboxes.am
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ _check_aisap() {
return 1
elif ! command -v aisap 1>/dev/null; then
printf '\n%s\n\n' " Error: You need aisap for this script work"
read -p " ◆ DO YOU WISH TO INSTALL AISAP? Install size <5 MiB? (Y/n) " yn
read -r -p " ◆ DO YOU WISH TO INSTALL AISAP? Install size <5 MiB? (Y/n) " yn
if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
echo " OPERATION ABORTED!"
return 1
Expand Down Expand Up @@ -123,7 +123,7 @@ _generate_sandbox_script() {
APPCONF=$( ls "$CONFIGDIR" | grep -i "$APPNAME" | head -1 )
# Disable sandbox
if [ "$1" = "--disable-sandbox" ]; then
APPIMAGEDIR="$(echo ${APPEXEC%/*})"
APPIMAGEDIR="${APPEXEC%/*}"
echo ""
echo " Giving exec permissions back to $APPEXEC..."
chmod a+x "$APPEXEC" || exit 1
Expand Down Expand Up @@ -177,33 +177,33 @@ _generate_sandbox_script() {

_configure_dirs_access() {
printf '\033[33m\n'
read -p " Do you want configure access to directories? (Y/n): " yn
read -r -p " Do you want configure access to directories? (Y/n): " yn
if echo "$yn" | grep -i '^n' >/dev/null 2>&1; then
return 0
fi
printf '\033[36m'
for DIR in DESKTOP DOCUMENTS DOWNLOAD GAMES MUSIC PICTURES VIDEOS; do
eval XDG_DIR=\$$DIR
read -p " Allow $1 access to \"$XDG_DIR\"? (y/N) " yn
read -r -p " Allow $1 access to \"$XDG_DIR\"? (y/N) " yn
if echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
tmpscript=$(echo "$tmpscript" \
| sed "s#--rm-file \"\$$DIR\"#--add-file \"\$$DIR\":rw#g" )
fi
done
sleep 0.5
printf '\033[31m'
read -p " Allow $1 access to a specific directory? (y/N) " yn
read -r -p " Allow $1 access to a specific directory? (y/N) " yn
if echo "$yn" | grep -i '^y' >/dev/null 2>&1; then
echo " WARNING: Giving access to all of $HOME or / and similar is not safe"
echo " Also aisap might not let $1 start when such paths are given"
printf '\033[33m%s\n' " Type the path to the directory"
read -p " Example: /media/external-drive or ~/Backups: " NEWDIR
read -r -p " Example: /media/external-drive or ~/Backups: " NEWDIR
case "$NEWDIR" in
'$HOME'|'$HOME/'|"$HOME"|"$HOME/"|"/"|"~"|"~/"|"/home"|"/home/"|\
"$DATADIR"|'$XDG_DATA_HOME'|"$CONFIGDIR"|'$XDG_CONFIG_HOME'|"$BINDIR")
notify-send -u critical "DO YOU WANT THE FBI TO GET YA?"
printf '\033[31m\n'
read -p " SPOOKY LOCATION! ARE YOU SURE? IF SO TYPE \"YES\": " YES
read -r -p " SPOOKY LOCATION! ARE YOU SURE? IF SO TYPE \"YES\": " YES
[ "$YES" != "YES" ] && echo " That's not \"YES\", aborting" && return 1
;;
'')
Expand Down Expand Up @@ -231,7 +231,7 @@ _install_sandbox_script() {
printf '\033[32m\n%s\n\033[0m' " \"$1\" successfully sandboxed!"
printf '\n%s\n' " $1 will be sandboxed in \"$SANDBOXDIR\""
printf '%s\n\n' " once launched"
printf '%s\n' ' Set the $SANDBOXDIR env variable to move the location'
printf '%s\n' " Set the \$SANDBOXDIR env variable to move the location"
printf '\n%s' ' Use '
printf '\033[33m%s' '--disable-sandbox'
printf '\033[0m%s\033[33m\n' " to revert the changes, in this case that is:"
Expand All @@ -244,7 +244,7 @@ _install_sandbox_script() {
case "$1" in
'--sandbox')
shift
for arg in ${@}; do
while [ "$#" -gt 0 ]; do
_check_appimage "${@}" && _check_aisap "${@}" \
&& _generate_sandbox_script "${@}" \
&& _configure_dirs_access "${@}" \
Expand All @@ -255,23 +255,23 @@ case "$1" in

'--disable-sandbox')
shift
for arg in ${@}; do
while [ "$#" -gt 0 ]; do
_disable_sandbox "${@}"
shift
done
;;

'-H'|'--home')
shift
for arg in ${@}; do
while [ "$#" -gt 0 ]; do
_check_appimage "${@}" && _home "${@}"
shift
done
;;

'-C'|'--config')
shift
for arg in ${@}; do
while [ "$#" -gt 0 ]; do
_check_appimage "${@}" && _config "${@}"
shift
done
Expand Down

0 comments on commit a703934

Please sign in to comment.