src

sauce
got clone ssh://anon@src.dalliard.ch/src
log | files | refs

open (1408B)


      1 #!/bin/sh -e
      2 # pkg_add aria2c mpv mupdf--js nsxiv ungoogled-chromium
      3 logger_tag="open"
      4 str="$1"
      5 test -z "$str" && str=$(xsel -bo 2>/dev/null)
      6 test -z "$str" && exit 1
      7 
      8 case "$str" in
      9 	https://*youtube.com/*|https://youtu.be/*|https://*video*|https://x.com/*|https://rumble.com/*)
     10 		logger -t "$logger_tag" "downloading with yt-dlp: $str"
     11 		yt-dlp -P ~/down </dev/null >>/tmp/ytdlp.log 2>&1 "$str" &
     12 		;;
     13 	magnet:*|*.torrent)
     14 		logger -t "$logger_tag" "downloading with aria2c: $str"
     15 		aria2c -d "$HOME/down" --seed-time=0 --file-allocation=none </dev/null >>/tmp/aria2c.log 2>&1 "$str" &
     16 		;;
     17 	*.mp4|*.avi|*.mkv|*.webm|*.mov|*.ogv|*.m2a|*.mp3|*.m4a|*.flac|*.wav|*.aac|*.ogg)
     18 		logger -t "$logger_tag" "playing media with mpv: $str"
     19 		mpv --really-quiet </dev/null >/dev/null 2>&1 "$str" &
     20 		;;
     21 	http*)
     22 		logger -t "$logger_tag" "opening web page with ungoogled-chromium: $str"
     23 		ungoogled-chromium --kiosk --app="$str" </dev/null >/dev/null 2>&1 &
     24 		;;
     25 	*.png|*.jpg|*.jpeg|*.gif|*.webp|*.bmp|*.tiff)
     26 		logger -t "$logger_tag" "opening image with nsxiv: $str"
     27 		nsxiv -ab "$str" &
     28 		;;
     29 	*.pdf|*.epub|*.mobi|*.cbz|*.cbr)
     30 		logger -t "$logger_tag" "opening document with mupdf: $str"
     31 		mupdf-gl </dev/null >/dev/null 2>&1 "$str" &
     32 		;;
     33 	*.txt|*.md|*.html)
     34 		logger -t "$logger_tag" "opening file in less: $str"
     35 		less "$str"
     36 		;;
     37 	*)
     38 		logger -t "$logger_tag" "no matching handler for: $str"
     39 		exit 1
     40 		;;
     41 esac