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 4d84acc605e2444a3dcb716a5b78b65bfe4c8036
parent 0c782701f4e71cca7419b0644d2bf39ebeb2254b
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Tue,  6 Aug 2019 11:35:29 +0200

Improve linkhandler

Diffstat:
M.local/bin/linkhandler | 90+++++++++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 47 insertions(+), 43 deletions(-)

diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler @@ -1,47 +1,51 @@ #!/bin/sh for url in "$@"; do - case "$url" in - *png|*jpg|*jpe|*jpeg) - setsid sxiv "$url" >/dev/null 2>&1 & ;; - *mp3|*flac|*opus|*mp3?source) - setsid tsp curl -LO "$url" >/dev/null 2>&1 & ;; - *) - if [ -f "$url" ]; then - "$TERMINAL" -e "$EDITOR $url" - else - #url="$(printf "%s" "$url" | sed 's|http.*://scholar\.google\..*url=||;s|&rt=.*$||')" - action="$(printf "Open\nOpen (Tor Browser)\nCopy URL\ncURL\nHtml to pdf\nSci-Hub\nAdd reference\nmpv\nyoutube-dl\nyoutube-dl-music" | dmenu_themed -i -p "Action:")" - if [ "$action" = "Open" ]; then - setsid xdg-open "$url" >/dev/null 2>&1 & - elif [ "$action" = "Open (Tor Browser)" ]; then - setsid tor-browser "$url" >/dev/null 2>&1 & - elif [ "$action" = "Copy" ]; then - printf "%s" "$url" | xclip - elif [ "$action" = "Download" ]; then - mkdir -p ~/tmp/ - cd ~/tmp/ || exit 1 - setsid tsp curl -LO "$url" >/dev/null 2>&1 & - elif [ "$action" = "Html to pdf" ]; then - mkdir -p ~/tmp/ - out="$HOME/tmp/html_to_pdf_$(date +'%F-%T')".pdf && \ - wkhtmltopdf "$url" "$out" && \ - notify-send "$(basename $out) complete" - elif [ "$action" = "Sci-Hub" ]; then - setsid tsp shdl --tor-socks --notify --open --reference "$url" >/dev/null 2>&1 & - elif [ "$action" = "Add reference" ]; then - getdoi "$url" | getref --notify >> "$BIB" & - elif [ "$action" = "mpv" ]; then - setsid mpv -quiet "$url" >/dev/null 2>&1 & - elif [ "$action" = "youtube-dl" ]; then - setsid tsp youtube-dl "$url" >/dev/null 2>&1 & - elif [ "$action" = "youtube-dl-music" ]; then - setsid $TERMINAL -e youtube-dl-music "$url" & - else - notify-send "${0##/*}" "Error: Action not understood" - exit 1 - fi - fi - ;; - esac + 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") + mkdir -p ~/tmp/ + cd ~/tmp/ || exit 1 + setsid tsp curl -LO "$url" >/dev/null 2>&1 & ;; + "html to pdf") + mkdir -p ~/tmp/ + 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 + esac done