forked from Botspot/pi-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload-daemon
executable file
·38 lines (30 loc) · 1006 Bytes
/
preload-daemon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#runs in the background and refreshes all the list files
DIRECTORY="$(dirname "$(readlink -f "$(dirname "$0")")")"
function error {
echo -e "\e[91m$1\e[39m"
exit 1
}
#variable 1 is yad or xlunch
#variable 2 is 'once', if you only want this to run once and exit.
if [ "$(pgrep preload-daemon | wc -l)" -gt 2 ];then
#echo "Another instance of preload-daemon is already running. Exiting now."
exit 0
fi
#generate list of folders to preload, including special folders
folders="$(cat "${DIRECTORY}/data/categories/structure" | awk -F '|' '{print $2}' | sort | uniq | grep .)
Installed
All Apps"
#echo "$folders"
[ "$1" != yad ] && [ "$1" != xlunch ] && [ ! -z "$1" ] && error "Unrecognized list format $1"
#runs every 30 secs for 10 mins
for i in {1..20};do
IFS=$'\n'
"${DIRECTORY}/preload" "$1" &>/dev/null
for folder in $folders ; do
echo "Preloading $folder..."
"${DIRECTORY}/preload" "$1" "$folder" &>/dev/null
done
[ "$2" == 'once' ] && exit 0
sleep 30
done