dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit 6a2787e8eeac071fef90a33d780605720bb13cc6
parent 643d74932326d76620b09cb3320d01cb228c25b8
Author: hhvn <dev@hhvn.uk>
Date:   Thu, 23 Dec 2021 22:58:55 +0000

.s/b/mpvrcp .s/b/mpvrcp-keys .s/b/mpvms .s/b/rmpv .s/b/rmpv-list: remove dumb mpv socket stuff

Diffstat:
D.scripts/bin/mpvms | 13-------------
D.scripts/bin/mpvrcp | 118-------------------------------------------------------------------------------
D.scripts/bin/mpvrcp-keys | 49-------------------------------------------------
D.scripts/bin/rmpv | 29-----------------------------
D.scripts/bin/rmpv-list | 29-----------------------------
5 files changed, 0 insertions(+), 238 deletions(-)

diff --git a/.scripts/bin/mpvms b/.scripts/bin/mpvms @@ -1,13 +0,0 @@ -#!/bin/sh - - -[ "$1" = "video" ] && { - shift - hmpv pause /tmp/mpv-socket - herbe "Playing video(s): $@" & - mpv --input-ipc-server=/tmp/mpv-socket2 -- "$@" || herbe "Failed to play video(s): $@" - exit -} || { - herbe "Playing music: $@" & - mpv --input-ipc-server=/tmp/mpv-socket --no-video -- "$@" || herbe "Failed to play music: $@" -} diff --git a/.scripts/bin/mpvrcp b/.scripts/bin/mpvrcp @@ -1,118 +0,0 @@ -#!/bin/sh -# -# mpvrcp - mpv remote control panel -# -# hayden@haydenvh.com -# Copyright (c) 2020 Hayden Hamilton -# -# 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. -# -# This work is free. You can redistribute it and/or modify it under the -# terms of the Do What The Fuck You Want To Public License, Version 2, -# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. - -# This script interacts with mpv through it's socket based ipc communications. -# Dependencies: mpv, socat, jq, posix -# -# Example usage: -# mpv --input-ipc-server=/tmp/mpv-socket -# mpvrcp -# -# With dwm: -# (in shell) st -c mpvrcp -e mpvrcp -# (rule in dwm) { "mpvrcp", NULL, NULL, 1 << 0, 1, 0 }, - -clear -trap 'tput cnorm; exit' 2 -trap 'clear; oldtitle=blah' 28 #SIGWINCH - -drw_line(){ - tput cup $1 0 - tput el - len=$(echo "$2" | sed "s/$(printf "\033")[^m]*m//g" | wc -c) - pad=$(($(tput cols)-$len+1)) - printf "$2" - for void in $(seq $pad); do printf ' '; done -} - -get(){ - echo '{command:["get_property", "'"$1"'"]}' | socat /tmp/mpv-socket - | jq .data | sed 's/^"//;s/"$//' -} - -getm(){ - echo "$(tput bold)$2:$(tput sgr0) $(get "$1" | sed "$3")" -} - -convertsecs() { - h=$((${1}/3600)) - m=$((${1}%3600)) - m=$(($m/60)) - s=$((${1}%60)) - printf "%02d:%02d:%02d\n" $h $m $s -} - -centre(){ - len=$(echo "$1" | sed "s/$(printf "\033")[^m]*m//g" | wc -c) - for void in $(seq $((($(tput cols)-$len)/2))); do printf ' '; done - printf "$1" -} - -invert(){ - $@ 2>/dev/null && return 1 || return 0 -} - -draw_main(){ - socat /tmp/mpv-socket /dev/null 2>/dev/null || { - clear - while invert socat /tmp/mpv-socket /dev/null - do - tput cup 0 0 - echo "Can't connect to socket" - sleep 0.1 - done - } - - - line=1 - title=$(getm "media-title" " Title " | tr '.' ' ') - - [ "$title" != "$oldtitle" ] && { - clear - ( - echo "$title" - getm "metadata/artist" " Artist " - getm "metadata/genre" " Genre " - getm "metadata/album" " Album " - getm "metadata/track" " Track " - getm "metadata/date" " Date " - getm "path" " Dir " "s~.*music/~~;s~/[^/]*$~~" - getm "file-format" " FF " - ) | while IFS= read -r s - do - drw_line $line "$s" - line=$(($line+1)) - done - duration=$(convertsecs $(echo '{ "command": ["get_property", "duration"] }' | socat /tmp/mpv-socket - | jq .data | sed 's/\..*$//')) - playlist_pos=$(get "playlist-pos") - playlist_count=$(get "playlist-count") - } - - oldtitle="$title" - - state=$(get "pause" | sed 's/false/Playing/;s/true/Paused/') - time=$(convertsecs $(echo '{ "command": ["get_property", "playback-time"] }' | socat /tmp/mpv-socket - | jq .data | sed 's/\..*$//')) - drw_line $(tput lines) "$(tput setaf 7; tput rev; tput bold; centre "$(printf "%s | %s/%s | Pos: %s/%s" "$state" "$time" "$duration" "$playlist_pos" "$playlist_count")")" - tput sgr0 -} - -tput civis -while true -do - draw_main -done diff --git a/.scripts/bin/mpvrcp-keys b/.scripts/bin/mpvrcp-keys @@ -1,49 +0,0 @@ -#!/bin/sh - -trap 'drawgui' 28 #SIGWINCH -trap 'stty icanon' 2 #SIGINT - -clear - -send(){ - echo "{ \"command\": [$1] }" | socat - $2 >/dev/null || { - tput cup 0 0 && tput el - printf '%s' "can't connect to socket..." - sleep 0.5 - drawgui - } -} - -toggle(){ - paused=$(echo '{ "command": ["get_property", "pause"] }' | socat - $1 2>/dev/null | tr '{":0,}' ' ' | awk '// {print $2}') - [ "$paused" = "true" ] && { - echo '{ "command": ["set_property", "pause", false] }' | socat - $1 > /dev/null - } || { - echo '{ "command": ["set_property", "pause", true] }' | socat - $1 > /dev/null - } -} - -drawgui(){ - tput cup 0 0 - tput el - printf 'quit(q) rand(m) pause(p) vol(+-) prev(h) back(j) forward(k) next(l)' -} - -stty -icanon -getchar(){ - drawgui - key=$(dd if=/dev/stdin bs=1 count=1 2>/dev/null) -} - -while getchar -do - [ "$key" = "h" ] && send '"playlist-prev"' /tmp/mpv-socket - [ "$key" = "j" ] && send '"seek", "-10"' /tmp/mpv-socket - [ "$key" = "k" ] && send '"seek", "10"' /tmp/mpv-socket - [ "$key" = "l" ] && send '"playlist-next"' /tmp/mpv-socket - [ "$key" = "q" ] && send '"quit"' /tmp/mpv-socket - [ "$key" = "p" ] && toggle /tmp/mpv-socket - [ "$key" = "+" ] && amixer set Master 5%+ >/dev/null 2>/dev/null - [ "$key" = "-" ] && amixer set Master 5%- >/dev/null 2>/dev/null - [ "$key" = "m" ] && rmpv music/list 150 >/dev/null 2>/dev/null & # rmpv is another script of mine -done diff --git a/.scripts/bin/rmpv b/.scripts/bin/rmpv @@ -1,29 +0,0 @@ -#!/bin/sh -# -# rmpv -# Created by Hayden Hamilton -# -# hayden@haydenvh.com -# Copyright (c) 2019-2021 Hayden Hamilton. - -[ "$(uname)" = "Linux" ] && grepargs="-I" -# WHO THE FUCK THOUGHT THE BINARY FILE SHIT IN GNU GREP WAS A GOOD IDEA? -# DO I REALLY HAVE TO FUCKING CHECK IF I'M ON A GNU SYSTEM AND GIVE A STUPID ARGUMENT TO GREP JUST TO MAKE MY SCRIPT WORK BECAUSE YOU THINK UTF8 FILE IS BINARY? -# HOW DO YOU FUCKING MANAGE TO FUCK UP LIKE THAT ON PURPOSE? - -[ -z "$1" ] || [ ! -z "$3" ] && echo "usage: rmpv <directory|filelist> [size]" - -[ -f "$1" ] && files=$(grep $grepargs -E "mp3 |opus |mkv |mp4 |flac |m4a |webm |wav " < "$1" | \ - awk -F"\t" '{for (i=0; i < $2; i++) print $1}' | shuf | head -n ${2:-2000} | sed "s~^.~$(dirname $1)~" | awk '!x[$0]++') -[ -d "$1" ] && files=$(find "$1" -type f | grep $grepargs -E 'mp3$|opus$|mkv$|mp4$|flac$|m4a$|webm$|wav$' | shuf | shuf -n ${2:-2000}) - echo "$files" | grep $grepargs '[[:alnum:]]' >/dev/null || { - echo "No files found..." - exit 1 -} - -echo "$files" -echo "$1" | grep $grepargs "music" >/dev/null && { - echo "$files" | tr '\n' '\0' | xargs -0 mpv --input-ipc-server=/tmp/mpv-socket --no-video -- -} || { - echo "$files" | tr '\n' '\0' | xargs -0 mpv --input-ipc-server=/tmp/mpv-socket -} diff --git a/.scripts/bin/rmpv-list b/.scripts/bin/rmpv-list @@ -1,29 +0,0 @@ -#!/bin/sh -# -# rmpv-list -# manipulate and create lists for rmpv -# -# Copyright (c) 2021 Hayden Hamilton <dev@haydenvh.com> - -# current format: -# file weight -# -# where weight is the number of times the file will occur in the pre-shuffle list - -[ -z "$1" ] || [ -z "$2" ] && printf '%s\n%s\n' "usage: rmpv-list -c <dir>" "usage: rmpv-list -m <list> <file> <weight>" - -[ "$1" = "-c" ] && { - [ -f "$2/list" ] && echo "error: $2/list already exists" | tr -s '/' && exit 1 - cd $2 - find . -type f | awk '{printf("%s\t1\n", $0)}' > list - } - -[ "$1" = "-m" ] && { - echo "$2" | grep -v '^/' >/dev/null && absolutelist="$(pwd)/$2" || absolutelist="$2" - echo "$3" | grep -v '^/' >/dev/null && absolutefile="$(pwd)/$3" || absolutefile="$3" - file=$(echo "$absolutefile" | sed "s~^$dir~~" | tr -s '/') - awk -F" " -v "file=$file" -v "weight=$4" ' - $1 == file {print file "\t" weight} - $1 != file - ' < $absolutelist > $absolutelist.new -}