Raspberry Pi/Quick Reference

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
(Add to cron job)
(script to turn monitor on/off)
Line 48: Line 48:
 
You can use tvservice to turn the monitors on and off, however, turning them back on and displaying the signal is a bit tricky.
 
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====
 
====script to turn monitor on/off====
  <nowiki>#!/bin/bash -e
+
  <nowiki>
 +
#!/bin/bash -e
 
    
 
    
 
  # /usr/local/sbin/raspi-monitor
 
  # /usr/local/sbin/raspi-monitor
Line 89: Line 90:
 
    
 
    
 
  main</nowiki>
 
  main</nowiki>
 +
 
====Add to cron job====
 
====Add to cron job====
 
Add the following script as a cronjob file
 
Add the following script as a cronjob file

Revision as of 11:15, 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
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox