I have a Spotify Premium subscription but I also have a few CDs which are not available on streaming services. I don’t like the whole process of syncing files, that’s why I took a Spotify subscription in the first place. Google offers a solution with Play Music: you can upload up to 20,000 songs to their servers for free and stream them to all of your devices. I didn’t use this because the Google Play Music app was too slow for my previous phone (Google Nexus S). So I decided to put my CDs on a computer and use that computer as a server with Tonido. This way I could stream my music over the Internet to all of my devices. As a plus I could also put all my photos on this device so that I could show them to friends or family wherever I am.
Because this was just a standard computer this would cost a lot of electricity while I wouldn’t use it 90% of the time. I would only need it when I wanted to listen to a song I own which isn’t available on Spotify. That’s why I came up with this idea.
I want my computer to be available when I need it and to be in standby mode when I don’t need it. This way the computer boots up in a few seconds when I wake it up. I want to be able to wake it up from all over the world. I have a Raspberry Pi which is always on and doesn’t require much power. So I created a way to send an email to a certain address which then wakes up my computer within the minute.
Create a new filter for a specific email address. You can use *firstname.lastname@example.org*
I assume you know how to log in to your Raspberry Pi in command line, over SSH or directly. There is a lot of documentation available on their website.
Install the wakeonlan package using the following command:
sudo apt-get update && sudo apt-get -y install wakeonlan
Use nano or another text editor to create the following file:
01:23:45:67:89:AB being the MAC address of the computer you want to wake up with your email. Name the file anynameyouwant.sh.
Create another file:
import imaplib import os mail = imaplib.IMAP4_SSL('imap.gmail.com') mail.login('YOUR USERNAME@gmail.com', 'YOUR PASSWORD') answer = mail.select('THE LABEL YOU CHOOSE') if int(answer) > 0: os.system('THE PATH TO THE FILE YOU CREATED IN STEP 2') mail.store("1:*",'+X-GM-LABELS', '\\Trash') mail.close() mail.logout()
crontab -eto edit the crontab file. Scroll to the bottom and add the following line:
* * * * * /usr/bin/python PATH TO THE FILE YOU CREATED IN STEP 3
Now you can send an email to the address you choose in the Gmail part above and your computer will wake up within the minute!