ansible-kanshi/templates/config.j2

62 lines
2.1 KiB
Django/Jinja

# {{ ansible_managed }}
{% if kanshi_profiles is defined %}
{% for p in kanshi_profiles %}
profile {{ p.profile | default('') }} {
{# Process screens #}
{% for s in p.screens %}
{% set current = (sway_outputs | selectattr('id','==', s.id))[0] %}
{{- ' output "' ~ current['name'] | default(s.id) ~ '"' -}}
{% if s.status is defined and s.status == 'disable' %}
{{- ' disable' -}}
{% else %}
{% if s.status is defined and s.status == 'enable' %}
{{- ' enable' -}}
{% endif %}
{% if s.mode is defined %}
{{- ' mode ' ~ s.mode }}
{% elif current['mode'] is defined %}
{{- ' mode ' ~ current['mode'] -}}
{% endif %}
{% if s.position is defined %}
{{- ' position ' ~ s.position -}}
{% endif %}
{% if s.transform is defined %}
{#
use sway config transform here is not a good idea because
rotation will be applied two times
#}
{{- ' transform ' ~ s.transform -}}
{% endif %}
{% if s.scale is defined %}
{{- ' scale ' ~ s.scale -}}
{% elif current['scale'] is defined %}
{{- ' scale ' ~ current['scale'] -}}
{% endif %}
{% endif %}
{% endfor -%}
{# process options#}
{% if p.options is defined %}
{% for o in p.options %}
{% set current = (sway_outputs | selectattr('id','==', o.id))[0] %}
{{- ' output "' ~ current['name'] | default(s.id) ~ '" ' -}}
{{ o.option }} {{ o.value }}
{% endfor -%}
{% endif -%}
{# Process command#}
{% if p.commands is defined %}
{% for c in p.commands %}
{% set cmd = namespace(cmd = c) %}
{% if sway_outputs is defined %}
{% for o in sway_outputs %}
{% set cmd.cmd = ( cmd.cmd | replace('+'+o.id+'+', '"'+o.name+'"')) %}
{% endfor %}
{% endif %}
{{- ' exec ' ~ cmd.cmd }}
{% endfor -%}
{% endif -%}
}
{% endfor %}
{% endif %}