Raspberry Pi/Quick Reference
From r00tedvw.com wiki
(Difference between revisions)
(→script to turn monitor on/off) |
(→Add to cron job) |
||
Line 96: | Line 96: | ||
<nowiki> | <nowiki> | ||
− | + | # /etc/cron.d/raspi-monitor-scheduler | |
# Enable the monitor every weekday morning at 7:00 | # Enable the monitor every weekday morning at 7:00 |
Revision as of 11:16, 26 March 2015
Contents |
xset
Overview
xset allows you to control a few things, but the most common is the monitor states. You can manipulate, enable, or disable some features like:
- dpms energy star features
- monitor standby, suspend, off, or on
- screen blanking
- screen exposing
- activate/reset screen saver
- screen saver on/off
It should be noted that while this can blank the monitor, it does not tell the monitor to turn off it's backlight.
disable screen saver/blanking
a common issue with raspberry pis used in kiosk/monitor setups is the screen blanking/screen saver kicking in. You can disable them with the following commands:
~$xset s noblank ~$xset s noexpose ~$xset s off ~$xset dpms 0 0 0
check it by doing:
~$xset -q Keyboard Control: auto repeat: on key click percent: 0 LED mask: 00000000 XKB indicators: 00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: off 03: Compose: off 04: Kana: off 05: Sleep: off 06: Suspend: off 07: Mute: off 08: Misc: off 09: Mail: off 10: Charging: off 11: Shift Lock: off 12: Group 2: off 13: Mouse Keys: off auto repeat delay: 500 repeat rate: 33 auto repeating keys: 00ffffffdffffbbf fadfffefffedffff 9fffffffffffffff fff7ffffffffffff bell percent: 0 bell pitch: 400 bell duration: 100 Pointer Control: acceleration: 20/10 threshold: 10 Screen Saver: prefer blanking: no allow exposures: no timeout: 0 cycle: 600 Colors: default colormap: 0x20 BlackPixel: 0x0 WhitePixel: 0xffff Font Path: /usr/share/fonts/X11/misc,/usr/share/fonts/X11/Type1,built-ins DPMS (Energy Star): Standby: 0 Suspend: 0 Off: 0 DPMS is Enabled Monitor is On
Turn monitors on/off
You can use tvservice to turn the monitors on and off, however, turning them back on and displaying the signal is a bit tricky.
script to turn monitor on/off
#!/bin/bash -e # /usr/local/sbin/raspi-monitor # Script to enable and disable the HDMI signal of the Raspberry PI # Inspiration: http://www.raspberrypi.org/forums/viewtopic.php?t=16472&p=176258 CMD="$1" function on { /opt/vc/bin/tvservice --preferred # Hack to enable virtual terminal nr 7 again: chvt 6 chvt 7 } function off { /opt/vc/bin/tvservice --off } function must_be_root { if [ $USER != root ]; then echo "ERROR: Script must be executed as the root user" exit 1 fi } function main { must_be_root if [ "$CMD" == "on" ]; then on elif [ "$CMD" == "off" ]; then off else echo "Usage: $0 <on|off>" exit 1 fi exit 0 } main
Add to cron job
Add the following script as a cronjob file
~$ sudo nano /etc/cron.d/raspi-monitor-scheduler
# /etc/cron.d/raspi-monitor-scheduler # Enable the monitor every weekday morning at 7:00 0 7 * * 1,2,3,4,5 root /usr/local/sbin/raspi-monitor on > /dev/null 2>&1 # Disable the monitor every weekday evening at 19:30 30 19 * * 1,2,3,4,5 root /usr/local/sbin/raspi-monitor off > /dev/null 2>&1
Make it executable
~$ sudo chmod +x /etc/cron.d/raspi-monitor-scheduler