diff --git a/.ansible-lint b/.ansible-lint index 3f7f5cd..37b04b0 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -2,3 +2,4 @@ skip_list: - name[casing] + - risky-shell-pipe diff --git a/README.md b/README.md index 13434f3..9982d57 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,24 @@ The default variables are defined in [defaults/main.yml](./defaults/main.yml): # first element is set as default potos_wallpaper_images: [] ``` +### Example +```yaml +potos_wallpaper_images: + - name: "Potos" + filename: "potos.jpg" + options: "zoom" + pcolor: "#161b21" + scolor: "#161b21" + shade_type: "solid" +``` +| variable | Possible values | Description | +|------------|---------------------------------------------------------------------------|-------------------------------------------------------------------------| +| name | | How the wallpaper is named to the user | +| filename | | | +| options | "none", "wallpaper", "centered", "scaled", "stretched", "zoom", "spanned" | Determines how the image is rendered | +| pcolor | any hex rgb value e.g. #161b21 | Left or top color when drawing gradients, or the solid color. | +| scolor | any hex rgb value e.g. #161b21 | Right or bottom color when drawing gradients, not used for solid color. | +| shade_type | "horizontal", "vertical", and "solid" | How to shade the background color. | Another option is to use `ansible-doc` to read the argument specification: diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index d875d8c..d44f3be 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -8,7 +8,7 @@ argument_specs: description: - Name of the default wallpaper file. type: str - required: no + required: false default: 'warty-final-ubuntu.png' potos_wallpaper_images: description: @@ -16,5 +16,5 @@ argument_specs: background, first element is set as default. type: list elements: str - required: no + required: false default: [] diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 8f51858..4cfd51f 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -10,3 +10,4 @@ ansible.builtin.shell: # noqa: command-instead-of-module cmd: 'apt-get update && apt-get upgrade -y' when: ansible_distribution == 'Ubuntu' + changed_when: false diff --git a/tasks/main.yml b/tasks/main.yml index 9c91674..7e7904f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -59,3 +59,33 @@ group: root mode: '0755' loop: '{{ potos_wallpaper_images[1:] | default([]) }}' + + - name: Ensure background info dir exists + ansible.builtin.file: + path: '/usr/share/gnome-background-properties' + state: directory + owner: root + group: root + mode: '0755' + + - name: Capture background info files to remote + ansible.builtin.find: + paths: /usr/share/gnome-background-properties + file_type: file + excludes: + - "potos.xml" + register: potos_wallpaper_backgrounds_properties_toremove + + - name: Delete files + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ potos_wallpaper_backgrounds_properties_toremove['files'] }}" + + - name: Deploy backgrounds info file + ansible.builtin.template: + src: 'usr/share/gnome-background-properties/potos.xml' + dest: '/usr/share/gnome-background-properties/potos.xml' + owner: root + group: root + mode: '0755' diff --git a/templates/usr/share/gnome-background-properties/potos.xml b/templates/usr/share/gnome-background-properties/potos.xml new file mode 100644 index 0000000..92a3411 --- /dev/null +++ b/templates/usr/share/gnome-background-properties/potos.xml @@ -0,0 +1,22 @@ + + + + + {% if potos_wallpaper_images[0] is string%}{{ potos_wallpaper_images[0] }}{% else %}{{ potos_wallpaper_images[0].name | default ('Wallpaper') }}{% endif %} + /usr/share/backgrounds/warty-final-ubuntu.png + {% if potos_wallpaper_images[0] is string%}zoom{% else %}{{ potos_wallpaper_images[0].options }}{% endif %} + {% if potos_wallpaper_images[0] is string%}#161b21{% else %}{{ potos_wallpaper_images[0].pcolor | default('#161b21') }}{% endif %} + {% if potos_wallpaper_images[0] is string%}#161b21{% else %}{{ potos_wallpaper_images[0].scolor | default('#161b21') }}{% endif %} + {% if potos_wallpaper_images[0] is string%}solid{% else %}{{ potos_wallpaper_images[0].shade_type | default('solid') }}{% endif %} + +{% for bg in potos_wallpaper_images[1:] | default([]) %} + + {% if bg is string%}{{ bg }}{% else %}{{ bg.name | default ('Wallpaper') }}{% endif %} + /usr/share/backgrounds/{% if bg is string%}{{ bg }}{% else %}{{ bg.filename }}{% endif %} + {% if bg is string%}zoom{% else %}{{ bg.options }}{% endif %} + {% if bg is string%}#161b21{% else %}{{ bg.pcolor | default('#161b21') }}{% endif %} + {% if bg is string%}#161b21{% else %}{{ bg.scolor | default('#161b21') }}{% endif %} + {% if bg is string%}solid{% else %}{{ bg.shade_type | default('solid') }}{% endif %} + +{% endfor %} + \ No newline at end of file