Use sockstat(1) and and running() to check that mpv is running - localbin - leot's localbin (~/bin)
 (HTM) hg clone https://bitbucket.org/iamleot/localbin
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) changeset 5dc01801932cd2e187e4fe18591e968c6df14815
 (DIR) parent 89f582e3c29a5775d6289753d3965a871d887847
 (HTM) Author: Leonardo Taccari <iamleot@gmail.com>
       Date:   Sat, 11 May 2019 00:13:37 
       
       Use sockstat(1) and and running() to check that mpv is running
       
       Directly use sockstat(1) instead of searching in ${mpv_socket_dir}.
       Please note that this needs `sysctl -w kern.expose_address=2'.
       
       Add a running() function to check that mpv is running.
       
       Diffstat:
        mc |  12 ++++++++++--
        1 files changed, 10 insertions(+), 2 deletions(-)
       ---
       diff -r 89f582e3c29a -r 5dc01801932c mc
       --- a/mc        Fri May 10 23:50:47 2019 +0200
       +++ b/mc        Sat May 11 00:13:37 2019 +0200
       @@ -2,8 +2,7 @@
        
        LYRICS_CMD=$(which lyrics)
        
       -mpv_socket_dir=${XDG_CACHE_HOME:-${HOME}/.cache}/mpv/socket
       -mpv_socket=${mpv_socket_dir}/$(ls -t "${mpv_socket_dir}" | head -1)
       +mpv_socket=`sockstat -u | awk '$2 == "mpv" { print $6; exit; }'`
        
        next() {
               pcur=`{ echo '{ "command": ["get_property", "playlist-pos"] }' | socat - $mpv_socket | jq '.data'; } 2>/dev/null`
       @@ -67,11 +66,20 @@
               fi
        }
        
       +running() {
       +       if [ ! -S "${mpv_socket}" ]; then
       +               exit 2
       +       fi
       +}
       +
        usage() {
               echo 'usage: mc next|pause|play|prev|status'
               exit 1
        }
        
       +# check that mpv is running
       +running
       +
        case "$1" in
               n|next)
                       next