Compare commits

...

4 Commits
v0.1.0 ... main

3 changed files with 60 additions and 16 deletions

View File

@ -1,20 +1,10 @@
{% from "system/map.jinja" import system_settings with context %} {% from "system/map.jinja" import system_settings with context %}
{% set settings = system_settings['sleep'] %} {% set settings = system_settings['sleep'] %}
{% if settings.disable %} {% if salt['grains']['get']('os_family') == 'FreeBSD' %}
disable_sleep_target: include:
service.masked: - system.sleep.freebsd
- name: 'sleep.target' {% else %}
include:
disable_suspend_target: - system.sleep.linux
service.masked:
- name: 'suspend.target'
disable_hibernate_target:
service.masked:
- name: 'hibernate.target'
disable_hybrid-sleep_target:
service.masked:
- name: 'hybrid-sleep.target'
{% endif %} {% endif %}

16
system/sleep/freebsd.sls Normal file
View File

@ -0,0 +1,16 @@
{% from "system/map.jinja" import system_settings with context %}
{% set settings = system_settings['sleep'] %}
{% if settings.disable %}
# Disable sleep via sysctl
sleep_disable_sysctl:
sysctl.present:
- name: 'kern.suspend_blocked'
- value: '1'
{% else %}
# Enable sleep via sysctl
sleep_enable_sysctl:
sysctl.present:
- name: 'kern.suspend_blocked'
- value: '0'
{% endif %}

38
system/sleep/linux.sls Normal file
View File

@ -0,0 +1,38 @@
{% from "system/map.jinja" import system_settings with context %}
{% set settings = system_settings['sleep'] %}
{% if settings.disable %}
# Disable common sleep states
disable_sleep_target:
service.masked:
- name: 'sleep.target'
disable_suspend_target:
service.masked:
- name: 'suspend.target'
disable_hibernate_target:
service.masked:
- name: 'hibernate.target'
disable_hybrid-sleep_target:
service.masked:
- name: 'hybrid-sleep.target'
{% else %}
# Enable sleep states
enable_sleep_target:
service.unmasked:
- name: 'sleep.target'
enable_suspend_target:
service.unmasked:
- name: 'suspend.target'
enable_hibernate_target:
service.unmasked:
- name: 'hibernate.target'
enable_hybrid-sleep_target:
service.unmasked:
- name: 'hybrid-sleep.target'
{% endif %}