Skip to content

Commit

Permalink
Dconf defaults via profile and local database
Browse files Browse the repository at this point in the history
Setup dconf settings using a user profile
And dconf database called local
This is another attempt to fix the dconf issues
frankenstein91#19 frankenstein91#20 frankenstein91#21
  • Loading branch information
TimL20 committed Jun 3, 2021
1 parent 237c96b commit 2405a99
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 69 deletions.
File renamed without changes
112 changes: 112 additions & 0 deletions roles/gnome_shell/tasks/dconf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
###############################################################################
# Default configuration
# See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/desktop_migration_and_administration_guide/custom-default-values-system-settings
# Ansible dconf module seems not to work for that...
###############################################################################

# General .....................................................................

- name: Create dconf profile directory
file:
path: /etc/dconf/profile/
state: directory
owner: root
group: root
mode: 0755

- name: Create user profile
template:
dest: /etc/dconf/profile/user
src: dconf/profile/user
mode: 0644
group: root
owner: root

- name: Create dconf DB directory
file:
path: /etc/dconf/db/local.d/
state: directory
owner: root
group: root
mode: 0755

# Background ..................................................................

- name: Ensure wallpaper directory existance
file:
path: /usr/local/share/backgrounds/
state: directory
owner: root
group: root
mode: 0644
tags:
- wallpaper

- name: Copy wallpaper
copy:
src: backgrounds/wallpaper.png
dest: /usr/local/share/backgrounds/wallpaper.png
owner: root
group: root
mode: 0644
tags:
- wallpaper

- name: Set default background
# See https://help.gnome.org/admin/system-admin-guide/stable/desktop-background.html.en
template:
dest: /etc/dconf/db/local.d/01-background
src: dconf/local.d/01-background
owner: root
group: root
mode: 0644
tags:
- wallpaper

# Keymap ......................................................................

- name: Try to find out host keymap
command: localectl status
delegate_to: localhost
failed_when: false
changed_when: false
when: keymap|default('', true)|length == 0
register: localectl_status
tags:
- keymap

- name: Store found host keymap
set_fact:
keymap: "{{ localectl_status.stdout | regex_search('Keymap:\\s*(.*)$', '\\1', multiline=True) | first }}"
when: (keymap | default('', true) | length == 0) and (localectl_status.rc == 0)
tags:
- keymap

- name: Set default keymap
template:
dest: /etc/dconf/db/local.d/01-input-sources
src: dconf/local.d/01-input-sources
owner: root
group: root
mode: 0644
when: keymap|default('', true)|length != 0
tags:
- keymap

# Enable extensions by default

- name: Set default keymap
template:
dest: /etc/dconf/db/local.d/10-enabled-extensions
src: dconf/local.d/10-enabled-extensions
owner: root
group: root
mode: 0644
tags:
- extensions

# Update dconf database .......................................................

- name: Update dconf database
command: dconf update
changed_when: false # The command is idempotent...
45 changes: 7 additions & 38 deletions roles/gnome_shell/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,13 @@
tags:
- gnome_shell

- name: Try to find out host keymap
command: localectl status
delegate_to: localhost
failed_when: false
changed_when: false
when: keymap|default('', true)|length == 0
register: localectl_status
tags:
- gnome_shell
- keymap

- name: Store found host keymap
set_fact:
keymap: "{{ localectl_status.stdout | regex_search('Keymap:\\s*(.*)$', '\\1', multiline=True) | first }}"
when: (keymap | default('', true) | length == 0) and (localectl_status.rc == 0)
tags:
- gnome_shell
- keymap

- name: Set gnome keyboard layout
dconf:
key: "/org/gnome/desktop/input-sources/sources"
value: "[('xkb', '{{ keymap }}')]"
when: keymap|default('', true)|length != 0
tags:
- gnome_shell
- keymap
- name: Include configuration
include_tasks:
file: dconf.yml
apply:
tags:
- gnome_shell
- dconf

- name: Disable sleep on inactivity
# Sleep on inactivity can be a problem when installation with Ansible is slow
Expand Down Expand Up @@ -94,15 +74,4 @@
- gnome_shell
- apps

- name: Enable appindicator by default
# Proper name of the appindicator extension needed
# Can be found in PKGBUILD of package:
# appindicatorsupport@rgcjonas.gmail.com
dconf:
key: "/org/gnome/shell/enabled-extensions"
value: "['appindicatorsupport@rgcjonas.gmail.com']"
tags:
- gnome_shell
- apps

# org.gnome.books night-mode true
2 changes: 2 additions & 0 deletions roles/gnome_shell/templates/dconf/local.d/01-background
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[org/gnome/desktop/background]
picture-uri='file:///usr/local/share/backgrounds/wallpaper.png'
2 changes: 2 additions & 0 deletions roles/gnome_shell/templates/dconf/local.d/01-input-sources
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[org/gnome/desktop/input-sources]
sources=[('xkb', '{{ keymap }}')]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[org/gnome/shell]
enabled-extensions=['appindicatorsupport@rgcjonas.gmail.com']
2 changes: 2 additions & 0 deletions roles/gnome_shell/templates/dconf/profile/user
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
user-db:user
system-db:local
31 changes: 0 additions & 31 deletions tasks/wallpaper.yml

This file was deleted.

0 comments on commit 2405a99

Please sign in to comment.