dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit b5033c99b269cb926eda626010f1b77ac29c5ce2
parent d8ba64d6222b9a920d073d60febdeac2cc905fae
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Thu, 12 Nov 2020 21:22:21 +0100

mpvq: allow piping & POSIX compatibility

Former-commit-id: 0214cc58ed2ee1f6afc9b457a58957ad6f4ef030
Diffstat:
Mscripts/mpvq | 18++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/scripts/mpvq b/scripts/mpvq @@ -1,5 +1,5 @@ -#!/bin/bash -if [[ ! -p "$HOME"/.cache/mpv/input ]]; then +#!/bin/sh +if ! [ -p "$HOME"/.cache/mpv/input ]; then mkfifo "$HOME"/.cache/mpv/input fi @@ -7,9 +7,9 @@ fi play() { if pgrep -f MPV-Q > /dev/null; then printf "%s\n" "loadfile \"$1\" append-play" > "$HOME"/.cache/mpv/input - terminal-notifier -title "Video queued" -message "Added to queue successfully" -group "mpv" &>/dev/null + terminal-notifier -title "Video queued" -message "Added to queue successfully" -group "mpv" 1>/dev/null 2>&1 else - terminal-notifier -title "Playing video" -message "MPV is launching..." -group "mpv" &>/dev/null + terminal-notifier -title "Playing video" -message "MPV is launching..." -group "mpv" 1>/dev/null 2>&1 mpv --idle=yes --volume=50 --no-terminal --x11-name=MPV-Q --input-file="$HOME"/.cache/mpv/input --player-operation-mode=pseudo-gui "$1" & fi } @@ -20,6 +20,16 @@ arc(){ printf "%b\n" "$title\t$1" >> "$HOME/.cache/mpv/linkarchive" } +if ! [ -t 0 ]; then + while read -r l; do + entered_read=1 + play "$l" + arc "$l" & + done + [ -n "$entered_read" ] && exit 0 +fi + +[ $# -eq 0 ] && printf "Links expected as arguments or stdin; none provided.\n" && exit 1 for l in "$@"; do play "$l" arc "$1" &