Auto Pause when you go out

Build/modify/repair equipment and improve systems performance by yourself

Auto Pause when you go out

Postby m0oml » 03 Jul 2016, 12:36

Yet another bodged script

make sure you phone always gets the same ip address from your router

Code: Select all
# This Script is to ping a ip addres ( My mobile phone)
# and pause music when it fails to detect a host
# it is crude dirty and badly written any sugestions
# or criticism welcome
# Trevor Cockayne


for (( ; ; ))
      count=$(ping -4 -c2 | grep 'received' | awk -F',' '{ print $2}' | awk '{ print $1}')
            if [ $count -eq 0 ]; then
            if [ $wepause -eq 0 ]; then
                  mpc pause > /dev/null 2>&1
                  let wepause=1
                  let weplay=0
            if [ $weplay -eq 0 ]; then
                  mpc play > /dev/null 2>&1
                  let weplay=1
                  let wepause=0
sleep 10
Posts: 8
Joined: 28 May 2016, 09:16

Re: Auto Pause when you go out

Postby watchdog » 22 Jan 2018, 10:06


I'm glad you made this script! Thank you!

I could use some info in order to make it work, tho. Ok with ssh access, but I'm almost a noob in coding.

Could it be possible to "auto-start" and "auto-pause" playing when it detects at least one (of my two) phones ?
It's ok with "auto-pause" but I don't know if its possible for autostart playing a queue.

Thanks in advance.
Posts: 2
Joined: 18 Jan 2018, 09:07

support RuneAudio Donate with PayPal

Return to DIY and tweaks

Who is online

Users browsing this forum: No registered users and 0 guests