Skip to content

Instantly share code, notes, and snippets.

@eoldavix
eoldavix / raspberrypiscreencontroller.sh
Created January 20, 2016 07:42
Turns on/off the screen at same time you unlock/lock your session in Elementary OS (should work in other distros)
#!/bin/bash
# Author: David Carrera <eoldavix@gmail.com>
dbus-monitor --session "interface=org.freedesktop.DBus.Properties,path=/org/gnome/SessionManager" | \
(
awk '/string "SessionIsActive"/ {
getline
if (index($0 ,"false") > 0)
system("ssh pi@raspberrypi.local \"/opt/vc/bin/tvservice -p && /opt/vc/bin/tvservice -o\" &> /dev/null")
else if (index($0, "true") > 0)