Skip to content

Commit 66d16ec

Browse files
authored
Merge pull request #800 from ivan-hc/dev
Add option to create portable config dir
2 parents e081b95 + 12490e5 commit 66d16ec

File tree

4 files changed

+61
-26
lines changed

4 files changed

+61
-26
lines changed

APP-MANAGER

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
AMVERSION="7.2.1-1"
3+
AMVERSION="7.3"
44

55
# Determine main repository and branch
66
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
@@ -443,7 +443,7 @@ function _use_enable_completion() {
443443

444444
# Generate a list of words to use in bash completion
445445
function _generate_options_list() {
446-
rm -rf "$AMPATH/options"
446+
rm -f "$AMPATH/options"
447447
cat <<-HEREDOC >> "$AMPATH/options"
448448
about
449449
apikey
@@ -470,6 +470,7 @@ function _generate_options_list() {
470470
web
471471
--apps
472472
--byname
473+
--config
473474
--convert
474475
--debug
475476
--devmode-disable
@@ -964,6 +965,7 @@ case "$1" in
964965
_if_appman_mode_enabled
965966
_use_module "$@"
966967
;;
968+
'-C'|'--config'|\
967969
'-H'|'--home'|\
968970
'--sandbox'|\
969971
'--disable-sandbox')

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,16 @@ See also "[How to update or remove apps manually](#how-to-update-or-remove-apps-
415415
`-c`
416416

417417
DESCRIPTION: Removes all the unnecessary files and folders.
418-
___________________________________________________________________________
418+
__________________________________________________________________________
419+
420+
`-C`, `--config`
421+
422+
SYNOPSIS:
423+
424+
`-C {PROGRAM}`
425+
426+
DESCRIPTION: Set a dedicated $XDD_CONFIG_HOME for one or more AppImages.
427+
__________________________________________________________________________
419428

420429
`-d`, `download`
421430

modules/help.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ function _help_body() {
7878
DESCRIPTION: Removes all the unnecessary files and folders.
7979
__________________________________________________________________________
8080
81+
-C, --config
82+
83+
SYNOPSIS: -C {PROGRAM}
84+
85+
DESCRIPTION: Set a dedicated $XDD_CONFIG_HOME for one or more AppImages.
86+
__________________________________________________________________________
87+
8188
-d, download
8289
8390
SYNOPSIS: -d {PROGRAM}

modules/sandboxes.am

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,28 @@
66

77
# Set a dedicated .home directory for a selected AppImage
88
_home() {
9-
cd "$APPSPATH" || return
10-
if ! test -d ./"$arg"; then
11-
echo " ERROR: \"$arg\" is not installed"
9+
if [ ! -d "$APPSPATH"/"$arg" ]; then
10+
echo " ERROR: \"$arg\" is not installed" || return
11+
elif [ -d "$APPSPATH/$arg/$arg.home" ]; then
12+
echo " ERROR: \"$arg\" already contains a home dir"
13+
elif ! strings -d "$APPSPATH/$arg/$arg" | grep -- '--appimage-extract' 1>/dev/null; then
14+
echo " ERROR: \"$arg\" is NOT an AppImage"
1215
else
13-
case "$arg" in
14-
*)
15-
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F "if you run it with the --appimage-extract option")" ] 2>/dev/null; then
16-
echo " ERROR: \"$arg\" is NOT an AppImage"
17-
else
18-
cd ./"$arg" || return
19-
mkdir -p ./"$arg.home"
20-
echo ' Setting $HOME to '"$APPSPATH/$arg/$arg"'.home for this AppImage'
21-
fi
22-
esac
16+
mkdir "$APPSPATH/$arg/$arg.home" || return
17+
echo ' $HOME set to '"$APPSPATH/$arg/$arg.home for $arg"''
18+
fi
19+
}
20+
21+
_config() {
22+
if [ ! -d "$APPSPATH"/"$arg" ]; then
23+
echo " ERROR: \"$arg\" is not installed" || return
24+
elif [ -d "$APPSPATH/$arg/$arg.config" ]; then
25+
echo " ERROR: \"$arg\" already contains a config dir"
26+
elif ! strings -d "$APPSPATH/$arg/$arg" | grep -- '--appimage-extract' 1>/dev/null; then
27+
echo " ERROR: \"$arg\" is NOT an AppImage"
28+
else
29+
mkdir "$APPSPATH/$arg/$arg.config" || return
30+
echo ' $XDG_CONFIG_HOME set to '"$APPSPATH/$arg/$arg.config for $arg"''
2331
fi
2432
}
2533

@@ -33,16 +41,12 @@ fi
3341
case "$1" in
3442
'--sandbox')
3543

36-
case $2 in
37-
'')
38-
echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
39-
esac
40-
4144
# This script makes it easy to sandbox AppImages installed with AppMan or AM
4245
# The default location for the sandboxed homes is at $HOME/.local/am-sandboxes
4346
# But that location can be changed by setting the $SANDBOXDIR env variable
4447
# aisap: https://github.com/mgord9518/aisap
4548

49+
[ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1
4650
while [ -n "$1" ]; do
4751
# Safety checks
4852
if ! test -f "$APPSPATH/$2/remove"; then
@@ -270,21 +274,34 @@ case "$1" in
270274
;;
271275

272276
'-H'|'--home')
273-
case $2 in
274-
'') echo " USAGE: $AMCLI $1 [ARGUMENT]"; exit;;
275-
esac
276-
277+
[ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1
277278
while [ -n "$1" ]; do
278279
rm -f "$AMCACHEDIR/home-args"
279280
echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR/home-args" && echo STOP >> "$AMCACHEDIR/home-args"
280281
ARGS=$(tail -n +2 "$AMCACHEDIR"/home-args)
281282
for arg in $ARGS; do
282283
if [ "$arg" = STOP ]; then
283-
exit
284+
exit 0
284285
else
285286
_home
286287
fi
287288
done
288289
done
289290
;;
291+
292+
'-C'|'--config')
293+
[ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1
294+
while [ -n "$1" ]; do
295+
rm -f "$AMCACHEDIR/config-args"
296+
echo "$@" | tr ' ' '\n' >> "$AMCACHEDIR/config-args" && echo STOP >> "$AMCACHEDIR/config-args"
297+
ARGS=$(tail -n +2 "$AMCACHEDIR"/config-args)
298+
for arg in $ARGS; do
299+
if [ "$arg" = STOP ]; then
300+
exit 0
301+
else
302+
_config
303+
fi
304+
done
305+
done
306+
;;
290307
esac

0 commit comments

Comments
 (0)