Skip to content

Commit db05d66

Browse files
authored
Merge pull request #631 from ivan-hc/dev
Monitor changes in the size of your installed apps!
2 parents ce9bbbd + d45414f commit db05d66

File tree

2 files changed

+43
-31
lines changed

2 files changed

+43
-31
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.1"
3+
AMVERSION="6.10.2"
44

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

modules/files.am

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,32 @@ function _files_sizes() {
2424
else
2525
SIZE=$(du -sh -- $arg | cut -f1 -d" ")
2626
fi
27+
SIZE=$(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')
28+
echo "$arg | $SIZE" >> "$AMCACHEDIR"/files-sizes
2729
}
2830
2931
function _files_if_binary_executable() {
30-
echo "$arg | $APPVERSION | binary/executable | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
32+
echo "$arg | binary/executable" >> "$AMCACHEDIR"/files-type
3133
}
3234
3335
function _files_if_unknown() {
34-
echo "$arg | $APPVERSION | unknown | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
36+
echo "$arg | unknown" >> "$AMCACHEDIR"/files-type
3537
}
3638
3739
function _files_if_other() {
38-
echo "$arg | $APPVERSION | other | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
40+
echo "$arg | other" >> "$AMCACHEDIR"/files-type
3941
}
4042
4143
function _files_if_launcher() {
42-
echo "$arg | $APPVERSION | launcher | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
44+
echo "$arg | launcher" >> "$AMCACHEDIR"/files-type
4345
}
4446
4547
function _files_if_set_tools() {
46-
echo "$arg | $APPVERSION | set/tools | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
48+
echo "$arg | set/tools" >> "$AMCACHEDIR"/files-type
4749
}
4850
4951
function _files_if_library() {
50-
echo "$arg | $APPVERSION | library | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
52+
echo "$arg | library" >> "$AMCACHEDIR"/files-type
5153
}
5254
5355
function _files_if_script() {
@@ -56,15 +58,15 @@ function _files_if_script() {
5658
elif test -f $APPSPATH/$arg/$arg-bin; then
5759
_files_if_binary_executable
5860
else
59-
echo "$arg | $APPVERSION | script | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
61+
echo "$arg | script" >> "$AMCACHEDIR"/files-type
6062
fi
6163
}
6264
6365
function _files_if_appimage() {
6466
if [ -z "$(strings -d "./$arg/$arg" 2>/dev/null | grep -F 'AppImages require FUSE to run')" ] 2>/dev/null; then
65-
echo "$arg | $APPVERSION | appimage-type3 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
67+
echo "$arg | appimage-type3" >> "$AMCACHEDIR"/files-type
6668
else
67-
echo "$arg | $APPVERSION | appimage-type2 | $(echo "$SIZE" | sed 's/.$/ &/' | sed 's/$/iB/')" >> "$AMCACHEDIR"/files-args
69+
echo "$arg | appimage-type2" >> "$AMCACHEDIR"/files-type
6870
fi
6971
}
7072
@@ -117,17 +119,37 @@ function _files_type() {
117119
fi
118120
}
119121
120-
function _files() {
121-
rm -f "$AMCACHEDIR"/files-args*
122+
function _files_files() {
122123
cd $APPSPATH &&
123124
INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
124125
if ! test -f "$AMCACHEDIR"/version-args; then
125126
_check_version
126127
fi
128+
if ! test -f "$AMCACHEDIR"/files-type; then
129+
for arg in $INSTALLED_APPS; do
130+
if test -f ./$arg/remove 2>/dev/null; then
131+
_files_type
132+
fi
133+
done
134+
fi
135+
rm -f "$AMCACHEDIR"/files-sizes
136+
for arg in $INSTALLED_APPS; do
137+
if test -f ./$arg/remove 2>/dev/null; then
138+
_files_sizes
139+
fi
140+
done
141+
}
142+
143+
function _files() {
144+
_files_files
145+
rm -f "$AMCACHEDIR"/files-args
146+
INSTALLED_APPS=$(find -name 'remove' -printf "%h\n" 2>/dev/null | du -sh -- * 2> /dev/null | sort -rh | sed 's@.* @@')
127147
for arg in $INSTALLED_APPS; do
128-
if test -f ./$arg/remove 2>/dev/null; then
129-
_files_sizes
130-
_files_type
148+
if test -f ./$arg/remove 2>/dev/null; then
149+
APPVERSION=$(cat "$AMCACHEDIR"/version-args | grep -w "$arg |" | tr ' ' '\n' | tail -1)
150+
APPTYPE=$(cat "$AMCACHEDIR"/files-type | grep -w "$arg |" | tr ' ' '\n' | tail -1)
151+
APPSYZE=$(cat "$AMCACHEDIR"/files-sizes | grep -w "$arg |" | tr ' ' '\n' | tail -1)
152+
echo "$arg | $APPVERSION | $APPTYPE | $APPSYZE" >> "$AMCACHEDIR"/files-args
131153
fi
132154
done
133155
}
@@ -141,29 +163,19 @@ function _files_show_only_number() {
141163
function _files_sort_by_name() {
142164
_files_header
143165
rm -f "$AMCACHEDIR"/files-args-byname
144-
if test -f "$AMCACHEDIR"/files-args; then
145-
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname
146-
cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname
147-
else
148-
_files
149-
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname
150-
cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname
151-
fi
166+
_files
167+
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-byname
168+
cat "$AMCACHEDIR"/files-args 2>/dev/null | sort >> "$AMCACHEDIR"/files-args-byname
152169
cat "$AMCACHEDIR"/files-args-byname | column -t
153170
echo ""
154171
}
155172
156173
function _files_sort_by_size() {
157174
_files_header
158175
rm -f "$AMCACHEDIR"/files-args-bysize
159-
if test -f "$AMCACHEDIR"/files-args; then
160-
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize
161-
cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
162-
else
163-
_files
164-
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize
165-
cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
166-
fi
176+
_files
177+
echo -e "- APPNAME | VERSION | TYPE | SIZE \n- ------- | ------- | ---- | ----" >> "$AMCACHEDIR"/files-args-bysize
178+
cat "$AMCACHEDIR"/files-args >> "$AMCACHEDIR"/files-args-bysize 2>/dev/null
167179
cat "$AMCACHEDIR"/files-args-bysize | column -t
168180
echo ""
169181
}

0 commit comments

Comments
 (0)