Hacking an IKEA mirror [part 6]

Now we get to the software side of this project.

In a new micro-SD card, I installed the latest version of Raspbian, expanded the fs to use the whole card,  connected the system to my wifi and then run the following commands:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio

I also installed and configured samba to simplify transfer of files to the device.

I connected the rpi to a Marmitek CM15 X10 module, as some button combinations will activate X10 switches in the room (lights, monitor power cables etc).

 

 

 

 

Switching your monitor off remotely (linux, windows, and mac)

If you want to switch off your monitor from your command line in linux, there is an easy way:

sleep 1 && xset -display :0.0 dpms force off

What if you want to run this command remotely?

Here is my take on this question:
– use Python and Bottle to build a simple web server.
– use “/on” and “/off” pages to run command line scripts that switch the monitor on and off.

Let’s do this in Linux, Windows and Mac.

LINUX

from bottle import route, run
import os
 
@route('/off')
def off():
        os.system("xset -display :0.0 dpms force off")
        return "Screen is now off"
 
@route('/on')
def on():
        os.system("xset -display :0.0 dpms force on")
        return "Screen is now on"
 
run(host='192.168.0.xxx', port=53535)

you just run this server in the background. If you need to switch the monitor off or on, just get any machine within the network and point its browser to these links:

http://192.168.0.xxx:53535/off
http://192.168.0.xxx:53535/on

WINDOWS
To do the same in windows, you can use nircmd, a free utility, to switch off the screen.

To switch on the screen back, I’m using a simple autohotkey script, that just moves the mouse a bit:

MouseMove, 200, 100
MouseMove, 100, 100

Save the above two lines in a text file with the name mouse.ahk, in the same folder as the script below:

from bottle import route, run
import os
 
@route('/off')
def off():
        os.system("nircmd.exe monitor off")
        return "Screen is now off"
 
@route('/on')
def on():
        os.system("mouse.ahk")
        return "Screen is now on"
 
run(host='192.168.0.xxx', port=53535)

The command needs to be in your path (alternatively give it the full path of the nircmd binary).

MAC
with a bit of help from here, the script is as follows:

from bottle import route, run
import os
 
@route('/off')
def off():
        os.system("pmset displaysleepnow")
        return "Screen is now off"
 
@route('/on')
def on():
        os.system("caffeinate -u &")
        return "Screen is now on"
 
run(host='192.168.0.xxx', port=53535)

No security considerations taken into account here; we are assuming you are running this in a secure environment. Depending on your setup, you may have to use administrator/root privileges and make adjustments to your firewall.

The above is part of my IKEA mirror project. Some button combinations will be switching monitors on and off.

Hacking an IKEA mirror [part 5]

I needed a case for the RaspberryPi. The good thing about the RPi being a business card-sized computer is that it fits nicely in a plastic box from old business cards. If you look on Ebay, you can buy 20 of them for £5 including delivery.

The boxes make fantastic custom RPi cases! I didn’t spend too much time and effort in cutting these accurately, but the result is fine for the purpose. All the necessary ports are exposed and the GPio cables have a custom hole.

The board fits snuggly in the box, so I did not bother fixing it. A bit of bluetack was used to stick the plastic box on the metal frame.

Popular Mechanics Ad Fest…

Our web browsing experience has deteriorated over the past few months, as Taboola and a few other companies have tried and successfully convinced  a large number of online publishers that they can help them monetise their online properties. Online publishers also modify their pages to ensure that maximise their page views. An article that should only be displayed in one page, gets divided into many many pages.

Don’t get me wrong, I understand that companies need to make money to survive and prosper, but I feel that ugly, sometimes disgusting ads from Taboola et al are either turning people away or forcing them to use ad blockers. I belong to the latter group. As a result of Taboola, I started using AdBlock (get extension for Chrome here).

To understand the difference in the web browsing experience, here are two shots from an article on Popular Mechanics.

With Ads:pop_mech_with_ads

 

Without Ads:pop_mech_no_ads

What really annoys me is the fact that the designers are happy to mess up the functionality of the site, in order to get more ad space. Notice the area near the orange exclamation mark. The user can barely read 3 lines of text here, even with the ads blocked.  To read the rest of the text on this page, you need to scroll using the tiny scrollbar… If you try to scroll down using your fingers on the iPad, you click the ads…

The whole article, with its low-res photos should not be over one page long. Here it gets converted into 8 pages. Disgraceful.

Aggressive advertising techniques will turn users away. Short term gains will be offset by lasting long term losses in readership. It’s common sense.