diff options
Diffstat (limited to 'modules/newsboat.home/opener.sh')
| -rwxr-xr-x | modules/newsboat.home/opener.sh | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/modules/newsboat.home/opener.sh b/modules/newsboat.home/opener.sh index 7a5da4e..5d0cbfc 100755 --- a/modules/newsboat.home/opener.sh +++ b/modules/newsboat.home/opener.sh @@ -2,25 +2,54 @@ type="$1"; shift; +spawn() { setsid -f "$@" >/dev/null 2>&1; } + video() { - mpv \ + spawn mpv \ + -keep-open \ --player-operation-mode=pseudo-gui \ --force-window=immediate \ - "$@" >/dev/null 2>&1 & disown; + "$@"; +} + +image() { spawn feh -x -F --image-bg "#0f0c19" "$@"; } + +__tts() { + # local tts_model="en_US-ryan-high.onnx"; + local tts_model="en_US-lessac-medium.onnx"; + local tts_model_path="$HOME/.config/piper-models/$tts_model"; + [ -f "$tts_model_path" ] || (echo "Model not found" && exit 1); + + local tmp_file=$(mktemp /tmp/newsboat-piper-tts.XXX); + notify-send -t 6000 'Loading tts...'; + piper --model "$tts_model_path" -f "$tmp_file" --sentence_silence 0.4; + video "$tmp_file"; } -image() { feh -x -F --image-bg "#0f0c19" "$@" >/dev/null 2>&1 & disown; } +tts() { __tts >/dev/null 2>&1; } + +browser() { spawn sensible-browser "$@"; } -browser() { sensible-browser "$@" >/dev/null 2>&1 & disown; } +torrent-dl() { ~/scripts/torrent.sh torrent "$1" >/dev/null 2>&1; } + +torrent-stream() { + notify-send -t 10000 'Starting stream player...'; + spawn peerflix "$1" --mpv -- -keep-open --force-window=immediate >/dev/null 2>&1; +} case "$type" in copy) echo "$@" | xclip -selection clipboard ;; + tts) tts ;; image) image "$@" ;; video|audio) video "$@" ;; + torrent-dl) torrent-dl "$@" ;; + torrent-stream) torrent-stream "$@" ;; *) case "$1" in https://*youtu.be/*|https://*youtube.com/v/*) video "$@" ;; https://*youtube.com/watch*) video "$@" ;; - *) browser ;; + magnet:*) torrent-dl "$@" ;; + https*.torrent) torrent-dl "$@" ;; + *) browser "$@" ;; esac ;; esac; |
