-
Notifications
You must be signed in to change notification settings - Fork 21
Use XFCE or Gnome commands to change background #151
Conversation
f3a1bb7
to
a8d8f45
Compare
- name: Change desktop background | ||
become: yes | ||
become_user: '{{ ATMOUSERNAME }}' | ||
shell: 'export $(dbus-launch); DISPLAY=:{{ item }} {{ change_background_cmd }} "{{ background_dest }}"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can remove the with_items
here. If you wouldn't mind throwing a comment in to say why dbus-launch is required. If DISPLAY must be set i think we can just use :0
.
a8d8f45
to
e3c362d
Compare
Works great without $DISPLAY. Rebased and pushed the changes. Thanks for your help and D-bus research! |
Looks good. Whoever is looking at this code is going to wonder why dbus-launch is being used. You can either throw a comment above that line, or put a few sentences in your first commit. |
e3c362d
to
59717a5
Compare
Added a comment |
|
||
# dbus-launch is used here to launch the dbus-daemon and appropriate dekstop session and gather the environment variables that it creates. | ||
# dbus-launch is generally run as part of user login, but that has not happened yet so it is necessary here. | ||
- name: Change desktop background |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically launching dbus is the wrong thing to do here-its definitely a hack. You need to explain not that we're launching dbus nor what dbus does, but that its a hack and why the hack is necessary. I realize that you may not have the holistic reason why its a hack.
We're creating a rogue dbus just so that gsettings will be satisfied. This is the wrong way to use gsettings, because an existing user session + windows would have its own dbus, and never see our updated setting. However, it's okay in this instance, because we nuke the users' desktop. The new desktop will get the updated settings from a file.
59717a5
to
8304cef
Compare
Finished testing latest changes |
Description
I noticed that our new CentOS 7 image did not get the correct desktop background change. This is because it uses XFCE desktop while the Ansible role expected CentOS instances to be using Gnome. This fix checks if XFCE commands are available on the instance, and if not, it uses Gnome commands instead.
This is a fix for CentOS 7, but it is also a big improvement to the task because it uses the correct commands to change the desktop background for XFCE instead of replacing the original background file with our own. It also gets rid of the specific checks for Ubuntu 14 and Ubuntu 16+.