diff --git a/share/completions/xdg-mime.fish b/share/completions/xdg-mime.fish index e2b597dce..ff8543d39 100644 --- a/share/completions/xdg-mime.fish +++ b/share/completions/xdg-mime.fish @@ -12,7 +12,7 @@ complete -c xdg-mime -d 'Query default application for type' -n 'contains_seq qu complete -c xdg-mime -d 'Query file\'s filetype' -n 'contains_seq query filetype -- (commandline -cop)' -r # complete xdg-mime default -complete -c xdg-mime -d 'Choose application' -n '__fish_seen_subcommand_from default; and __fish_is_token_n 3' -xa '(__fish_print_xdg_mimeapps)' +complete -c xdg-mime -d 'Choose application' -n '__fish_seen_subcommand_from default; and __fish_is_token_n 3' -xa '(__fish_print_xdg_desktop_file_ids)' complete -c xdg-mime -d 'Mimetype' -n '__fish_seen_subcommand_from default; and __fish_is_token_n 4' -xa '(__fish_print_xdg_mimetypes)' # complete xdg-mime install @@ -29,4 +29,3 @@ complete -c xdg-mime -d 'Set mode' -n 'contains_seq xdg-mime complete -c xdg-mime -l help -d 'Display help' complete -c xdg-mime -l manual -d 'Diplay long help' complete -c xdg-mime -l version -d 'Print version' - diff --git a/share/functions/__fish_print_xdg_applications_directories.fish b/share/functions/__fish_print_xdg_applications_directories.fish new file mode 100644 index 000000000..c4a102aca --- /dev/null +++ b/share/functions/__fish_print_xdg_applications_directories.fish @@ -0,0 +1,20 @@ +function __fish_print_xdg_applications_directories --description 'Print directories where desktop files are stored' + set -l data_home $XDG_DATA_HOME + if test -z "$data_home" + set data_home $HOME/.local/share/ + end + + set -l data_dirs $XDG_DATA_DIRS + if test -z "$data_dirs" + set data_dirs /usr/local/share/:/usr/share/ + end + + set data_dirs $data_home:$data_dirs + + for path in (string split : $data_dirs) + set path $path"applications" + if test -d $path + echo $path + end + end +end diff --git a/share/functions/__fish_print_xdg_desktop_file_ids.fish b/share/functions/__fish_print_xdg_desktop_file_ids.fish new file mode 100644 index 000000000..26673c1b5 --- /dev/null +++ b/share/functions/__fish_print_xdg_desktop_file_ids.fish @@ -0,0 +1,3 @@ +function __fish_print_xdg_desktop_file_ids --description 'Print all available xdg desktop file IDs' + find (__fish_print_xdg_applications_directories) -name \*.desktop \( -type f -or -type l \) -printf '%P\n' | tr / - | sort -u +end diff --git a/share/functions/__fish_print_xdg_mimeapps.fish b/share/functions/__fish_print_xdg_mimeapps.fish deleted file mode 100644 index f5b231418..000000000 --- a/share/functions/__fish_print_xdg_mimeapps.fish +++ /dev/null @@ -1,4 +0,0 @@ -function __fish_print_xdg_mimeapps --description 'Print xdg mime applications' - find ~/.local/share/applications/ /usr/share/applications/ -name \*.desktop \( -type f -or -type l \) -printf '%P\n' | sort -u - -end diff --git a/share/functions/__fish_print_xdg_mimetypes.fish b/share/functions/__fish_print_xdg_mimetypes.fish index 5d944a623..79d4dbf21 100644 --- a/share/functions/__fish_print_xdg_mimetypes.fish +++ b/share/functions/__fish_print_xdg_mimetypes.fish @@ -1,3 +1,3 @@ function __fish_print_xdg_mimetypes --description 'Print XDG mime types' - cat ~/.local/share/applications/mimeinfo.cache /usr/share/applications/mimeinfo.cache ^/dev/null | string match -v '[MIME Cache]' | string replace = \t + cat {__fish_print_xdg_applications_directories}/mimeinfo.cache ^/dev/null | string match -v '[MIME Cache]' | string replace = \t end