dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

lock.sh (503B)


      1 #!/bin/sh
      2 #
      3 # lock
      4 
      5 SOCKETS_DIR="/tmp/mpv-sockets/"
      6 
      7 main() {
      8     mpc pause >/dev/null 2>&1;
      9 
     10     for socket in "${SOCKETS_DIR}"/*; do
     11         [ -e "${socket}" ] || break
     12         printf 'set pause yes\n' | socat - "${socket}";
     13     done
     14 
     15     bpid=$(ps -ef | grep -i "\<${BROWSER}\>" | grep -iv '\<grep\>' | awk '{ printf "%s ", $2 }')
     16 
     17     [ -n "${bpid}" ] && kill -STOP ${bpid}
     18 
     19     "${LOCKER}"
     20 
     21     temp="$(mktemp)"
     22 
     23     jobs -p > "${temp}"
     24 
     25     wait < "${temp}"
     26 
     27     kill -CONT ${bpid}
     28 }
     29 
     30 main "${@}"