Skip to content

Commit 19d80c1

Browse files
authored
"AM" 9.6.2 (#1442)
* Move -H and -C from sandboxes.am to main CLI ...add option -HC or -CH to create both dedicated HOME and XDG_CONFIG_HOME for selected AppImages * Move -C and -H and add -HC to management.am * Update README.md * Update management.am * Update management.am * Update APP-MANAGER
1 parent 232ef79 commit 19d80c1

File tree

4 files changed

+99
-53
lines changed

4 files changed

+99
-53
lines changed

APP-MANAGER

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

3-
AMVERSION="9.6.1-5"
3+
AMVERSION="9.6.2"
44

55
# Determine main repository and branch
66
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"
@@ -1265,6 +1265,7 @@ case "$1" in
12651265
if [ -t 1 ]; then _use_module "$@"; else _use_module "$@" | sed -e 's/\x1b\[[0-9;]*m//g'; fi
12661266
;;
12671267
'backup'|'-b'|\
1268+
'config'|'-C'|'--config'|'home'|'-H'|'--home'|'-HC'|'-CH'|'HC'|'CH'|\
12681269
'downgrade'|'--rollback'|\
12691270
'icons'|'--icons'|\
12701271
'launcher'|'--launcher'|\
@@ -1275,10 +1276,7 @@ case "$1" in
12751276
MODULE="management.am"
12761277
_use_module "$@"
12771278
;;
1278-
'config'|'-C'|'--config'|\
1279-
'home'|'-H'|'--home'|\
1280-
'sandbox'|'--sandbox'|\
1281-
'--disable-sandbox')
1279+
'sandbox'|'--sandbox'|'--disable-sandbox')
12821280
MODULE="sandboxes.am"
12831281
_use_module "$@"
12841282
;;
@@ -1387,7 +1385,7 @@ case "$1" in
13871385
13881386
${LightBlue}$AMCLI -C {PROGRAM}\033[0m
13891387
1390-
Description: Set a dedicated \$XDD_CONFIG_HOME for one or more AppImages.
1388+
Description: Set a dedicated \$XDG_CONFIG_HOME for one or more AppImages.
13911389
13921390
${Gold}downgrade, --rollback\033[0m
13931391
@@ -1435,6 +1433,12 @@ case "$1" in
14351433
14361434
Description: Set a dedicated \$HOME directory for one or more AppImages.
14371435
1436+
${Gold}-HC, -CH\033[0m
1437+
1438+
${LightBlue}$AMCLI -HC {PROGRAM}\033[0m
1439+
1440+
Description: Set dedicated \$HOME and \$XDG_CONFIG_HOME directories for one or more AppImages.
1441+
14381442
${Gold}icons, --icons\033[0m
14391443
14401444
${LightBlue}$AMCLI --icons {PROGRAM}

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Removes all the unnecessary files and folders.
374374
375375
**Description**:
376376
377-
Set a dedicated `$XDD_CONFIG_HOME` for one or more AppImages.
377+
Set a dedicated `$XDG_CONFIG_HOME` for one or more AppImages.
378378
379379
------------------------------------------------------------------------
380380
### `downgrade`, `--rollback`
@@ -445,6 +445,15 @@ Prevents an installed application from being shown or managed by "am".
445445
446446
Set a dedicated $HOME directory for one or more AppImages.
447447
448+
------------------------------------------------------------------------
449+
### `-HC`, `-CH`
450+
451+
am -HC {PROGRAM}
452+
453+
**Description**:
454+
455+
Set dedicated $HOME and $XDG_CONFIG_HOME directories for one or more AppImages.
456+
448457
------------------------------------------------------------------------
449458
### `icons`, `--icons`
450459

modules/management.am

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
##############################################################################################
44
# THIS MODULE INCLUDES ALL THE ACTIONS INTENDED TO MANAGE THE APPS INSTALLED FROM THE DATABASE
55
# AND ONE OPTION IS FOR LOCAL APPIMAGES INSTEAD
6-
# OPTIONS: BACKUP/RESTORE, DOWNGRADE, LAUNCHER, LOCK/UNLOCK, NOLIBFUSE, REMOVE
6+
# OPTIONS: BACKUP/RESTORE, CONFIG/HOME, DOWNGRADE, LAUNCHER, LOCK/UNLOCK, NOLIBFUSE, REMOVE
77
##############################################################################################
88

9-
# BACKUP
9+
################################################################################################################################################################
10+
# BACKUP
11+
################################################################################################################################################################
12+
1013
_backup_name() {
1114
printf "\n ◆ To set date and time as a name, press ENTER (default)\n ◆ To set the version as a name, press \"1\"\n ◆ To set a custom name, write anything else\n\n"
1215
read -r -p " Write your choice here, or leave blank to use \"date/time\": " response
@@ -48,7 +51,10 @@ _backup() {
4851
echo "$DIVIDING_LINE"
4952
}
5053

51-
# RESTORE
54+
################################################################################################################################################################
55+
# RESTORE
56+
################################################################################################################################################################
57+
5258
_overwrite() {
5359
if [ ! -d "$HOME/.am-snapshots/$2" ]; then
5460
echo " ERROR: No snapshot for \"$2\" found."
@@ -77,7 +83,40 @@ _overwrite() {
7783
echo "$DIVIDING_LINE"
7884
}
7985

80-
# DOWNGRADE
86+
################################################################################################################################################################
87+
# CONFIG/HOME
88+
################################################################################################################################################################
89+
90+
_isolate_appimage() {
91+
_determine_args
92+
if [ -z "$argpath" ]; then
93+
printf " ✖ ERROR: \"%b\" is not installed\n" "$arg"
94+
elif [ -f "$argpath"/"$arg" ] && ! head -c10 "$argpath"/"$arg" 2>/dev/null | grep -qa '^.ELF....AI$'; then
95+
printf " ✖ ERROR: \"%b\" is NOT an AppImage\n" "$arg"
96+
else
97+
if echo "$1" | grep -q -- "C\|config$"; then
98+
if [ -d "$argpath"/"$arg".config ]; then
99+
echo "✖ ERROR: \"$arg\" already contains a config dir" | _fit
100+
else
101+
mkdir "$argpath"/"$arg".config || return 1
102+
echo "\$XDG_CONFIG_HOME set to \"$argpath.config\" for \"$arg\"" | _fit
103+
fi
104+
fi
105+
if echo "$1" | grep -q -- "H\|home$"; then
106+
if [ -d "$argpath"/"$arg".home ]; then
107+
echo "✖ ERROR: \"$arg\" already contains a home dir" | _fit
108+
else
109+
mkdir "$argpath"/"$arg".home || return 1
110+
echo "\$HOME set to \"$argpath.home\" for \"$arg\"" | _fit
111+
fi
112+
fi
113+
fi
114+
}
115+
116+
################################################################################################################################################################
117+
# DOWNGRADE
118+
################################################################################################################################################################
119+
81120
_downgrade_entries_filter() {
82121
grep -vi "^#\|version0=" ./AM-updater | grep "api.github.com" \
83122
| tr '=' '\n' | sed 's/^\$(//g' \
@@ -141,7 +180,10 @@ _downgrade() {
141180
echo "ROLLBACK SUCCESSFUL!"
142181
}
143182

144-
# ICON THEME CHANGER
183+
################################################################################################################################################################
184+
# ICON THEME CHANGER
185+
################################################################################################################################################################
186+
145187
_icon_theme() {
146188
if [ "$AMCLI" = am ] && test -f /usr/local/share/applications/"$arg"*AM.desktop; then
147189
$SUDOCMD sed -i "s#Icon=$argpath/icons/#Icon=#g" /usr/local/share/applications/"$arg"*AM.desktop 2>/dev/null
@@ -151,7 +193,10 @@ _icon_theme() {
151193
_icon_theme_export_to_datadir 2>/dev/null
152194
}
153195

154-
# LAUNCHER
196+
################################################################################################################################################################
197+
# LAUNCHER
198+
################################################################################################################################################################
199+
155200
_launcher_appimage_integration() {
156201
if grep -Eaoq -m 1 "appimage-extract" "$arg"; then
157202
"$arg" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$appimage".desktop
@@ -252,7 +297,10 @@ _launcher(){
252297
fi
253298
}
254299

255-
# LOCK/UNLOCK
300+
################################################################################################################################################################
301+
# LOCK/UNLOCK
302+
################################################################################################################################################################
303+
256304
_lock() {
257305
if [ ! -f "$argpath"/AM-updater ]; then
258306
echo " \"$AMCLIUPPER\" cannot manage updates for $2, \"AM-updater\" file not found!"
@@ -283,7 +331,10 @@ _unlock() {
283331
fi
284332
}
285333

286-
# NO LIBFUSE
334+
################################################################################################################################################################
335+
# NO LIBFUSE
336+
################################################################################################################################################################
337+
287338
_nolibfuse() {
288339
AMCLIPATH_ORIGIN="$AMCLIPATH"
289340
target="$(echo "${2}" | tr '[:lower:]' '[:upper:]')"
@@ -365,7 +416,10 @@ _nolibfuse() {
365416
fi
366417
}
367418

368-
# REMOVE
419+
################################################################################################################################################################
420+
# REMOVE
421+
################################################################################################################################################################
422+
369423
_detect_path_to_remove() {
370424
if [ -f "$APPMAN_APPSPATH"/"$arg"/remove ]; then
371425
RMPATH="1"
@@ -405,9 +459,9 @@ _hard_remove() {
405459
[ -d "$DATADIR"/icons/hicolor/scalable/apps ] && find "$DATADIR"/icons/hicolor/scalable/apps -xtype l -exec rm {} \;
406460
}
407461

408-
###########################################################################
409-
# OPTIONS AVAILABLE IN THIS MODULE
410-
###########################################################################
462+
################################################################################################################################################################
463+
# USAGE
464+
################################################################################################################################################################
411465

412466
# Main logic
413467
[ -z "$2" ] && echo " USAGE: $AMCLI $1 [ARGUMENT]" && exit 1
@@ -423,6 +477,19 @@ case "$1" in
423477
done
424478
;;
425479

480+
'config'|'-C'|'--config'|'home'|'-H'|'--home'|'-HC'|'-CH'|'HC'|'CH')
481+
# Set dedicated $HOME and $XDG_CONFIG_HOME directories for one or more AppImages.
482+
_determine_args
483+
echo "$DIVIDING_LINE"
484+
entries="$(echo "$@" | cut -f2- -d ' ')"
485+
for arg in $entries; do
486+
argpath=$(echo "$ARGPATHS" | grep "/$arg$")
487+
_isolate_appimage "${@}"
488+
echo "$DIVIDING_LINE"
489+
argpath=""
490+
done
491+
;;
492+
426493
'downgrade'|'--rollback')
427494
# Downgrade the installed app to a previous version, from its online source
428495
_online_check

modules/sandboxes.am

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,6 @@ _check_appimage() {
3838
fi
3939
}
4040

41-
_home() {
42-
if [ -d "$APPIMAGE.home" ]; then
43-
echo " ERROR: \"$1\" already contains a home dir"
44-
return 1
45-
fi
46-
mkdir "$APPIMAGE.home" || return 1
47-
echo " \$HOME set to \"$APPIMAGE.home\" for \"$1\""
48-
}
49-
50-
_config() {
51-
if [ -d "$APPIMAGE.config" ]; then
52-
echo " ERROR: \"$1\" already contains a config dir"
53-
return 1
54-
fi
55-
mkdir "$APPIMAGE.config" || return 1
56-
echo " \$XDG_CONFIG_HOME set to \"$APPIMAGE.config\" for \"$1\""
57-
}
58-
5941
_disable_sandbox() {
6042
TARGET="$(command -v "$1")"
6143
if ! grep "aisap-am sandboxing script" "$TARGET" >/dev/null 2>&1; then
@@ -286,21 +268,5 @@ case "$1" in
286268
shift
287269
done
288270
;;
289-
290-
'-H'|'--home')
291-
shift
292-
while [ "$#" -gt 0 ]; do
293-
_check_appimage "${@}" && _home "${@}"
294-
shift
295-
done
296-
;;
297-
298-
'-C'|'--config')
299-
shift
300-
while [ "$#" -gt 0 ]; do
301-
_check_appimage "${@}" && _config "${@}"
302-
shift
303-
done
304-
;;
305271
esac
306272
_remove_info_files

0 commit comments

Comments
 (0)