Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Use XFCE or Gnome commands to change background #151

Merged
merged 2 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
### Fixed

- Fixed task to kill VNC servers using `pkill` instead of `vncserver -kill :$DISPLAY` ([#150](https://github.com/cyverse/atmosphere-ansible/pull/150))
- Fixed task to change desktop background on CentOS 7. This change also offered other improvements by using the correct commands to change the desktop background instead of overwriting existing files ([#151](https://github.com/cyverse/atmosphere-ansible/pull/151))
1 change: 1 addition & 0 deletions ansible/roles/atmo-gui-tweaks/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---

background_img: 'files/atmosphere_wallpaper_v1.jpg'
background_dest: '/usr/share/backgrounds/cloud_background.jpg'

SET_DESKTOP_BACKGROUND: false
47 changes: 26 additions & 21 deletions ansible/roles/atmo-gui-tweaks/tasks/desktop-background.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,32 @@
- name: Copy desktop background to instance
copy:
src: "{{ background_img }}"
dest: /usr/share/backgrounds/cloud_background.jpg
dest: '{{ background_dest }}'

- name: Change desktop background on CentOS
become: yes
become_user: "{{ ATMOUSERNAME }}"
command: >
gconftool-2 -s -t string /desktop/gnome/background/picture_filename "/usr/share/backgrounds/cloud_background.jpg"
when: ansible_distribution == "CentOS"
- name: check if XFCE is desktop environment
stat:
path: '/usr/bin/xfce4-session'
register: xfce

# Note: These tasks trick the os by replacing their defaults with our own instead of properly
# setting the background because "Unable to autolaunch a dbus-daemon without a $DISPLAY for X11"
- name: Change desktop background on Ubuntu
copy:
src: /usr/share/backgrounds/cloud_background.jpg
dest: /usr/share/backgrounds/default.jpg
remote_src: True
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version < "16"
- name: desktop environment is XFCE
set_fact:
change_background_cmd: 'xfconf-query -c xfce4-desktop --property /backdrop/screen0/monitor0/workspace0/last-image --create --type string --set'
when: xfce.stat.exists

- name: Change desktop background on Ubuntu 16+
copy:
src: /usr/share/backgrounds/cloud_background.jpg
dest: /usr/share/backgrounds/xfce/xfce-teal.jpg
remote_src: True
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version >= "16"
- name: check if Gnome is desktop environment
stat:
path: '/usr/bin/gnome-session'
register: gnome

- name: desktop environment is Gnome
set_fact:
change_background_cmd: 'gconftool-2 -s -t string /desktop/gnome/background/picture_filename'
when: gnome.stat.exists and not xfce.stat.exists

# gsettings requires that a dbus-daemon is running. dbus-launch is used to launch it
# because it exits and returns environment variables. $() sources these variables so
# we can kill the PID and avoid having a bunch of rogue dbus-daemons.
- name: Change desktop background
become: yes
become_user: '{{ ATMOUSERNAME }}'
shell: 'export $(dbus-launch); {{ change_background_cmd }} "{{ background_dest }}" && kill $DBUS_SESSION_BUS_PID'