handy

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

README.md (2474B)


      1 handlers and pipes
      2 
      3 
      4 ### ago20 newsboat linkhandler (for macro links also)
      5 
      6 
      7 https://github.com/nsklaus/dotfiles/blob/master/.local/bin/linkhandler
      8 
      9 ````
     10 #!/bin/sh
     11 
     12 # Feed script a url or file location.
     13 # If an image, it will view in sxiv,
     14 # if a video or gif, it will view in mpv
     15 # if a music file or pdf, it will download,
     16 # otherwise it opens link in browser.
     17 
     18 # If no url given. Opens browser. For using script as $BROWSER.
     19 [ -z "$1" ] && { "$BROWSER"; exit; }
     20 
     21 case "$1" in
     22 	*mkv|*webm|*mp4|*youtube.com/watch*|*invidio.us/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*)
     23 		setsid -f mpv -quiet "$1" >/dev/null 2>&1 ;;
     24 	*png|*jpg|*jpe|*jpeg|*gif)
     25 		curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")"  >/dev/null 2>&1 & ;;
     26 	*mp3|*flac|*opus|*mp3?source*)
     27 		setsid -f tsp curl -LO "$1" >/dev/null 2>&1 ;;
     28 	*)
     29 		if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR" "$1"
     30 	else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;;
     31 esac
     32 ````
     33 
     34 
     35 
     36 
     37 
     38 how to execute macro on a specific link ? · Issue #1118 · newsboat/newsboat
     39 https://github.com/newsboat/newsboat/issues/1118
     40 
     41 ````
     42 browser linkhandler
     43 macro , open-in-browser
     44 macro t set browser "qndl" ; open-in-browser ; set browser linkhandler
     45 macro a set browser "tsp youtube-dl --add-metadata -xic -f bestaudio/best" ; open-in-browser ; set browser linkhandler
     46 macro v set browser "setsid -f mpv" ; open-in-browser ; set browser linkhandler
     47 macro w set browser "lynx" ; open-in-browser ; set browser linkhandler
     48 macro p set browser "dmenuhandler" ; open-in-browser ; set browser linkhandler
     49 macro c set browser "xsel -b <<<" ; open-in-browser ; set browser linkhandler
     50 macro C set browser "youtube-viewer --comments=%u" ; open-in-browser ; set browser linkhandler
     51 macro d set browser "curl -LO %u" ; open-in-browser ; set browser linkhandler
     52 ````
     53 
     54 ### jul2020 gotbletu 'urlportal'
     55 
     56 https://github.com/gotbletu/shownotes/blob/master/urlportal.sh
     57 
     58 ### apr2020 drew
     59 
     60 
     61 
     62 Managing my dotfiles as a git repository | Drew DeVault’s Blog
     63 https://drewdevault.com/2019/12/30/dotfiles.html
     64 
     65 ```
     66 #!/bin/sh
     67 case "${1%%:*}" in
     68 	http|https|*.pdf)
     69 		exec qutebrowser "$1"
     70 		;;
     71 	mailto)
     72 		exec aerc "$1"
     73 		;;
     74 	*)
     75 		exec /usr/bin/xdg-open "$@"
     76 		;;
     77 esac
     78 ```
     79 
     80 Replacing the needlessly annoying-to-customize xdg-open with one that just does what I want, falling back to /usr/bin/xdg-open if necessary. Many other non-shadowed scripts and programs are found in ~/bin as well.
     81 
     82 
     83 
     84