From 840f1e3bdd34b0b4b8d1d199ef6e97b6f1a1951d Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Fri, 18 Sep 2020 00:13:07 +0300 Subject: Use solely mimeo to handle default files/links --- dotfiles/.config/mimeapps.list | 7 ++- dotfiles/.config/mimeo/associations.txt | 22 +++++++ dotfiles/.config/mimeo/default_arguments.txt | 1 + dotfiles/.config/ranger/scope.sh | 71 ---------------------- dotfiles/.local/bin/imgurl | 6 ++ dotfiles/.local/bin/linkhandler | 23 ------- dotfiles/.local/bin/menuwebsurf | 7 +-- dotfiles/.local/share/applications/aerc.desktop | 6 ++ .../.local/share/applications/imageviewer.desktop | 11 ++++ dotfiles/.local/share/applications/imv.desktop | 14 ----- 10 files changed, 53 insertions(+), 115 deletions(-) create mode 100644 dotfiles/.config/mimeo/associations.txt create mode 100644 dotfiles/.config/mimeo/default_arguments.txt create mode 100755 dotfiles/.local/bin/imgurl delete mode 100755 dotfiles/.local/bin/linkhandler create mode 100644 dotfiles/.local/share/applications/aerc.desktop create mode 100644 dotfiles/.local/share/applications/imageviewer.desktop delete mode 100644 dotfiles/.local/share/applications/imv.desktop (limited to 'dotfiles') diff --git a/dotfiles/.config/mimeapps.list b/dotfiles/.config/mimeapps.list index f15c469..9dd144e 100644 --- a/dotfiles/.config/mimeapps.list +++ b/dotfiles/.config/mimeapps.list @@ -4,9 +4,9 @@ application/rdf+xml=org.qutebrowser.qutebrowser.desktop; application/xhtml+xml=org.qutebrowser.qutebrowser.desktop; application/xml=org.qutebrowser.qutebrowser.desktop; audio/mpeg=mpv.desktop; -image/gif=imv.desktop; -image/jpeg=imv.desktop; -image/png=imv.desktop; +image/gif=imageviewer.desktop; +image/jpeg=imageviewer.desktop; +image/png=imageviewer.desktop; text/html=org.qutebrowser.qutebrowser.desktop; text/xml=nvim.desktop; text/plain=nvim.desktop; @@ -15,3 +15,4 @@ x-scheme-handler/http=org.qutebrowser.qutebrowser.desktop; x-scheme-handler/https=org.qutebrowser.qutebrowser.desktop; x-scheme-handler/qute=org.qutebrowser.qutebrowser.desktop; x-scheme-handler/discord-455712169795780630=discord-455712169795780630.desktop +x-scheme-handler/mailto=aerc.desktop diff --git a/dotfiles/.config/mimeo/associations.txt b/dotfiles/.config/mimeo/associations.txt new file mode 100644 index 0000000..9a666ec --- /dev/null +++ b/dotfiles/.config/mimeo/associations.txt @@ -0,0 +1,22 @@ +mpv --input-ipc-server=/tmp/mpvsock -quiet %U >/dev/null 2>&1 + ^https?://(www.)?youtube.com/watch\?.*v= + ^https?://youtu.be/ + ^https?://.*\.mkv + ^https?://.*\.webm + ^https?://.*\.mp4 + +imgurl %U + ^https?://.*\.png + ^https?://.*\.jpg + ^https?://.*\.jpe + ^https?://.*\.jpeg + ^https?://.*\.gif + ^https?://.*\.bmp + +libreoffice %F + \.doc + \.docx + \.xls + \.xlsx + \.ppt + \.pptx diff --git a/dotfiles/.config/mimeo/default_arguments.txt b/dotfiles/.config/mimeo/default_arguments.txt new file mode 100644 index 0000000..8be5f30 --- /dev/null +++ b/dotfiles/.config/mimeo/default_arguments.txt @@ -0,0 +1 @@ +--term 'termite -e' diff --git a/dotfiles/.config/ranger/scope.sh b/dotfiles/.config/ranger/scope.sh index 940c9ba..dcb0752 100755 --- a/dotfiles/.config/ranger/scope.sh +++ b/dotfiles/.config/ranger/scope.sh @@ -89,77 +89,6 @@ handle_extension() { handle_image() { local mimetype="${1}" case "${mimetype}" in - # SVG - image/svg+xml) - convert "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 - exit 1;; - - # Image - image/*) - local orientation - orientation="$( identify -format '%[EXIF:Orientation]\n' -- "${FILE_PATH}" )" - # If orientation data is present and the image actually - # needs rotating ("1" means no rotation)... - if [[ -n "$orientation" && "$orientation" != 1 ]]; then - # ...auto-rotate the image according to the EXIF data. - convert -- "${FILE_PATH}" -auto-orient "${IMAGE_CACHE_PATH}" && exit 6 - fi - - # `w3mimgdisplay` will be called for all images (unless overriden as above), - # but might fail for unsupported types. - exit 7;; - - # Video - # video/*) - # # Thumbnail - # ffmpegthumbnailer -i "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" -s 0 && exit 6 - # exit 1;; - # PDF - # application/pdf) - # pdftoppm -f 1 -l 1 \ - # -scale-to-x 1920 \ - # -scale-to-y -1 \ - # -singlefile \ - # -jpeg -tiffcompression jpeg \ - # -- "${FILE_PATH}" "${IMAGE_CACHE_PATH%.*}" \ - # && exit 6 || exit 1;; - - # Preview archives using the first image inside. - # (Very useful for comic book collections for example.) - # application/zip|application/x-rar|application/x-7z-compressed|\ - # application/x-xz|application/x-bzip2|application/x-gzip|application/x-tar) - # local fn=""; local fe="" - # local zip=""; local rar=""; local tar=""; local bsd="" - # case "${mimetype}" in - # application/zip) zip=1 ;; - # application/x-rar) rar=1 ;; - # application/x-7z-compressed) ;; - # *) tar=1 ;; - # esac - # { [ "$tar" ] && fn=$(tar --list --file "${FILE_PATH}"); } || \ - # { fn=$(bsdtar --list --file "${FILE_PATH}") && bsd=1 && tar=""; } || \ - # { [ "$rar" ] && fn=$(unrar lb -p- -- "${FILE_PATH}"); } || \ - # { [ "$zip" ] && fn=$(zipinfo -1 -- "${FILE_PATH}"); } || return - # - # fn=$(echo "$fn" | python -c "import sys; import mimetypes as m; \ - # [ print(l, end='') for l in sys.stdin if \ - # (m.guess_type(l[:-1])[0] or '').startswith('image/') ]" |\ - # sort -V | head -n 1) - # [ "$fn" = "" ] && return - # [ "$bsd" ] && fn=$(printf '%b' "$fn") - # - # [ "$tar" ] && tar --extract --to-stdout \ - # --file "${FILE_PATH}" -- "$fn" > "${IMAGE_CACHE_PATH}" && exit 6 - # fe=$(echo -n "$fn" | sed 's/[][*?\]/\\\0/g') - # [ "$bsd" ] && bsdtar --extract --to-stdout \ - # --file "${FILE_PATH}" -- "$fe" > "${IMAGE_CACHE_PATH}" && exit 6 - # [ "$bsd" ] || [ "$tar" ] && rm -- "${IMAGE_CACHE_PATH}" - # [ "$rar" ] && unrar p -p- -inul -- "${FILE_PATH}" "$fn" > \ - # "${IMAGE_CACHE_PATH}" && exit 6 - # [ "$zip" ] && unzip -pP "" -- "${FILE_PATH}" "$fe" > \ - # "${IMAGE_CACHE_PATH}" && exit 6 - # [ "$rar" ] || [ "$zip" ] && rm -- "${IMAGE_CACHE_PATH}" - # ;; esac } diff --git a/dotfiles/.local/bin/imgurl b/dotfiles/.local/bin/imgurl new file mode 100755 index 0000000..2a2cb37 --- /dev/null +++ b/dotfiles/.local/bin/imgurl @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -z "$1" ] && exit + +setsid curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & + diff --git a/dotfiles/.local/bin/linkhandler b/dotfiles/.local/bin/linkhandler deleted file mode 100755 index 338750d..0000000 --- a/dotfiles/.local/bin/linkhandler +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -# Feed script a url or file location. -# If an image, it will view in sxiv, -# if a video or gif, it will view in mpv -# if a music file or pdf, it will download, -# otherwise it opens link in browser. - -# If no url given opens browser. -[ -z "$1" ] && { "$BROWSER"; exit; } - -case "$1" in - *mkv|*webm|*mp4|*youtube.com*|*youtu.be*|*hooktube.com*|*bitchute.com*) - setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;; - *png|*jpg|*jpe|*jpeg|*gif) - curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; - *mp3|*flac|*opus|*mp3?source*) - setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;; - *://*|*.*) - setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;; - *) # If it's not a url, perform a search using duckduckgo - setsid "$BROWSER" "https://duckduckgo.com/?q=$1&t=ffab&atb=v1-1" >/dev/null 2>&1 & ;; -esac diff --git a/dotfiles/.local/bin/menuwebsurf b/dotfiles/.local/bin/menuwebsurf index 00155c6..bef9890 100755 --- a/dotfiles/.local/bin/menuwebsurf +++ b/dotfiles/.local/bin/menuwebsurf @@ -1,7 +1,6 @@ #!/bin/sh -# menu prompt to open a link or search with duckduckgo if it's -# not a url +# menu prompt to open a link with mimeo # Source settings from .bemenurc . ~/.config/bemenurc @@ -16,8 +15,8 @@ fi choice=$(echo "$prompt" | bemenu -i -p "Enter link or query:" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB" --monitor="$BEMENU_MONITOR") || exit 1 if [ "$choice" = "🌐" ]; then - linkhandler + $BROWSER else - linkhandler "$choice" + mimeo "$choice" fi diff --git a/dotfiles/.local/share/applications/aerc.desktop b/dotfiles/.local/share/applications/aerc.desktop new file mode 100644 index 0000000..84cf639 --- /dev/null +++ b/dotfiles/.local/share/applications/aerc.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=aerc +GenericName=Email Client +Exec=aerc %u +Terminal=true +MimeType=x-scheme-handler/mailto diff --git a/dotfiles/.local/share/applications/imageviewer.desktop b/dotfiles/.local/share/applications/imageviewer.desktop new file mode 100644 index 0000000..ba4e1c7 --- /dev/null +++ b/dotfiles/.local/share/applications/imageviewer.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=ImageViewer +GenericName=Image viewer +GenericName[en_US]=Image viewer +Exec=sxiv-rifle %f +NoDisplay=true +Terminal=false +Type=Application +MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-tga;image/x-xbitmap; +Icon=multimedia-photo-viewer +Keywords=photo;picture; diff --git a/dotfiles/.local/share/applications/imv.desktop b/dotfiles/.local/share/applications/imv.desktop deleted file mode 100644 index d558282..0000000 --- a/dotfiles/.local/share/applications/imv.desktop +++ /dev/null @@ -1,14 +0,0 @@ -[Desktop Entry] -Name=imv -GenericName=Image viewer -GenericName[en_US]=Image viewer -Comment=Fast freeimage-based Image Viewer -Exec=imv-rifle %f -NoDisplay=true -Terminal=false -Type=Application -Categories=Graphics;2DGraphics;Viewer; -MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/pjpeg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-png;image/x-portable-anymap;image/x-portable-bitmap;image/x-portable-graymap;image/x-portable-pixmap;image/x-tga;image/x-xbitmap; -Name[en_US]=imv -Icon=multimedia-photo-viewer -Keywords=photo;picture; -- cgit v1.2.3