diff --git a/fake_home/.sofi.sh b/fake_home/.sofi.sh index deb8ffd..0956f94 100755 --- a/fake_home/.sofi.sh +++ b/fake_home/.sofi.sh @@ -54,18 +54,22 @@ windows() { fi } +function read_app { + echo "app $(grep '^Name=' "$1" | grep -Eiv "$IGNORED_APPS" | sed 's/Name=//' | head -n 1) <= $1" +} + read_apps() { + export -f read_app + export APP_LOCATIONS + export IGNORED_APPS + if [[ "$1" == "--now" ]]; then - find $APP_LOCATIONS -name '*.desktop' -exec grep '^Name=' {} \; | - egrep -iv "$IGNORED_APPS" | - sed 's/Name=/app /' + # shellcheck disable=SC2086 + find $APP_LOCATIONS -name '*.desktop' -exec bash -c 'read_app "{}"' \; return $? fi cat "$CACHE_FILE" - # shellcheck disable=SC2086 - nohup find $APP_LOCATIONS -name '*.desktop' -exec grep '^Name=' {} \; | - egrep -iv "$IGNORED_APPS" | - sed 's/Name=/app /' > "$CACHE_FILE" & + nohup find $APP_LOCATIONS -name '*.desktop' -exec bash -c 'read_app "{}"' \; } read_snap_apps() { @@ -95,14 +99,8 @@ add-recent() { } open_app() { - app="$(echo "$1" | cut -c 5-)" - # shellcheck disable=SC2086 - find $APP_LOCATIONS -name '*.desktop' | while read -r f; do - if grep "Name=$app" "$f" &> /dev/null; then - setsid exo-open "$f" >/dev/null 2>&1 /dev/null 2>&1