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
#!/bin/bash
# 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 trevoml@gmail.com

count=2
weplay=0
wepause=0

for (( ; ; ))
        do
      count=$(ping -4 -c2 192.168.1.136 | 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
               else
                  let weplay=0
               fi
         else
            if [ $weplay -eq 0 ]; then
                  mpc play > /dev/null 2>&1
                  let weplay=1
               else
                  let wepause=0
               fi
        fi
sleep 10
done
m0oml
 
Posts: 8
Joined: 28 May 2016, 09:16

Re: Auto Pause when you go out

Postby watchdog » 22 Jan 2018, 10:06

Hello,

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.
watchdog
 
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 1 guest
cron