I asked the question already on stackoverflow, but figured, that this could be a better place to get an answer: I want to provision a virtual machine with Ubuntu 16 LTS using vagrant and ansible (local). Part of the provisioning is to add and remove some Unity launcher icons for a user that is also created by the same script. The script is started from the vagrant
user. After searching through several related questions, I tried variations of
dbus-launch --exit-with-session
before the gsettings commandbecome_flags: '-i'
become_flags: '-H'
become_flags: '-E'
on the following basic ansible command
- name: Remove Launcher Icons
command: gsettings set com.canonical.Unity.Launcher favorites "['application://org.gnome.Nautilus.desktop', 'application://firefox.desktop', 'application://gnome-terminal.desktop', 'application://atom.desktop', 'application://unity-control-center.desktop', 'unity://running-apps', 'unity://expo-icon', 'unity://devices']"
become: true
become_user: "{{ user }}"
So far, no success, BUT running the command as a logged in user works.
EDIT
My best appoach for a solution would be launching a shell script from ansible instead of doing the change in ansible directly. However, I am not sure how it should look like.
Best Answer
I recommend you place a
.desktop
file into each user's~/.config/autostart
folder that will call launcher setup script. Alternatively, place.desktop
file into/etc/xdg/autostart
so that script runs for every user, but then you'll need to grab username and find user launcher config in some form of database. Id personally use Python script that reads json file with username: launcher list valies, because it's simple.