Skip to content

Commit

Permalink
feat: customize bg color and fix not appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
fadnincx committed Mar 21, 2023
1 parent d8e3bb4 commit 9d9ee60
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

skip_list:
- name[casing]
- risky-shell-pipe
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ argument_specs:
description:
- Name of the default wallpaper file.
type: str
required: no
required: false
default: 'warty-final-ubuntu.png'
potos_wallpaper_images:
description:
- List of files to be found under 'potos_wallpaper' to be added as
background, first element is set as default.
type: list
elements: str
required: no
required: false
default: []
1 change: 1 addition & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 30 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
22 changes: 22 additions & 0 deletions templates/usr/share/gnome-background-properties/potos.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
<wallpaper>
<name>{% if potos_wallpaper_images[0] is string%}{{ potos_wallpaper_images[0] }}{% else %}{{ potos_wallpaper_images[0].name | default ('Wallpaper') }}{% endif %}</name>
<filename>/usr/share/backgrounds/warty-final-ubuntu.png</filename>
<options>{% if potos_wallpaper_images[0] is string%}zoom{% else %}{{ potos_wallpaper_images[0].options }}{% endif %}</options>
<pcolor>{% if potos_wallpaper_images[0] is string%}#161b21{% else %}{{ potos_wallpaper_images[0].pcolor | default('#161b21') }}{% endif %}</pcolor>
<scolor>{% if potos_wallpaper_images[0] is string%}#161b21{% else %}{{ potos_wallpaper_images[0].scolor | default('#161b21') }}{% endif %}</scolor>
<shade_type>{% if potos_wallpaper_images[0] is string%}solid{% else %}{{ potos_wallpaper_images[0].shade_type | default('solid') }}{% endif %}</shade_type>
</wallpaper>
{% for bg in potos_wallpaper_images[1:] | default([]) %}
<wallpaper>
<name>{% if bg is string%}{{ bg }}{% else %}{{ bg.name | default ('Wallpaper') }}{% endif %}</name>
<filename>/usr/share/backgrounds/{% if bg is string%}{{ bg }}{% else %}{{ bg.filename }}{% endif %}</filename>
<options>{% if bg is string%}zoom{% else %}{{ bg.options }}{% endif %}</options>
<pcolor>{% if bg is string%}#161b21{% else %}{{ bg.pcolor | default('#161b21') }}{% endif %}</pcolor>
<scolor>{% if bg is string%}#161b21{% else %}{{ bg.scolor | default('#161b21') }}{% endif %}</scolor>
<shade_type>{% if bg is string%}solid{% else %}{{ bg.shade_type | default('solid') }}{% endif %}</shade_type>
</wallpaper>
{% endfor %}
</wallpapers>

0 comments on commit 9d9ee60

Please sign in to comment.