MPV: Extract socket path from command line
This commit is contained in:
parent
f2528c963f
commit
97b27287f5
|
@ -3,15 +3,13 @@
|
||||||
# Purpose {{{
|
# Purpose {{{
|
||||||
# This script will try to control MPV with IPC socket
|
# This script will try to control MPV with IPC socket
|
||||||
# 1. Check for MPV proc with IPC socket option.
|
# 1. Check for MPV proc with IPC socket option.
|
||||||
# 2. Verify if a process runs with one of the expected socket.
|
# 2. Extract the newest socket path from command line.
|
||||||
# Unable to correctly extract socket path from command line…
|
|
||||||
# 3. Send user command to the last MPV process with a existing socket.
|
# 3. Send user command to the last MPV process with a existing socket.
|
||||||
#
|
#
|
||||||
# 2022-05-22
|
# 2022-05-22
|
||||||
# }}}
|
# }}}
|
||||||
# TODO {{{
|
# TODO {{{
|
||||||
# * Add an option to set the socket path.
|
# * Add an option to set the socket path.
|
||||||
# * Set a list of sockets path and use the first existing one.
|
|
||||||
# * Add new user command ?
|
# * Add new user command ?
|
||||||
# }}}
|
# }}}
|
||||||
# Vars {{{
|
# Vars {{{
|
||||||
|
@ -24,9 +22,10 @@ readonly NBARGS="${#}"
|
||||||
export DEBUG
|
export DEBUG
|
||||||
|
|
||||||
## Default values for some vars
|
## Default values for some vars
|
||||||
readonly MPV_PROC_REGEXP="mpv.*--input-ipc-server"
|
readonly MPV_PROC_REGEXP="mpv.*--input-ipc-server="
|
||||||
readonly USER_MULTIMEDIA_COMMAND_DEFAULT="toggle"
|
readonly USER_MULTIMEDIA_COMMAND_DEFAULT="toggle"
|
||||||
readonly MPV_POSSIBLE_SOCKET_PATH="${HOME}/.cache/qutebrowser/mpv.ipc.socket"
|
MPV_POSSIBLE_SOCKET_PATH=$(pgrep --newest --full --list-full -- "^${MPV_PROC_REGEXP}" | sed -n -e "s/.*${MPV_PROC_REGEXP}\(.*\) .*/\1/p;q")
|
||||||
|
readonly MPV_POSSIBLE_SOCKET_PATH
|
||||||
|
|
||||||
## Colors
|
## Colors
|
||||||
readonly PURPLE='\033[1;35m'
|
readonly PURPLE='\033[1;35m'
|
||||||
|
@ -91,8 +90,6 @@ error_message() { # {{{
|
||||||
define_vars() { # {{{
|
define_vars() { # {{{
|
||||||
|
|
||||||
## Get the socket path of the last MPV process {{{
|
## Get the socket path of the last MPV process {{{
|
||||||
## Can't extract a valid socket path from the command line !
|
|
||||||
## So… no other choice than test a static list of possible socket
|
|
||||||
MPV_SOCKET_PATH="${MPV_POSSIBLE_SOCKET_PATH}"
|
MPV_SOCKET_PATH="${MPV_POSSIBLE_SOCKET_PATH}"
|
||||||
debug_message "define_vars − \
|
debug_message "define_vars − \
|
||||||
IPC socket path for the last MPV process : ${RED}${MPV_SOCKET_PATH}${COLOR_DEBUG} ."
|
IPC socket path for the last MPV process : ${RED}${MPV_SOCKET_PATH}${COLOR_DEBUG} ."
|
||||||
|
|
Loading…
Reference in New Issue