skip to Main Content

I try to set a wallpaper on Debian Systems with ansible on xfce4 desktops. For this I looked up the official documentation: https://docs.ansible.com/ansible/latest/collections/community/general/xfconf_module.html

My Task:

  - name: set wallpaper
    become_user: odin
    xfconf:
      channel: "xfce4-desktop"
      property: "/backdrop/screen0/{{item}}/image-path"
      value_type: "string"
      value: ['/usr/share/backgrounds/xfce/802192.jpg']
    loop:
      - monitor0
      - monitor1
      - monitorDP-1
      - monitoreDP-1

I receive the following error:

XFConfException: xfconf-query failed with error (rc=1): Failed to init libxfconf: Error spawning command line “dbus-launch --autolaunch=2e66f568a1c34fda92dcec58e724b679 --binary-syntax --close-stderr”: Child process exited with code 1.

failed: [localhost] (item=monitoreDP-1) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "channel": "xfce4-desktop",
            "force_array": false,
            "property": "/backdrop/screen0/monitoreDP-1/image-path",
            "state": "present",
            "value": [
                "/usr/share/backgrounds/xfce/802192.jpg"
            ],
            "value_type": [
                "string"
            ]
        }
    },
    "item": "monitoreDP-1",
    "msg": "Module failed with exception: xfconf-query failed with error (rc=1): Failed to init libxfconf: Error spawning command line “dbus-launch --autolaunch=2e66f568a1c34fda92dcec58e724b679 --binary-syntax --close-stderr”: Child process exited with code 1.",                                                                                                                                                                                                                    
    "output": {
        "ansible_facts": {
            "xfconf": {}
        },
        "cmd_args": [
            "/usr/bin/xfconf-query",
            "--channel",
            "xfce4-desktop",
            "--property",
            "/backdrop/screen0/monitoreDP-1/image-path"
        ],
        "force_lang": "C",
        "rc": 1,
        "stderr": "Failed to init libxfconf: Error spawning command line “dbus-launch --autolaunch=2e66f568a1c34fda92dcec58e724b679 --binary-syntax --close-stderr”: Child process exited with code 1.n",
        "stdout": ""
    },
    "vars": {
        "cmd_args": [
            "/usr/bin/xfconf-query",
            "--channel",
            "xfce4-desktop",
            "--property",
            "/backdrop/screen0/monitoreDP-1/image-path"
        ]
    }
}

I thought about copying the xml config for xfce4-desktop on to every machine, but not every machine has the same screen "monitor" property.

2

Answers


  1. Chosen as BEST ANSWER

    Got it to work. Seems like running the task as root was doing the trick.


  2. The xfce modification works as root for me as well with the following approach:

    - name: Copy wallpaper file
      copy:
        src: files/wallpaper.jpg
        dest: /usr/share/backgrounds/xfce/debian-wallpaper.jpg
        owner: root
        group: root
      when: ansible_distribution == "Debian"
    
    - name: Change wallpaper
      become: true
      xfconf:
        channel: xfce4-desktop
        property: /backdrop/screen0/monitoreDP-1/workspace0/last-image
        value: ["/usr/share/backgrounds/xfce/debian-wallpaper.jpg"]
        value_type: string
      when: ansible_distribution == "Debian"
    

    This will configure the xfce files in /root/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml though.

    I was not able to do it for another user USERNAME, besides with this workaround:

    - name: Copy xfce4 desktop xml files from root to user
      copy:
        src: /root/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
        dest: /home/USERNAME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
        owner: USERNAME
        group: USERNAME
        force: yes
      when: ansible_distribution == "Debian"
    

    If anybody know how to use xfconf module in a better way to overcome this workaround, please let me know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search