mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Update xdg-mime helper
This will respect the `/usr/local/share/applications/` directory when fetching mime infos. Update xdg-mime helper to comply with the xdg spec. This also makes sure __fish_print_xdg_applications_directories only prints directories that exist. Relevant specs: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html https://specifications.freedesktop.org/desktop-entry-spec/latest/ape.html
This commit is contained in:
parent
c611943cc2
commit
5eb0b34da1
5 changed files with 25 additions and 7 deletions
|
@ -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'
|
||||
|
||||
|
|
|
@ -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
|
3
share/functions/__fish_print_xdg_desktop_file_ids.fish
Normal file
3
share/functions/__fish_print_xdg_desktop_file_ids.fish
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue