First thing’s first, I have an atom based in-dash car PC as demonstrated here. What’s going on here, is when I come home, my car will detect my home WIFI connection. When this happens, and I turn my car off, instead of simply going to sleep, it will connect to my home computer and perform an rsync of all new mp3’s from my computer to my car. When this is done, my car PC will then go to sleep. I have a safety in place which will automatically stop the rsync and go to sleep after 20 minutes. That way if something goes wrong such as poor wifi signal causing crawling speeds, my carpc doesn’t stay on all night and drain my car battery.
Now the key here is how to execute these actions. On linux, or at least on ubuntu, there is a script called /etc/acpi/powerbtn.sh. This script gets run when you push the computer’s power button, a.k.a when I turn my car off.
IF you use linux, then using the actions I described below, it’s a pretty trivial task to write these actions into powerbtn.sh yourself. And it’s probably better to rather than to reuse my case specific code.
Actions:
- When powerbtn.sh run, query if the SSID of your home network is present
- IF not, then sleep
- IF so, then connect to this network
- Mount a network share to your MP3 folder
- Use sleep, or at, a timestamp comparison, or some other method to count down from X minutes.
- Perform an rsync with the arguments of your choosing
- Then sleep