aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sway/.local/bin/sway-mpv
blob: 67ec133c696b7d6a8546b7e969d3a654c5ec67ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

if [ ! -t 0 ]; then
	set -- "$@" "$(cat)"
elif [ $# -eq 0 ]; then
	grep -Po '# title: \K.*' "$XDG_STATE_HOME"/mpv/watch_later/* | while IFS=: read -r file match; do
		grep -Pom1 '# \K.*' "$file" | tr -d '\n'
		printf ': %s\n' "$match"
	done
	exit 0
fi

# shellcheck disable=SC2068
swaymsg exec -- mpv --msg-level=all=no "${1%*:*}"