From 58e1f64f8af2afcfe3ecbadc29f9f340df7eb0f2 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Wed, 1 Jun 2022 01:01:54 +0200 Subject: [PATCH] bin: create xdg-mime-file to edit mimeapps --- .config/mimeapps.list##user.janek | 3 +-- .local/bin/scripts/b | 4 ++-- .local/bin/scripts/xdg-mime-file | 9 +++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100755 .local/bin/scripts/xdg-mime-file diff --git a/.config/mimeapps.list##user.janek b/.config/mimeapps.list##user.janek index ba0bf6e..6df1d35 100644 --- a/.config/mimeapps.list##user.janek +++ b/.config/mimeapps.list##user.janek @@ -1,6 +1,5 @@ [Added Associations] application/java-archive=org.kde.ark.desktop; -application/pdf=org.kde.okular.desktop; application/rss+xml=nvim.desktop; application/x-java-archive=java-2.desktop;java.desktop;jconsole-java11-openjdk.desktop; application/x-ms-shortcut=firefox.desktop; @@ -20,7 +19,7 @@ text/plain=nvim.desktop;emacs.desktop;okularApplication_txt.desktop; x-scheme-handler/tg=telegram.desktop; [Default Applications] -application/pdf=org.kde.okular.desktop; +application/pdf=org.pwmt.zathura.desktop; application/x-java-archive=java-2.desktop; application/x-ms-shortcut=firefox.desktop; application/x-mswinurl=firefox.desktop; diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 1aeafc9..5eb154f 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -17,7 +17,7 @@ test "$1" = "-v" && set -eo xtrace && shift inspect=false -# Show file info without preview +# inspect: Show file info without preview test "$1" = "-i" && inspect=true && shift @@ -30,7 +30,7 @@ fileinfo() { tput setaf 6 for arg do case "$arg" in (-*) continue;; esac - $elevate file -E "$arg" + $elevate file --exclude elf -E "$arg" # TODO do not grep bitrate but extract properly #probe="$($elevate ffprobe "$arg" 2>&1)" #echo $probe | grep -v -e '00:00:00.04' -e 'ansi' && diff --git a/.local/bin/scripts/xdg-mime-file b/.local/bin/scripts/xdg-mime-file new file mode 100755 index 0000000..d9f2235 --- /dev/null +++ b/.local/bin/scripts/xdg-mime-file @@ -0,0 +1,9 @@ +#!/bin/sh -e +# Use xdg-mime with a file's mime type +xdg-mime query default "$(xdg-mime query filetype "$1")" +test $# -gt 1 && + desktop="$(find /usr/share/applications -name "*$2*" | fzf -0 -1)" && + xdg-mime default "$desktop" "$(xdg-mime query filetype "$1")" && + echo -n "Updated to: " && + xdg-mime query default "$(xdg-mime query filetype "$1")" +# || echo "Cannot find application $2 in /usr/share/applications!"