From 38e3917e3704fb1a71b435fccbc028dfcd6b7fb4 Mon Sep 17 00:00:00 2001 From: lara Date: Fri, 20 Nov 2020 19:12:05 +0100 Subject: [PATCH] Fix cliplumber error reporting --- bin/cliplumber | 9 ++++----- bin/playvideo | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100755 bin/playvideo diff --git a/bin/cliplumber b/bin/cliplumber index be59a80..d2d076f 100755 --- a/bin/cliplumber +++ b/bin/cliplumber @@ -14,9 +14,9 @@ check_exists() { done } -if ! which wl-paste > /dev/null && [ ! -z "$WAYLAND_DISPLAY" ]; then +if ! which wl-paste > /dev/null 2>&1 && [ ! -z "$WAYLAND_DISPLAY" ]; then die "Wayland detected and wl-paste not found" -elif ! which xsel > /dev/null && [ -z "$WAYLAND_DISPLAY" ]; then +elif ! which xsel > /dev/null 2>&1 && [ -z "$WAYLAND_DISPLAY" ]; then die "xsel not found" fi @@ -61,8 +61,7 @@ case "$choice" in path="$HOME/mus/$(printf "%s" "$choice" | cut -d " " -f 2-)" [ -d "$path" ] || mkdir -p "$path" cd "$path" || exit - youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$urls" 2>&1 | grep 'ERROR:' | xargs -n1 -d "\n" notify-send - #notify-send "Error while downloading: $clip" + youtube-dl -x --audio-format mp3 --no-playlist -o "%(title)s.%(ext)s" "$urls" 2>&1 | grep 'ERROR:' | tee /dev/fd/2 | xargs -n1 -d "\n" notify-send ;; "crawl") path="$HOME/books/" @@ -80,7 +79,7 @@ case "$choice" in dragon -x "$clip" ;; "play") - mpv --ytdl-format='bestvideo[height<=?720]+bestaudio/best' "$clip" 2>&1 | grep 'ERROR:' | xargs -n1 -d "\n" notify-send + playvideo "$clip" ;; "audio-search") diff --git a/bin/playvideo b/bin/playvideo new file mode 100755 index 0000000..c7e0a3c --- /dev/null +++ b/bin/playvideo @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ "$1" = "-h" ] || [ "$#" -ne "1" ]; then + >&2 echo "Usage: $0 " + exit 1 +fi + +mpv --ytdl-format='bestvideo[height<=?720]+bestaudio/best' "$1" 2>&1 | grep 'ERROR:' | tee /dev/fd/2 | xargs -n1 -d "\n" notify-send