From 815a0d392143b2149a2d7cb8e89737175ad5da8c Mon Sep 17 00:00:00 2001 From: xyz Date: Tue, 21 Sep 2021 00:32:27 -0700 Subject: use tsp in sxhkd, mpvy exit status and notify manage --- .config/sxhkd/sxhkdrc | 2 +- .local/bin/mpvy | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 82045dad..2b140afb 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -19,7 +19,7 @@ alt + Y mpvy -a alt + ctrl + y - mpvy -A + tsp mpvy -A alt + w firefox diff --git a/.local/bin/mpvy b/.local/bin/mpvy index 47c6a9e5..50c2566c 100755 --- a/.local/bin/mpvy +++ b/.local/bin/mpvy @@ -8,12 +8,7 @@ height=$SCRHEIGHT url="$(xsel -ob)" flag=s -notify () -{ - notify-send 'mpvsel failed' -} - -# can improve to make some options mutually exclusive, see curlncm, maybe not +# may improve to make some options mutually exclusive, see curlncm, maybe not # option f and h may do nothing if redownload? since same filename exist. yt-dlp won't download same file even without --auto-file-renameing=false. how improve? pass argument to aria2c? while getopts Aabd:f:h:su: opt; do case $opt in @@ -37,7 +32,11 @@ fi case $flag in # here if use --write-sub, mpv doesn't recognize subtitles? # --embed-subs is a little bit better, but still worse then direct streaming - A) tsp yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove all "$url";; - a) yt-dlp -f "$format" --embed-subs -P "${download_dir:-/tmp/mpvy/}" --sponsorblock-remove all "$url" --exec 'mpv --fs --speed=2' || notify ;; - s) mpv --ytdl-format="$format" --ytdl-raw-options='write-sub=' --fs --speed=2 "$url" || notify;; + A) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove all "$url";; + a) yt-dlp -f "$format" --embed-subs -P "${download_dir:-/tmp/mpvy/}" --sponsorblock-remove all "$url" --exec 'mpv --fs --speed=2';; + s) mpv --ytdl-format="$format" --ytdl-raw-options='write-sub=' --fs --speed=2 "$url";; esac +# not sure if this is the best practice, but it works ;) +status=$? +[ $status -ne 0 ] && notify-send 'mpvsel failed' +exit $status -- cgit v1.2.3-70-g09d2