Add hdmi scheduled on/off to ansible

This commit is contained in:
KemoNine 2020-08-04 23:33:01 +00:00
parent 7a45025c56
commit bdc4a382c3
7 changed files with 98 additions and 0 deletions

View file

@ -3,3 +3,4 @@
become: yes become: yes
roles: roles:
- msmtp - msmtp
- hdmi

View file

@ -0,0 +1,7 @@
---
# When to automatically turn on the display (every day @ 6am)
hdmi_schedule_display_on: "*-*-* 6:00:00"
# When to automatically turn off the display (every day @ midnight)
hdmi_schedule_display_off: "*-*-* 00:00:00"

51
roles/hdmi/tasks/main.yml Normal file
View file

@ -0,0 +1,51 @@
---
- name: Gather instance facts
setup:
- block:
- name: Generate screen-off.service
template:
src: screen-off.service
dest: "/etc/systemd/system/screen-off.service"
owner: root
group: root
mode: 0644
tags:
- hdmi-config
- name: Generate screen-off.timer
template:
src: screen-off.timer
dest: "/etc/systemd/system/screen-off.timer"
owner: root
group: root
mode: 0644
tags:
- hdmi-config
- name: Generate screen-on.service
template:
src: screen-on.service
dest: "/etc/systemd/system/screen-on.service"
owner: root
group: root
mode: 0644
- name: Generate screen-on.timer
template:
src: screen-on.timer
dest: "/etc/systemd/system/screen-on.timer"
owner: root
group: root
mode: 0644
- block:
- name: Refresh systemd
systemd:
daemon_reload: yes
- name: Enable screen-off.timer
systemd:
name: screen-off.timer
state: started
enabled: yes
- name: Enable screen-on.timer
systemd:
name: screen-on.timer
state: started
enabled: yes

View file

@ -0,0 +1,10 @@
[Unit]
Description=Turn off display
[Service]
Type=oneshot
ExecStart=/opt/vc/bin/vcgencmd display_power 0
StandardOutput=journal
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,9 @@
[Unit]
Description=Turn off display
[Timer]
OnCalendar={{ hdmi_schedule_display_off }}
Persistent=true
[Install]
WantedBy=timers.target

View file

@ -0,0 +1,10 @@
[Unit]
Description=Turn on display
[Service]
Type=oneshot
ExecStart=/opt/vc/bin/vcgencmd display_power 1
StandardOutput=journal
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,10 @@
[Unit]
Description=Turn on display
[Timer]
OnCalendar={{ hdmi_schedule_display_on }}
Persistent=true
[Install]
WantedBy=timers.target
EOF