From a08904d88a5dc413258c590ad794871cb3fc88e8 Mon Sep 17 00:00:00 2001 From: Wis Date: Thu, 9 Apr 2020 04:35:03 +0300 Subject: [PATCH] mpv config: use mpvSockets script to remove mpv wrappers/aliases (#544) * add scripts to mpv's cfg \w mpvSockets as 1st dependency and\or script * remove all usage of --input-ipc-server in all cmds * remove mpv alias that adds --input-ipc-server * fix pauseallmpv: correct paths to unix socket files * fix dependency-scripts loading so it works also when opening files off main disk --- .config/aliasrc | 3 --- .config/lf/lfrc | 4 ++-- .config/mpv/scripts/modules.lua | 3 +++ .config/mpv/scripts/mpvSockets | 1 + .config/ranger/rifle.conf | 18 +++++++++--------- .config/vifm/vifmrc | 4 ++-- .gitmodules | 3 +++ .local/bin/dmenuhandler | 4 ++-- .local/bin/linkhandler | 2 +- .local/bin/pauseallmpv | 2 +- 10 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 .config/mpv/scripts/modules.lua create mode 160000 .config/mpv/scripts/mpvSockets create mode 100644 .gitmodules diff --git a/.config/aliasrc b/.config/aliasrc index 2bf5813..64d45af 100644 --- a/.config/aliasrc +++ b/.config/aliasrc @@ -36,9 +36,6 @@ alias \ xr="sudo xbps-remove -R" \ xq="xbps-query" -# This alias is important. It enables the `pauseallmpv` command. -alias mpv="mpv --input-ipc-server=/tmp/mpvsoc$(date +%s)" - # Some other stuff alias \ magit="nvim -c MagitOnly" \ diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 2925808..616c5ab 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -16,8 +16,8 @@ cmd open ${{ text/*) $EDITOR $fx;; image/x-xcf|image/svg+xml) setsid gimp $f >/dev/null 2>&1 & ;; image/*) rotdir $f | setsid sxiv -aio 2>/dev/null | lf-select & ;; - audio/*) mpv --input-ipc-server=/tmp/mpvsoc$(date +%%s) $f ;; - video/*) setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%%s) $f -quiet >/dev/null 2>&1 & ;; + audio/*) mpv $f ;; + video/*) setsid mpv $f -quiet >/dev/null 2>&1 & ;; application/pdf) setsid zathura $fx >/dev/null 2>&1 & ;; *) for f in $fx; do setsid $OPENER $f >/dev/null 2>&1 & done;; esac diff --git a/.config/mpv/scripts/modules.lua b/.config/mpv/scripts/modules.lua new file mode 100644 index 0000000..37b69b3 --- /dev/null +++ b/.config/mpv/scripts/modules.lua @@ -0,0 +1,3 @@ +local mpv_scripts_dir_path = os.getenv("HOME") .. "/.config/mpv/scripts/" +function load(relative_path) dofile(mpv_scripts_dir_path .. relative_path) end +load("mpvSockets/mpvSockets.lua") diff --git a/.config/mpv/scripts/mpvSockets b/.config/mpv/scripts/mpvSockets new file mode 160000 index 0000000..8415a08 --- /dev/null +++ b/.config/mpv/scripts/mpvSockets @@ -0,0 +1 @@ +Subproject commit 8415a08d99a46213c918613cfe1e088071018db9 diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf index 97410d9..8f661b2 100644 --- a/.config/ranger/rifle.conf +++ b/.config/ranger/rifle.conf @@ -101,7 +101,7 @@ ext s[wmf]c, has snes9x-gtk,X = snes9x-gtk "$1" ext nes, has fceux, X = fceux "$1" ext exe = wine "$1" name ^[mM]akefile$ = make -ext asf, has mpv, X, flag f = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -- "$@" +ext asf, has mpv, X, flag f = mpv -- "$@" #-------------------------------------------- # Code @@ -118,11 +118,11 @@ ext php = php -- "$1" #------------------------------------------- mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@" mime ^video|audio, has smplayer, X, flag f = smplayer "$@" -mime ^video, has mpv, X, flag f = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -- "$@" -mime ^video, has mpv, X, flag f = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --no-video -- "$@" -mime ^video, has mpv, X, flag f = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --fs -- "$@" -mime ^video, has mpv, X, flag f = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --loop -- "$@" -mime ^video, has mpv, X, flag f = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --title="obs" --autofit=1050x700 -- "$@" +mime ^video, has mpv, X, flag f = mpv -- "$@" +mime ^video, has mpv, X, flag f = mpv --no-video -- "$@" +mime ^video, has mpv, X, flag f = mpv --fs -- "$@" +mime ^video, has mpv, X, flag f = mpv --loop -- "$@" +mime ^video, has mpv, X, flag f = mpv --title="obs" --autofit=1050x700 -- "$@" mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@" mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@" mime ^video, has mplayer, X, flag f = mplayer -- "$@" @@ -135,16 +135,16 @@ mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@" #------------------------------------------- mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@" mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@" -mime ^audio|ogg$, terminal, has mpv = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --no-audio-display -- "$@" +mime ^audio|ogg$, terminal, has mpv = mpv --no-audio-display -- "$@" mime ^audio|ogg$ = tag "$@" -mime ^audio|ogg$, terminal, has mpv = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -- "$@" +mime ^audio|ogg$, terminal, has mpv = mpv -- "$@" ext midi?, terminal, has wildmidi = wildmidi -- "$@" #-------------------------------------------- # Video without X: #------------------------------------------- -mime ^video, terminal, !X, has mpv = mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -- "$@" +mime ^video, terminal, !X, has mpv = mpv -- "$@" mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@" mime ^video, terminal, !X, has mplayer = mplayer -- "$@" diff --git a/.config/vifm/vifmrc b/.config/vifm/vifmrc index 56e5fca..59210cd 100644 --- a/.config/vifm/vifmrc +++ b/.config/vifm/vifmrc @@ -54,11 +54,11 @@ fileviewer *.odt odt2txt %c - filetype *.csv,*.xlsx sc-im %c fileviewer *.csv sed "s/,,,,/,,-,,/g;s/,,/ /g" %c | column -t | sed "s/ - / /g" | cut -c -%pw -filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus mpv --no-audio-display --input-ipc-server=/tmp/mpvsoc$(date +%%s) %c +filetype *.wav,*.mp3,*.flac,*.m4a,*.wma,*.ape,*.ac3,*.og[agx],*.spx,*.opus mpv --no-audio-display %c filextype *.pdf,*.ps,*.eps,*.ps.gz,*.djvu,*.epub,*.cbz,*.cbr,*.cb7 zathura %f 2>/dev/null &, fileviewer *.pdf pdftotext -l 1 -nopgbrk %c - fileviewer *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.qt,*.divx,*.as[fx],*mp3,*.flac file -filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,*.as[fx] mpv --input-ipc-server=/tmp/mpvsoc$(date +%%s) %f 2>/dev/null &, +filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,*.fl[icv],*.m2v,*.mov,*.webm,*.ts,*.mts,*.m4v,*.r[am],*.qt,*.divx,*.as[fx] mpv %f 2>/dev/null &, fileview *.tar.gz atool -l --format=tar %f 2>/dev/null | awk '{$1=$2=$3=$4=$5=""; print $0}' fileview *.zip,*.cbz atool -l --format=zip %f 2>/dev/null | tail +4 | awk '{$1=$2=$3=""; print $0}' diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..dd87c9a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".config/mpv/scripts/mpvSockets"] + path = .config/mpv/scripts/mpvSockets + url = git@github.com:wis/mpvSockets.git diff --git a/.local/bin/dmenuhandler b/.local/bin/dmenuhandler index c7e2740..8ada2f4 100755 --- a/.local/bin/dmenuhandler +++ b/.local/bin/dmenuhandler @@ -6,11 +6,11 @@ case "$(printf "copy url\\nmpv\\nmpv (loop)\\nqueue download\\n\\nqueue youtube-dl\\nfeh\\nbrowser\\nw3m\\nmpv (float)" | dmenu -i -p "Open link with what program?")" in "copy url") echo "$1" | xclip -selection clipboard ;; mpv) setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; - "mpv (loop)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet --loop "$1" >/dev/null 2>&1 & ;; + "mpv (loop)") setsid mpv -quiet --loop "$1" >/dev/null 2>&1 & ;; "queue download") tsp curl -LO "$1" >/dev/null 2>&1 ;; "queue youtube-dl") tsp youtube-dl --write-metadata -ic "$1" >/dev/null 2>&1 ;; browser) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;; feh) setsid feh "$1" >/dev/null 2>&1 & ;; w3m) w3m "$1" >/dev/null 2>&1 ;; - "mpv (float)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;; + "mpv (float)") setsid mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;; esac diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler index 2c64dcb..0660011 100755 --- a/.local/bin/linkhandler +++ b/.local/bin/linkhandler @@ -11,7 +11,7 @@ case "$1" in *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*) - setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;; + setsid mpv -quiet "$1" >/dev/null 2>&1 & ;; *png|*jpg|*jpe|*jpeg|*gif) curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; *mp3|*flac|*opus|*mp3?source*) diff --git a/.local/bin/pauseallmpv b/.local/bin/pauseallmpv index 85a7032..15b9f59 100755 --- a/.local/bin/pauseallmpv +++ b/.local/bin/pauseallmpv @@ -5,6 +5,6 @@ # every single one of them with one command! This is bound to super + shift + p # (with other things) by default and is used in some other places. -for i in $(ls /tmp/mpvsoc*); do +for i in $(ls /tmp/mpvSockets/*); do echo '{ "command": ["set_property", "pause", true] }' | socat - $i; done