dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit f11804bb51f7fe56ef345dfe77faa0e0a3e81585
parent 8f914396014d87d553b73b380ced97ecc25f0454
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed, 14 Aug 2019 09:00:18 +0200

Handle images as any other link

Diffstat:
M.local/bin/linkhandler | 78++++++++++++++++++++++++++++++++++++------------------------------------------
1 file changed, 36 insertions(+), 42 deletions(-)

diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler @@ -3,48 +3,42 @@ mkdir -p ~/tmp cd ~/tmp || exit 42 for url in "$@"; do - case "$url" in - *png|*jpg|*jpe|*jpeg) - setsid sxiv "$url" >/dev/null 2>&1 & ;; + if [ -f "$url" ]; then + setsid "$TERMINAL" -e "$EDITOR $url" + exit 0; + fi + action="$(printf "open\nopen (tbb)\nxclip\nbookmark\ncurl\nhtml to pdf\nsci-hub\nadd bibref\nmpv\nyoutube-dl\nyoutube-dl-music" | \ + dmenu_themed -i -p "action:")" + case "$action" in + "open") + setsid xdg-open "$url" >/dev/null 2>&1 & ;; + "open (tbb)") + setsid tor-browser "$url" >/dev/null 2>&1 & ;; + "xclip") + printf "%s" "$url" | xclip ;; + "bookmark") + description="$(echo "$(date), $hostname" | \ + dmenu_themed -p "description:")" + setsid $TERMINAL bookmark "$url" "$description" & ;; + "curl") + setsid tsp curl -LO "$url" >/dev/null 2>&1 & ;; + "html to pdf") + out="$HOME/tmp/html_to_pdf_$(date +'%F-%T')".pdf && \ + wkhtmltopdf "$url" "$out" && \ + notify-send "$(basename $out) complete" ;; + "sci-hub") + setsid tsp shdl --tor-socks --notify --open --reference \ + "$url" >/dev/null 2>&1 & ;; + "add bibref") + getdoi "$url" | getref --notify >> "$BIB" & ;; + "mpv") + setsid mpv -quiet "$url" >/dev/null 2>&1 & ;; + "youtube-dl") + setsid tsp youtube-dl "$url" >/dev/null 2>&1 & ;; + "youtube-dl-music") + setsid $TERMINAL -e youtube-dl-music "$url" & ;; *) - if [ -f "$url" ]; then - setsid "$TERMINAL" -e "$EDITOR $url" - exit 0; - fi - action="$(printf "open\nopen (tbb)\nxclip\nbookmark\ncurl\nhtml to pdf\nsci-hub\nadd bibref\nmpv\nyoutube-dl\nyoutube-dl-music" | \ - dmenu_themed -i -p "action:")" - - case "$action" in - "open") - setsid xdg-open "$url" >/dev/null 2>&1 & ;; - "open (tbb)") - setsid tor-browser "$url" >/dev/null 2>&1 & ;; - "xclip") - printf "%s" "$url" | xclip ;; - "bookmark") - description="$(echo "$(date), $hostname" | \ - dmenu_themed -p "description:")" - setsid $TERMINAL bookmark "$url" "$description" & ;; - "curl") - setsid tsp curl -LO "$url" >/dev/null 2>&1 & ;; - "html to pdf") - out="$HOME/tmp/html_to_pdf_$(date +'%F-%T')".pdf && \ - wkhtmltopdf "$url" "$out" && \ - notify-send "$(basename $out) complete" ;; - "sci-hub") - setsid tsp shdl --tor-socks --notify --open --reference \ - "$url" >/dev/null 2>&1 & ;; - "add bibref") - getdoi "$url" | getref --notify >> "$BIB" & ;; - "mpv") - setsid mpv -quiet "$url" >/dev/null 2>&1 & ;; - "youtube-dl") - setsid tsp youtube-dl "$url" >/dev/null 2>&1 & ;; - "youtube-dl-music") - setsid $TERMINAL -e youtube-dl-music "$url" & ;; - *) - notify-send "${0##/*}" "Error: Action not understood" - exit 1 ;; - esac + notify-send "${0##/*}" "Error: Action not understood" + exit 1 ;; esac done