81 lines
1.9 KiB
Markdown
81 lines
1.9 KiB
Markdown
# HDMI Scheduled On/Off
|
|
|
|
The below comamnds will setup automatic on/off of the monitor connected to the HDMI port on your PiFrame. This is handy as overnight few people are looking at their photos and by turning off the display you'll save power and make the screen last longer.
|
|
|
|
The below is setup to turn the display on at ```0600``` and off at ```0000```. Please adjust accordingly.
|
|
|
|
``` sh
|
|
DL_URL=$(curl https://git.kemonine.info/api/v1/repos/PiFrame/piframe-go/releases | jq -r '.[0].assets[] | select(.name == "hdmi") | .browser_download_url')
|
|
wget $DL_URL -O /usr/local/bin/pf-hdmi
|
|
chmod a+x /usr/local/bin/pf-hdmi
|
|
cat > /etc/systemd/system/hdmi-on-off.service <<EOF
|
|
[Unit]
|
|
Description=Turn screen on / off at boot to ensure state is kept
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
User=root
|
|
ExecStart=/usr/local/bin/pf-hdmi
|
|
TimeoutSec=15
|
|
Restart=never
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
systemctl daemon-reload
|
|
systemctl enable --now hdmi-on-off
|
|
|
|
cat > /etc/systemd/system/screen-on.timer <<EOF
|
|
[Unit]
|
|
Description=Turn on display
|
|
|
|
[Timer]
|
|
OnCalendar=*-*-* 06:00:00
|
|
Persistent=true
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
EOF
|
|
cat > /etc/systemd/system/screen-on.service <<EOF
|
|
[Unit]
|
|
Description=Turn on display
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/opt/vc/bin/vcgencmd display_power 1
|
|
StandardOutput=journal
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
cat > /etc/systemd/system/screen-off.timer <<EOF
|
|
[Unit]
|
|
Description=Turn off display
|
|
|
|
[Timer]
|
|
OnCalendar=*-*-* 00:00:00
|
|
Persistent=true
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
EOF
|
|
cat > /etc/systemd/system/screen-off.service <<EOF
|
|
[Unit]
|
|
Description=Turn off display
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/opt/vc/bin/vcgencmd display_power 0
|
|
StandardOutput=journal
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
systemctl daemon-reload
|
|
systemctl enable screen-on.timer
|
|
systemctl enable screen-off.timer
|
|
|
|
```
|