Add hdmi scheduled on/off to ansible
This commit is contained in:
parent
7a45025c56
commit
bdc4a382c3
|
@ -3,3 +3,4 @@
|
||||||
become: yes
|
become: yes
|
||||||
roles:
|
roles:
|
||||||
- msmtp
|
- msmtp
|
||||||
|
- hdmi
|
||||||
|
|
7
roles/hdmi/defaults/main.yml
Normal file
7
roles/hdmi/defaults/main.yml
Normal 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
51
roles/hdmi/tasks/main.yml
Normal 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
|
10
roles/hdmi/templates/screen-off.service
Normal file
10
roles/hdmi/templates/screen-off.service
Normal 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
|
9
roles/hdmi/templates/screen-off.timer
Normal file
9
roles/hdmi/templates/screen-off.timer
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Turn off display
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar={{ hdmi_schedule_display_off }}
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
10
roles/hdmi/templates/screen-on.service
Normal file
10
roles/hdmi/templates/screen-on.service
Normal 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
|
10
roles/hdmi/templates/screen-on.timer
Normal file
10
roles/hdmi/templates/screen-on.timer
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Turn on display
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar={{ hdmi_schedule_display_on }}
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
|
EOF
|
Loading…
Reference in a new issue