Skip to content

Instantly share code, notes, and snippets.

@uncomfyhalomacro
Created November 27, 2021 00:16
Show Gist options
  • Save uncomfyhalomacro/625192962fa0338230bc0ddde4f11b55 to your computer and use it in GitHub Desktop.
Save uncomfyhalomacro/625192962fa0338230bc0ddde4f11b55 to your computer and use it in GitHub Desktop.
Simple launcher with foot
#!/usr/bin/env bash
# Launcher for executables in $PATH
shopt -s lastpipe
source ~/.bashrc
IFS=: read -ra path <<< "$PATH"
IFS=$'\n' read -r -d '' -a desktops <<< "$(find /usr/share/applications/ -name "*.desktop")"
[ -x "$(which flatpak)" ] && IFS=$'\n' read -r -d '' -a flatapps <<< "$(flatpak list --columns=application | tail -n +1)"
[ -x "$(which flatpak)" ] && for i in "${flatapps[@]}"
do
flatrun=("${flatrun[@]}" "flatpak run ${i}")
done
for p in "${path[@]}"
do
frompaths=("${frompaths[@]}" "$(ls ${p})")
done
for i in "${desktops[@]}"
do
desktopexecs=("${desktopexecs[@]}" "$(cat "${i}" | awk '/^Exec=/{sub(/^Exec=/,""); print}')");
done
allapps=("${frompaths[@]}" "${flatrun[@]}" "${desktopexecs[@]}")
for e in "${allapps[@]}"
do
echo "$e"
#done | uniq | bemenu -l 20 --prompt='launch: ' | read -r cmd
done | uniq | fzf -e -i --prompt='launch: ' | read -r cmd
[ -z "${cmd}" ] && exit
# Needs foot and river but you can use other to launcher it as well such as eval or exec but make sure
# it does not kill it by accidentally invoking a terminal or whatever.
riverctl spawn "source ~/.bashrc; ${cmd}"
#eval "${cmd} & disown"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment