Skip to content

Commit d67b632

Browse files
author
Derek
committed
fix: GPU groups and duplicate app icons
- Add render/video groups to all non-system users for VirGL GPU acceleration - Hide Nautilus when Nemo is installed (desktop_cleanup.yml) - Prefer apt/dnf packages over Flatpak to avoid duplicate app icons - Auto-detect and hide duplicate Flatpak apps when native version exists
1 parent 873abcf commit d67b632

5 files changed

Lines changed: 235 additions & 3 deletions

File tree

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
# Desktop Entry Cleanup - Hide duplicate and replaced apps from menus
3+
#
4+
# Strategy:
5+
# 1. Hide Nautilus (Files) when Nemo is installed (Nemo replaces it)
6+
# 2. Detect duplicate Flatpak apps that also have apt versions and hide the Flatpak ones
7+
#
8+
# We use user-local overrides (~/.local/share/applications/) with NoDisplay=true
9+
# This preserves the original .desktop files and survives package updates
10+
11+
# ============================================================================
12+
# HIDE NAUTILUS (replaced by Nemo)
13+
# ============================================================================
14+
15+
- name: Check if Nemo is installed
16+
ansible.builtin.stat:
17+
path: /usr/bin/nemo
18+
register: nemo_installed
19+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
20+
21+
- name: Ensure user applications directory exists
22+
ansible.builtin.file:
23+
path: "{{ user_home }}/.local/share/applications"
24+
state: directory
25+
owner: "{{ actual_user }}"
26+
mode: '0755'
27+
when:
28+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
29+
- nemo_installed.stat.exists | default(false)
30+
31+
# Hide Nautilus from menus (user still has full Nautilus functionality if needed)
32+
- name: Hide Nautilus Files from menus (Nemo replaces it)
33+
ansible.builtin.copy:
34+
dest: "{{ user_home }}/.local/share/applications/org.gnome.Nautilus.desktop"
35+
content: |
36+
[Desktop Entry]
37+
Type=Application
38+
Name=Files
39+
NoDisplay=true
40+
Hidden=true
41+
owner: "{{ actual_user }}"
42+
mode: '0644'
43+
when:
44+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
45+
- nemo_installed.stat.exists | default(false)
46+
47+
# ============================================================================
48+
# HIDE DUPLICATE FLATPAK APPS (when apt version exists)
49+
# ============================================================================
50+
51+
# Get list of Flatpak desktop files
52+
- name: Get Flatpak application desktop files
53+
ansible.builtin.find:
54+
paths: /var/lib/flatpak/exports/share/applications
55+
patterns: "*.desktop"
56+
register: flatpak_desktop_files
57+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
58+
59+
# For each Flatpak app, check if an equivalent apt app exists
60+
# Common pattern: Flatpak uses org.foo.Bar.desktop, apt uses foo-bar.desktop
61+
- name: Check for duplicate apt versions of Flatpak apps
62+
ansible.builtin.shell: |
63+
# Get app name from Flatpak desktop file (e.g., org.onlyoffice.desktopeditors)
64+
flatpak_name="{{ item.path | basename | regex_replace('\\.desktop$', '') }}"
65+
66+
# Extract the last part as the likely app name (e.g., desktopeditors)
67+
app_simple=$(echo "$flatpak_name" | rev | cut -d. -f1 | rev)
68+
69+
# Search for matching apt .desktop file
70+
for apt_file in /usr/share/applications/*.desktop; do
71+
[ -f "$apt_file" ] || continue
72+
apt_name=$(basename "$apt_file" .desktop)
73+
74+
# Match if apt_name contains the app_simple name (case insensitive)
75+
if echo "$apt_name" | grep -qi "$app_simple"; then
76+
# Found duplicate - output the Flatpak desktop filename to hide
77+
echo "{{ item.path | basename }}"
78+
exit 0
79+
fi
80+
done
81+
82+
# No duplicate found
83+
exit 0
84+
register: duplicate_check
85+
loop: "{{ flatpak_desktop_files.files | default([]) }}"
86+
changed_when: false
87+
when:
88+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
89+
- flatpak_desktop_files.files | default([]) | length > 0
90+
91+
# Build list of Flatpak desktop files to hide
92+
- name: Build list of duplicate Flatpak apps to hide
93+
ansible.builtin.set_fact:
94+
flatpak_duplicates: "{{ duplicate_check.results | default([]) | map(attribute='stdout') | select('match', '.+\\.desktop$') | list }}"
95+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
96+
97+
# Hide each duplicate Flatpak app
98+
- name: Hide duplicate Flatpak apps (apt version exists)
99+
ansible.builtin.copy:
100+
dest: "{{ user_home }}/.local/share/applications/{{ item }}"
101+
content: |
102+
[Desktop Entry]
103+
Type=Application
104+
Name={{ item | regex_replace('\\.desktop$', '') }}
105+
NoDisplay=true
106+
Hidden=true
107+
owner: "{{ actual_user }}"
108+
mode: '0644'
109+
loop: "{{ flatpak_duplicates | default([]) }}"
110+
when:
111+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
112+
- flatpak_duplicates | default([]) | length > 0
113+
114+
- name: Display hidden duplicate apps
115+
ansible.builtin.debug:
116+
msg: |
117+
Desktop cleanup complete:
118+
- Nautilus hidden: {{ nemo_installed.stat.exists | default(false) }}
119+
- Flatpak duplicates hidden: {{ flatpak_duplicates | default([]) | join(', ') | default('none') }}
120+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']

ansible/roles/developer/tasks/nemo.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@
5555
changed_when: true
5656
failed_when: false
5757
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
58+
59+
# ============================================================================
60+
# DESKTOP CLEANUP (hide Nautilus and duplicate Flatpak apps)
61+
# ============================================================================
62+
63+
- name: Run desktop cleanup (hide Nautilus and duplicates)
64+
ansible.builtin.include_tasks:
65+
file: desktop_cleanup.yml
66+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']

ansible/roles/developer_core/tasks/office.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
11
---
2-
# OnlyOffice and Mailspring installation (Linux only, system-wide via Flatpak)
2+
# OnlyOffice and Mailspring installation (Linux only)
33
# macOS users use native apps (Apple Mail, Pages/Numbers/Keynote)
4+
#
5+
# Strategy: Prefer apt/dnf packages (faster, native), only use Flatpak as fallback
6+
# - If apt/dnf package exists: use it (developer/tasks/onlyoffice.yml handles this)
7+
# - If no apt/dnf package: install via Flatpak
8+
# This avoids duplicate icons in app menus
49

510
# ============================================================================
611
# ONLYOFFICE DESKTOP EDITORS
712
# ============================================================================
813

9-
- name: Install OnlyOffice via Flatpak (system-wide)
14+
# Check if OnlyOffice is already installed via apt/dnf
15+
- name: Check if OnlyOffice is installed via apt/dnf
16+
ansible.builtin.stat:
17+
path: /usr/bin/onlyoffice-desktopeditors
18+
register: onlyoffice_native
19+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
20+
21+
# Only install Flatpak if native package not present
22+
- name: Install OnlyOffice via Flatpak (system-wide, fallback only)
1023
community.general.flatpak:
1124
name: org.onlyoffice.desktopeditors
1225
state: present
1326
method: system
1427
when:
1528
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
1629
- has_gnome | default(false)
30+
- not (onlyoffice_native.stat.exists | default(false))
31+
32+
# Determine correct desktop file name based on installation method
33+
- name: Set OnlyOffice desktop file variable
34+
ansible.builtin.set_fact:
35+
onlyoffice_desktop_file: "{{ 'onlyoffice-desktopeditors.desktop' if (onlyoffice_native.stat.exists | default(false)) else 'org.onlyoffice.desktopeditors.desktop' }}"
36+
when: ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
1737

1838
# Set OnlyOffice as default for common document types
1939
- name: Set OnlyOffice as default for office documents
2040
ansible.builtin.command:
21-
cmd: "xdg-mime default org.onlyoffice.desktopeditors.desktop {{ item }}"
41+
cmd: "xdg-mime default {{ onlyoffice_desktop_file }} {{ item }}"
2242
loop:
2343
# Word documents
2444
- application/msword
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
# GPU Group Configuration for VirGL/virtio-gl Acceleration
3+
# Ensures all non-system users can access GPU render nodes for hardware acceleration
4+
# Without this, gnome-remote-desktop sessions fall back to software rendering (CPU-intensive)
5+
6+
# ============================================================================
7+
# ENSURE GPU GROUPS EXIST
8+
# ============================================================================
9+
10+
- name: Ensure render group exists
11+
ansible.builtin.group:
12+
name: render
13+
state: present
14+
system: true
15+
when:
16+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
17+
- has_gnome
18+
19+
- name: Ensure video group exists
20+
ansible.builtin.group:
21+
name: video
22+
state: present
23+
system: true
24+
when:
25+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
26+
- has_gnome
27+
28+
# ============================================================================
29+
# ADD ALL NON-SYSTEM USERS TO GPU GROUPS
30+
# ============================================================================
31+
32+
- name: Get list of non-system users (UID 1000-60000)
33+
ansible.builtin.shell:
34+
cmd: awk -F: '$3 >= 1000 && $3 < 60000 && $1 != "nobody" {print $1}' /etc/passwd
35+
register: non_system_users
36+
changed_when: false
37+
when:
38+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
39+
- has_gnome
40+
41+
- name: Add non-system users to render and video groups
42+
ansible.builtin.user:
43+
name: "{{ item }}"
44+
groups:
45+
- render
46+
- video
47+
append: true
48+
loop: "{{ non_system_users.stdout_lines | default([]) }}"
49+
when:
50+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
51+
- has_gnome
52+
- non_system_users.stdout_lines is defined
53+
- non_system_users.stdout_lines | length > 0
54+
55+
# ============================================================================
56+
# VERIFY GPU ACCESS
57+
# ============================================================================
58+
59+
- name: Check /dev/dri/renderD128 exists
60+
ansible.builtin.stat:
61+
path: /dev/dri/renderD128
62+
register: render_device
63+
when:
64+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
65+
- has_gnome
66+
67+
- name: Display GPU group configuration status
68+
ansible.builtin.debug:
69+
msg: |
70+
GPU Groups configured for VirGL acceleration:
71+
- Users added to render/video groups: {{ non_system_users.stdout_lines | default([]) | join(', ') }}
72+
- Render device (/dev/dri/renderD128): {{ 'PRESENT' if render_device.stat.exists | default(false) else 'NOT FOUND (not a VM or no virtio-gl)' }}
73+
74+
Note: Users must log out and back in for group changes to take effect.
75+
For RDP sessions, restart gnome-remote-desktop: systemctl restart gnome-remote-desktop
76+
when:
77+
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
78+
- has_gnome

ansible/roles/rdp/tasks/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
- ansible_facts['distribution'] in ['Fedora', 'Ubuntu']
1818
- not has_gnome
1919

20+
- name: Configure GPU groups for VirGL acceleration
21+
ansible.builtin.include_tasks:
22+
file: gpu_groups.yml
23+
tags: ['gpu_groups']
24+
2025
- name: Configure polkit rules for RDP sessions
2126
ansible.builtin.include_tasks:
2227
file: polkit.yml

0 commit comments

Comments
 (0)