Skip to content

Commit

Permalink
fix: fixes #25
Browse files Browse the repository at this point in the history
Enforce a restart (gentle reload) of Gnome Shell when a new extension has been
detected. This allows Gnome Shell to detect the new extension.
Create a list of enabled extensions before and after the changes, and compare
the changes.
  • Loading branch information
PeterMosmans committed Jan 26, 2023
1 parent b7a692c commit 9cc4673
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
tags:
- fonts

- name: Create a list of current enabled extensions
become_user: "{{ gnome_user }}"
ansible.builtin.shell: gnome-extensions list --enabled > /tmp/before.txt

- name: Load Gnome extension information
include_tasks: get_extension_info.yml
loop: "{{ gnome_extensions|default([]) }}"
Expand Down Expand Up @@ -101,6 +105,13 @@
label: "{{ item.name }}"
tags:
- extensions
register: unzipped_extension

- name: Restart Gnome Shell to ensure all extensions are visible
become_user: "{{ gnome_user }}"
ansible.builtin.command:
cmd: killall -3 gnome-shell
when: unzipped_extension.changed

- name: Enable extensions
ansible.builtin.command: gnome-shell-extension-tool -e {{ item.name }}
Expand All @@ -127,6 +138,31 @@
changed_when: yes # Unfortunately the command does not return anything, so we can't know if it changed anything
tags:
- settings
ignore_errors: true

- name: Create a list of enabled extensions
become_user: "{{ gnome_user }}"
ansible.builtin.shell: gnome-extensions list --enabled > /tmp/after.txt
changed_when: false

- name: Compare the list of enabled extensions
ansible.builtin.shell: diff --ignore-all-space /tmp/before.txt /tmp/after.txt|awk '/[<>]/{print $2}'
register: difference
changed_when: false

- debug:
msg: "Changes in enabled extensions: {{ difference.stdout }}"
when: difference.stdout

- name: Clean up list
become_user: "{{ gnome_user }}"
ansible.builtin.file:
path: "{{ item }}"
state: absent
changed_when: false
loop:
- /tmp/before.txt
- /tmp/after.txt

- name: Modify application settings using gsettings
ansible.builtin.command:
Expand Down

0 comments on commit 9cc4673

Please sign in to comment.