Files
illogical-impulse/tetrio/.config/eww/scripts/appsearch
T
2024-02-22 15:35:06 +07:00

65 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/bash
IFS=$'\n'
entrynames=( $(cat 'scripts/cache/entrynames.txt' | fzf --filter="$1" | head -n 10) )
entries=( $(cat 'scripts/cache/entries.txt') )
definitelyNotMath() {
if [[ ${1:0:1} != "0" \
&& ${1:0:1} != "1" \
&& ${1:0:1} != "2" \
&& ${1:0:1} != "3" \
&& ${1:0:1} != "4" \
&& ${1:0:1} != "5" \
&& ${1:0:1} != "6" \
&& ${1:0:1} != "7" \
&& ${1:0:1} != "8" \
&& ${1:0:1} != "9" ]]; then
echo 'true'
else
echo 'false'
fi
}
if [[ "$1" == ">"* ]]; then
cd ~/.config/eww
if [[ "$1" == ">load"* ]]; then
searching=$(echo "$1" | sed 's/>load //g' | sed 's/>load//g')
profilenames=( $(ls css/savedcolors/ | grep .txt | sed 's/_iconcolor_//g' | sed 's/.txt//g' | fzf --filter="$searching") )
echo -n '['
for x in "${!profilenames[@]}"; do
if [ "$x" != "0" ]; then
printf ','
fi
echo -n '{"name": "'"${profilenames[x]}"'", "exec": ">load '"${profilenames[x]}"'"}'
done
echo -n ']'
else
echo '[]'
fi
exit 0
fi
if [[ "${!entrynames[@]}" == "" && $(definitelyNotMath "$1") == "false" ]]; then
mathAns=$(qalc $1 | head -n 1)
mathAns="${mathAns#*= }"
mathAns="${mathAns#*≈ }"
if [[ "$mathAns" == *"error"* ]]; then
echo '[]'
exit 0
else
echo '[{"name": "'"$mathAns"'", "exec": "wl-copy \"'"$mathAns"'\""}]'
fi
exit 0
fi
printf '['
for x in "${!entrynames[@]}"; do
if [ "$x" != "0" ]; then
printf ','
fi
echo -n $(echo $entries | gojq -c '."'"${entrynames[x]}"'"')
done
printf ']'