Skip to content

Instantly share code, notes, and snippets.

@eoldavix
Created January 20, 2016 07:42
Show Gist options
  • Select an option

  • Save eoldavix/fb15ad2397a1e5b7fb7b to your computer and use it in GitHub Desktop.

Select an option

Save eoldavix/fb15ad2397a1e5b7fb7b to your computer and use it in GitHub Desktop.
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)
system("ssh pi@raspberrypi.local \"/opt/vc/bin/tvservice -p && chvt 1 && chvt 7\" &> /dev/null")
}'
)
@eoldavix

Copy link
Copy Markdown
Author

Recomendable usar autenticación por clave pública agregada al anillo de contraseñas (o sin contraseña) para que el script funcione correctamente.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment