diff options
| author | Shivesh Mandalia <mail@shivesh.org> | 2022-01-09 14:49:47 +0000 |
|---|---|---|
| committer | Shivesh Mandalia <mail@shivesh.org> | 2022-01-09 14:49:47 +0000 |
| commit | cc6d87e970c2e5db53c4db770ab5ed85c17044af (patch) | |
| tree | 6c59f485a1809236e035315f85c0ba05a9b82294 | |
| parent | 5d2b8abdddd969977e12b356d060b2dc2d6f616b (diff) | |
| download | sway-launcher-desktop-shivesh.tar.gz sway-launcher-desktop-shivesh.zip | |
modify desktop to search for all dirs under XDG_DATA_DIRS + allow it to list desktop files which are symbolic linksshivesh
| -rwxr-xr-x | sway-launcher-desktop.sh | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 1d06933..42861a9 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -16,8 +16,8 @@ TERMINAL_COMMAND="st -e" # TERMINAL_COMMAND="${TERMINAL_COMMAND:="$TERM -e"}" GLYPH_COMMAND="${GLYPH_COMMAND-📟 }" GLYPH_DESKTOP="${GLYPH_DESKTOP-🖥️ }" -GLYPH_FILES="${GLYPH_FILES-📄 }" -GLYPH_FOLDERS="${GLYPH_FOLDERS-📂 }" +GLYPH_FILES="${GLYPH_FILES-📄 }" +GLYPH_FOLDERS="${GLYPH_FOLDERS-📂 }" CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sway-launcher-desktop" PROVIDERS_FILE="${PROVIDERS_FILE:=providers.conf}" if [[ "${PROVIDERS_FILE#/}" == "${PROVIDERS_FILE}" ]]; then @@ -99,13 +99,13 @@ function list-commands() { function list-entries() { # Get locations of desktop application folders according to spec # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html - IFS=':' read -ra DIRS <<<"${XDG_DATA_HOME-${HOME}/.local/share}:${XDG_DATA_DIRS-/usr/local/share:/usr/share}" + IFS=':' read -ra DIRS <<<"${XDG_DATA_HOME-${HOME}/.local/share}:${XDG_DATA_DIRS}" for i in "${!DIRS[@]}"; do if [[ ! -d "${DIRS[i]}" ]]; then unset -v 'DIRS[$i]' else # DIRS[$i]="${DIRS[i]}/applications/**/*.desktop" - DIRS[$i]=$(find ${DIRS[i]}/applications -type f -name "*.desktop" | tr -s '/') + DIRS[$i]=$(find -L ${DIRS[i]}/applications -type f -name "*.desktop" | tr -s '/' | sort -u) fi done # shellcheck disable=SC2068 @@ -164,8 +164,8 @@ function entries() { # the empty stdin is needed in case no *.desktop files } function list-files() { - find $HOME -maxdepth 5 -path '*/\.*' -prune -o -type d -print | gawk -F / -v pre="$GLYPH_FOLDERS" '{print $0 "\034files\034\033[31m" pre "\033[0m" $NF;}' - find $HOME -maxdepth 5 -path '*/\.*' -prune -o -type f -print | gawk -F / -v pre="$GLYPH_FILES" '{print $0 "\034files\034\033[31m" pre "\033[0m" $NF;}' + find $HOME -maxdepth 5 -type d -path '*/\.*' -prune -o -not -name '.*' -type d -print | sort -u | gawk -F / -v pre="$GLYPH_FOLDERS" '{print $0 "\034files\034\033[31m" pre "\033[0m" $NF;}' + find $HOME -maxdepth 5 -type d -path '*/\.*' -prune -o -not -name '.*' -type f -print | sort -u | gawk -F / -v pre="$GLYPH_FILES" '{print $0 "\034files\034\033[31m" pre "\033[0m" $NF;}' } function run-desktop() { CMD="$("${0}" generate-command "$@" 2>&3)" @@ -290,6 +290,8 @@ readarray -t COMMAND_STR <<<$( --prompt="${GLYPH_PROMPT-# }" \ --header='' --no-info --margin='1,2' \ --color='16,gutter:-1' \ + --algo=v2 \ + --tiebreak=length \ <"$FZFPIPE" ) || exit 1 # Get the last line of the fzf output. If there were no matches, it contains the query which we'll treat as a custom command |
