Skip to content

Commit 7c39892

Browse files
authored
Merge pull request #634 from ivan-hc/dev
Shows the total size of installed apps
2 parents 096def2 + 7e821d5 commit 7c39892

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

APP-MANAGER

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

3-
AMVERSION="6.10.2"
3+
AMVERSION="6.10.3"
44

55
# Determine main repository and branch
66
AMREPO="https://raw.githubusercontent.com/ivan-hc/AM/main"

modules/files.am

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh
22

33
##########################################################################
44
# THIS MODULE ALLOWS YOU TO SEE THE MAIN INFORMATION ON THE INSTALLED APPS
55
##########################################################################
66

7-
function _files_header() {
7+
_files_header() {
88
echo ""
9-
echo $(echo "YOU HAVE INSTALLED "
10-
cd "$APPSPATH" &&
11-
find . -type f -name 'remove' 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | wc -l
9+
echo $(echo "- YOU HAVE INSTALLED "
10+
find "$APPSPATH" -type f -name 'remove' 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | wc -l
1211
if grep -q 'usr/local/lib' $APPSPATH/*/remove 2> /dev/null; then
1312
echo " STANDALONE PROGRAMS AND LIBRARIES MANAGED BY '$(echo $AMCLI | tr a-z A-Z)':"
1413
else
@@ -17,42 +16,42 @@ function _files_header() {
1716
echo ""
1817
}
1918
20-
function _files_sizes() {
19+
_files_sizes() {
2120
if grep -q "usr/local/lib" ./$arg/remove; then
2221
LIBNAME=$(cat $APPSPATH/$arg/remove | tr ' ' '\n' | grep "usr/local/lib" | head -1)
2322
SIZE=$(du -sh $LIBNAME | cut -f1 | sort -rh | head -1)
2423
else
2524
SIZE=$(du -sh -- $arg | cut -f1 -d" ")
2625
fi
27-
SIZE=$(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')
26+
SIZE=$(echo "$SIZE" | sed 's/.$/ &/; s/$/iB/')
2827
echo "$arg | $SIZE" >> "$AMCACHEDIR"/files-sizes
2928
}
3029
31-
function _files_if_binary_executable() {
30+
_files_if_binary_executable() {
3231
echo "$arg | binary/executable" >> "$AMCACHEDIR"/files-type
3332
}
3433
35-
function _files_if_unknown() {
34+
_files_if_unknown() {
3635
echo "$arg | unknown" >> "$AMCACHEDIR"/files-type
3736
}
3837
39-
function _files_if_other() {
38+
_files_if_other() {
4039
echo "$arg | other" >> "$AMCACHEDIR"/files-type
4140
}
4241
43-
function _files_if_launcher() {
42+
_files_if_launcher() {
4443
echo "$arg | launcher" >> "$AMCACHEDIR"/files-type
4544
}
4645
47-
function _files_if_set_tools() {
46+
_files_if_set_tools() {
4847
echo "$arg | set/tools" >> "$AMCACHEDIR"/files-type
4948
}
5049
51-
function _files_if_library() {
50+
_files_if_library() {
5251
echo "$arg | library" >> "$AMCACHEDIR"/files-type
5352
}
5453
55-
function _files_if_script() {
54+
_files_if_script() {
5655
if test -f $APPSPATH/$arg/bin/$arg; then
5756
_files_if_binary_executable
5857
elif test -f $APPSPATH/$arg/$arg-bin; then
@@ -62,15 +61,15 @@ function _files_if_script() {
6261
fi
6362
}
6463
65-
function _files_if_appimage() {
64+
_files_if_appimage() {
6665
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'AppImages require FUSE to run')" ] 2>/dev/null; then
6766
echo "$arg | appimage-type3" >> "$AMCACHEDIR"/files-type
6867
else
6968
echo "$arg | appimage-type2" >> "$AMCACHEDIR"/files-type
7069
fi
7170
}
7271
73-
function _files_type() {
72+
_files_type() {
7473
APPVERSION=$(cat "$AMCACHEDIR"/version-args | grep -w "$arg |" | sed 's:.*| ::')
7574
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'if you run it with the --appimage-extract option')" ] 2>/dev/null; then
7675
string=$(strings -d "./$arg/$arg" 2>/dev/null | head -1 )
@@ -95,7 +94,7 @@ function _files_type() {
9594
elif cat "./$arg/remove" | tail -1 | grep -q 'xtype l -exec rm'; then
9695
_files_if_set_tools
9796
elif echo "$realstring" | grep -q "#!"; then
98-
script2path=$(cat "$link_in_path" | tail -1 | sed 's#$APP#'$arg'#g' | sed 's#exec ##g')
97+
script2path=$(cat "$link_in_path" | tail -1 | sed 's#$APP#'$arg'#g; s#exec ##g')
9998
realrealstring=$(strings -d "$script2path" 2>/dev/null | head -1 )
10099
if echo "$realrealstring" | grep -q "ld-linux"; then
101100
_files_if_binary_executable
@@ -119,7 +118,7 @@ function _files_type() {
119118
fi
120119
}
121120
122-
function _files_files() {
121+
_files_files() {
123122
cd $APPSPATH &&
124123
INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
125124
if ! test -f "$AMCACHEDIR"/version-args; then
@@ -140,7 +139,7 @@ function _files_files() {
140139
done
141140
}
142141
143-
function _files() {
142+
_files() {
144143
_files_files
145144
rm -f "$AMCACHEDIR"/files-args
146145
INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
@@ -154,30 +153,29 @@ function _files() {
154153
done
155154
}
156155
157-
function _files_show_only_number() {
158-
cd "$APPSPATH" &&
159-
find . -type f -name 'remove' 2>/dev/null | sed -r 's|/[^/]+$||' | sort | uniq | wc -l
156+
_files_show_only_number() {
157+
find "$APPSPATH" -type f -name 'remove' 2>/dev/null | uniq | wc -l
160158
exit 0
161159
}
162160
163-
function _files_sort_by_name() {
161+
_files_sort_by_name() {
164162
_files_header
165163
rm -f "$AMCACHEDIR"/files-args-byname
166164
_files
167165
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname
168166
cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname
169167
cat "$AMCACHEDIR"/files-args-byname | column -t
170-
echo ""
168+
echo -e "\n TOTAL SIZE: $(du -ch $(find -name 'remove' -printf "%h\n" 2>/dev/null) 2>/dev/null | tail -1 | awk '{print $1}' | sed 's/.$/ &/; s/$/iB/') of disk space in use\n"
171169
}
172170
173-
function _files_sort_by_size() {
171+
_files_sort_by_size() {
174172
_files_header
175173
rm -f "$AMCACHEDIR"/files-args-bysize
176174
_files
177175
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize
178176
cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
179177
cat "$AMCACHEDIR"/files-args-bysize | column -t
180-
echo ""
178+
echo -e "\n TOTAL SIZE: $(du -ch $(find -name 'remove' -printf "%h\n" 2>/dev/null) 2>/dev/null | tail -1 | awk '{print $1}' | sed 's/.$/ &/; s/$/iB/') of disk space in use\n"
181179
}
182180
183181
if [ "$2" = "--less" ]; then

0 commit comments

Comments
 (0)