.bin: Add MPV desktop embedding script

This commit is contained in:
Salt 2017-09-15 12:36:33 -05:00
parent dc3f148af1
commit c308f682bd

46
.bin/mpv-xwinwrap Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# Copyright (c) 2017 rehashedsalt/vintagesalt
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
function video-play {
notify-send -u low -t 10 -a 'MPV' "Embedded Video" "Playing $1 as a stream embedded in the desktop"
xwinwrap -ni -fs -b -nf -ov -- mpv -wid WID $1
return 0
}
function video-validate {
if [[ "$(curl -Is $1 | head -1)" = *"200"* ]]; then
return 0
fi
return 1
}
input="$(rofi -dmenu -p 'Embed video: ' -l 1)"
printf "Input: $input\n"
if ! video-validate $input; then
printf "Not a valid stream: $input\n"
exit 1
fi
video-play $input
exit 0