From 9cc467351836d61a1708a998c2cb80dadf1c808c Mon Sep 17 00:00:00 2001 From: Peter Mosmans Date: Thu, 26 Jan 2023 17:49:32 +0100 Subject: [PATCH] fix: fixes #25 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. --- tasks/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 234c8d0..3108848 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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([]) }}" @@ -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 }} @@ -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: