Created
November 27, 2021 00:16
-
-
Save uncomfyhalomacro/625192962fa0338230bc0ddde4f11b55 to your computer and use it in GitHub Desktop.
Simple launcher with foot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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