The previous three parts unified 99% of the post-login desktop experience—frosted glass, dual file managers, mixed CJK/Latin typography, input method, terminal CLI, Qt5 apps, editors, and Chrome all share the same dark frosted-glass aesthetic. Yet the moment you reboot or hit Super+L to lock your screen, the illusion shatters: a stark text-only GRUB menu, a jarring default boot splash, Ubuntu’s ever-present purple GDM login prompt, and an unblurred lockscreen.

Breaking a user-space tweak is easy to recover from—at worst you switch themes or restore ~/.config. Touching the bootloader and display manager is a different story: one bad edit can drop you into a black screen or stop the graphical greeter from starting altogether. That is why this part establishes one non-negotiable engineering rule for system-level customization: never overwrite package-managed system files; route every change through official extension mechanisms or isolated paths, and wrap every step with a one-command --restore rollback to factory defaults.


End-to-End Boot and Rollback Architecture

From pressing the power button to locking and unlocking your desktop during the day, a Linux workstation moves through five stages: GRUB boot menu → Plymouth kernel boot splash → GDM system login greeter → GNOME desktop session → user-space lockscreen.

To carry the same cool blue-violet sunset-island palette across every stage while keeping blast radius minimal, the full chain follows a layered forward apply + independent per-layer rollback design:

Each layer has clean boundaries:

  • Bootloader layer (GRUB + Plymouth): managed by apply-boot-theme.sh, which snapshots stock settings on first run, supports --keep-plymouth to leave your existing splash intact, and provides --restore for a complete revert.
  • System greeter layer (GDM): compiles a standalone .gresource bundle under /usr/local/share/gnome-shell/ and mounts it via Ubuntu’s native update-alternatives without touching a single package-managed file.
  • User session layer (Desktop + Lockscreen): lives entirely in $HOME and user dconf, reverting in seconds via the restore.sh snapshot and dconf backup created in Part 2.

Let’s walk through each stage and the real pitfalls encountered along the way.


Stage 1: GRUB Boot Menu Theming and the Progressive JPEG Pitfall

1. Theme Selection and Directory Isolation

For GRUB, we use Tela (1080p) from vinceliuice/grub2-themes (by the same author behind Fluent and Colloid). Its centered boot list and flat OS icons stay clean and understated. To keep it isolated from stock directories, deploy it to /boot/grub/themes/tela-sunset/ and swap in the same twilight sunset-island wallpaper (twilight-island-sea.jpg) used on the desktop:

1
2
3
4
5
6
git clone --depth=1 https://github.com/vinceliuice/grub2-themes.git /tmp/grub2-themes
sudo mkdir -p /boot/grub/themes/tela-sunset
sudo cp -r /tmp/grub2-themes/common/* /boot/grub/themes/tela-sunset/
sudo cp -r /tmp/grub2-themes/config/theme-1080p.txt /boot/grub/themes/tela-sunset/theme.txt
sudo cp -r /tmp/grub2-themes/assets/assets-color/icons-1080p /boot/grub/themes/tela-sunset/icons
sudo cp -r /tmp/grub2-themes/assets/assets-select/select-1080p/* /boot/grub/themes/tela-sunset/

2. Major Pitfall: Why Dropping the Raw Wallpaper into GRUB Gives a Black Screen

Copying ~/Pictures/Wallpapers/Sunset/twilight-island-sea.jpg straight to /boot/grub/themes/tela-sunset/background.jpg looks like the obvious shortcut, but it fails in practice for two reasons:

  1. The raw file is 11 MB: GRUB runs before the kernel initializes GPU acceleration. Decoding an 11 MB high-resolution image on a single CPU thread noticeably delays menu rendering and puts pressure on the framebuffer.
  2. The real killer—Progressive JPEG: many high-res photography wallpapers are saved as progressive JPEGs (SOF2 marker, multi-scan rendering) for faster web loading. GRUB’s minimal built-in jpeg decoder only reliably supports standard Baseline JPEG (SOF0). When fed a progressive JPEG, it often fails silently, leaving white menu text floating over a solid black void with the entire background missing.

You can check the encoding in one command with file:

1
2
file ~/Pictures/Wallpapers/Sunset/twilight-island-sea.jpg
# If the output mentions "progressive", feeding it directly to GRUB will likely render a black screen

3. Preprocessing with Python Pillow: Crop, Darken, and Force Baseline Output

The reliable fix is a 3-step Pillow (PIL) preprocessing pass:

  • Center-crop to 1920x1080: matches GRUB_GFXMODE=1920x1080 pixel-for-pixel so GRUB never performs low-quality boot-time scaling.
  • Slightly darken to 0.78 brightness: ImageEnhance.Brightness(...).enhance(0.78) tames bright highlights so white GRUB boot entries stay crisp and legible while preserving the twilight sea palette.
  • Force progressive=False for Baseline JPEG: shrinks the original 11 MB wallpaper down to roughly 246 KB, rendering instantaneously on cold boot.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
"""Preprocess a high-res wallpaper into a GRUB-safe 1080p Baseline JPEG."""
import sys
from pathlib import Path
from PIL import Image, ImageEnhance, ImageOps

def prepare_grub_background(src: str, dst: str, size=(1920, 1080), brightness=0.78):
with Image.open(src) as img:
img = img.convert("RGB")
resample = getattr(Image, "Resampling", Image).LANCZOS
fitted = ImageOps.fit(img, size, method=resample, centering=(0.5, 0.5))
darkened = ImageEnhance.Brightness(fitted).enhance(brightness)
Path(dst).parent.mkdir(parents=True, exist_ok=True)
darkened.save(
dst,
format="JPEG",
quality=88,
optimize=True,
progressive=False, # Critical: force Baseline JPEG to avoid GRUB black-screen decode failures
subsampling="4:2:0",
)

if __name__ == "__main__":
if len(sys.argv) != 3:
raise SystemExit("Usage: prepare_grub_bg.py <source_wallpaper> <output_path>")
prepare_grub_background(sys.argv[1], sys.argv[2])

Verify both the encoding and file size right after conversion:

1
2
file /boot/grub/themes/tela-sunset/background.jpg
ls -lh /boot/grub/themes/tela-sunset/background.jpg

Confirm the output reports baseline and a size around 246 KB before moving on.

4. Tested /etc/default/grub Settings

Set these four keys in /etc/default/grub so single-OS Ubuntu does not hide the menu by default and locks the framebuffer to 1080p:

1
2
3
4
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=3
GRUB_GFXMODE=1920x1080
GRUB_THEME="/boot/grub/themes/tela-sunset/theme.txt"

After saving, run sudo update-grub to regenerate /boot/grub/grub.cfg.

GRUB Tela 1080p sunset-island boot menu rendered from real local /boot/grub/themes/tela-sunset/ assets and layout


Stage 2: Minimal Dark Plymouth Splash & apply-boot-theme.sh

Once GRUB hands off to the kernel, Plymouth takes over the graphical boot splash.

Instead of wrestling with flashy third-party Plymouth themes that stutter or break across upgrades, the cleanest and least invasive choice is Ubuntu’s built-in bgrt theme. It reads the vendor logo directly from the motherboard’s UEFI ACPI BGRT (Boot Graphics Resource Table) and places a minimal dark spinner underneath on a pure black background—transitioning seamlessly between dark GRUB and dark GDM.

Switching manually takes just two commands:

1
2
sudo update-alternatives --set default.plymouth /usr/share/plymouth/themes/bgrt/bgrt.plymouth
sudo update-initramfs -u

To make GRUB wallpaper processing, idempotent /etc/default/grub edits, Plymouth switching, and rollback repeatable, we wrap the whole workflow into apply-boot-theme.sh:

  • One-time initial snapshot: saves the original /etc/default/grub and default.plymouth target under /var/backups/ubuntu-gnome-boot-theme/ without overwriting the factory snapshot on subsequent runs.
  • --keep-plymouth flag: if you prefer your current boot animation—or run on hardware without a UEFI BGRT logo—pass this flag to theme GRUB only without rebuilding initramfs.
  • --restore one-command rollback: restores /etc/default/grub, removes the custom theme directory, resets the original Plymouth alternative, and re-runs both update-grub and update-initramfs -u.
Expand full apply-boot-theme.sh (with --keep-plymouth and --restore)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env bash
set -euo pipefail

BACKUP_DIR="/var/backups/ubuntu-gnome-boot-theme"
GRUB_DEFAULT="/etc/default/grub"
THEME_DIR="/boot/grub/themes/tela-sunset"
BGRT_PLYMOUTH="/usr/share/plymouth/themes/bgrt/bgrt.plymouth"

KEEP_PLYMOUTH=false
RESTORE_MODE=false
WALLPAPER=""
THEME_SRC=""

usage() {
cat <<'EOF'
Usage:
sudo ./apply-boot-theme.sh --wallpaper <wallpaper_path> --theme-src <tela_theme_dir> [--keep-plymouth]
sudo ./apply-boot-theme.sh --restore

Options:
--wallpaper <path> Source sunset wallpaper (auto-darkened and converted to 1080p baseline JPEG)
--theme-src <dir> Prepared Tela 1080p theme directory (containing theme.txt, icons/, etc.)
--keep-plymouth Configure GRUB only; leave the current Plymouth splash untouched
--restore Roll back GRUB and Plymouth to the pre-modification snapshot
EOF
}

require_root() {
if [[ "${EUID}" -ne 0 ]]; then
echo "Error: please run this script with sudo." >&2
exit 1
fi
}

upsert_grub_kv() {
local key="$1"
local value="$2"
if grep -qE "^#?${key}=" "${GRUB_DEFAULT}"; then
sed -i -E "s|^#?${key}=.*|${key}=${value}|" "${GRUB_DEFAULT}"
else
printf '\n%s=%s\n' "${key}" "${value}" >> "${GRUB_DEFAULT}"
fi
}

backup_state_once() {
mkdir -p "${BACKUP_DIR}"
if [[ ! -f "${BACKUP_DIR}/grub.orig" ]]; then
cp -a "${GRUB_DEFAULT}" "${BACKUP_DIR}/grub.orig"
fi
if [[ ! -f "${BACKUP_DIR}/plymouth.orig" ]]; then
if [[ -e /etc/alternatives/default.plymouth ]]; then
readlink -f /etc/alternatives/default.plymouth > "${BACKUP_DIR}/plymouth.orig"
else
: > "${BACKUP_DIR}/plymouth.orig"
fi
fi
}

prepare_baseline_jpeg() {
local src="$1"
local dst="$2"
python3 - "$src" "$dst" <<'PY'
import sys
from PIL import Image, ImageEnhance, ImageOps

src, dst = sys.argv[1], sys.argv[2]
with Image.open(src) as img:
img = img.convert("RGB")
resample = getattr(Image, "Resampling", Image).LANCZOS
fitted = ImageOps.fit(img, (1920, 1080), method=resample, centering=(0.5, 0.5))
darkened = ImageEnhance.Brightness(fitted).enhance(0.78)
darkened.save(
dst,
format="JPEG",
quality=88,
optimize=True,
progressive=False,
subsampling="4:2:0",
)
PY
}

do_restore() {
if [[ ! -f "${BACKUP_DIR}/grub.orig" ]]; then
echo "Backup file ${BACKUP_DIR}/grub.orig not found; skipping GRUB restore." >&2
else
cp -a "${BACKUP_DIR}/grub.orig" "${GRUB_DEFAULT}"
rm -rf "${THEME_DIR}"
update-grub
echo "[OK] GRUB restored from backup."
fi

if [[ -f "${BACKUP_DIR}/plymouth.orig" ]]; then
local orig_plymouth
orig_plymouth="$(cat "${BACKUP_DIR}/plymouth.orig")"
if [[ -n "${orig_plymouth}" && -f "${orig_plymouth}" ]]; then
update-alternatives --set default.plymouth "${orig_plymouth}"
else
update-alternatives --auto default.plymouth || true
fi
update-initramfs -u
echo "[OK] Plymouth and initramfs restored."
fi
}

do_apply() {
if [[ -z "${WALLPAPER}" || ! -f "${WALLPAPER}" ]]; then
echo "Error: specify a valid wallpaper file via --wallpaper." >&2
exit 1
fi
if [[ -z "${THEME_SRC}" || ! -f "${THEME_SRC}/theme.txt" ]]; then
echo "Error: specify a Tela theme directory containing theme.txt via --theme-src." >&2
exit 1
fi

backup_state_once

rm -rf "${THEME_DIR}"
mkdir -p "${THEME_DIR}"
cp -r "${THEME_SRC}/." "${THEME_DIR}/"

prepare_baseline_jpeg "${WALLPAPER}" "${THEME_DIR}/background.jpg"
chmod 0644 "${THEME_DIR}/background.jpg"

upsert_grub_kv "GRUB_TIMEOUT_STYLE" "menu"
upsert_grub_kv "GRUB_TIMEOUT" "3"
upsert_grub_kv "GRUB_GFXMODE" "1920x1080"
upsert_grub_kv "GRUB_THEME" "\"${THEME_DIR}/theme.txt\""

update-grub
echo "[OK] GRUB Tela Sunset theme applied:"
file "${THEME_DIR}/background.jpg"

if [[ "${KEEP_PLYMOUTH}" == "false" ]]; then
if [[ -f "${BGRT_PLYMOUTH}" ]]; then
update-alternatives --set default.plymouth "${BGRT_PLYMOUTH}"
update-initramfs -u
echo "[OK] Plymouth switched to minimal dark bgrt and initramfs updated."
else
echo "Note: ${BGRT_PLYMOUTH} not found; keeping current Plymouth theme."
fi
else
echo "[SKIP] --keep-plymouth set; keeping existing boot splash."
fi
}

while [[ $# -gt 0 ]]; do
case "$1" in
--wallpaper)
WALLPAPER="${2:-}"
shift 2
;;
--theme-src)
THEME_SRC="${2:-}"
shift 2
;;
--keep-plymouth)
KEEP_PLYMOUTH=true
shift
;;
--restore)
RESTORE_MODE=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage
exit 1
;;
esac
done

require_root
if [[ "${RESTORE_MODE}" == "true" ]]; then
do_restore
else
do_apply
fi

Stage 3: Non-Destructive GDM Theming (update-alternatives + Permission Isolation)

1. Core Rule: Why You Must Never Overwrite the Package-Managed .gresource

Plenty of older Ubuntu GDM tutorials start with something like this:

1
2
# ❌ Anti-pattern: never do this!
sudo cp custom.gresource /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource

Overwriting that file in place causes two serious problems:

  1. Silently wiped on upgrades: /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource belongs to yaru-theme-gnome-shell. The very next apt upgrade quietly resets your login screen back to stock purple.
  2. One typo breaks login: if your patched CSS has a syntax error or the resource manifest drops an icon, GDM fails to start and you are stuck switching to a TTY to reinstall the .deb package.

Ubuntu already provides an official update-alternatives extension point for GDM targeting /usr/share/gnome-shell/gdm-theme.gresource. By compiling our custom theme into a standalone /usr/local/share/gnome-shell/gdm-sunset-theme.gresource and registering it at a higher priority than Yaru, rollback is a single update-alternatives --remove command—zero residue and immune to package updates.

2. Three-Step Non-Destructive Workflow

Step 1: Extract Stock Yaru, Inject CSS, and Compile a Standalone Bundle

GDM styles live inside a compiled GLib binary archive (GResource). Use the built-in gresource CLI to unpack /usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource into a temporary directory, copy in the preprocessed sunset background (gdm-sunset-bg.jpg), and append dark frosted-glass rules for #lockDialogGroup and .login-dialog to the extracted stylesheets:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Append to the end of the extracted GDM theme stylesheets */
#lockDialogGroup {
background: #141720 url(resource:///org/gnome/shell/theme/gdm-sunset-bg.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

.login-dialog {
background-color: rgba(20, 23, 32, 0.42);
}

.login-dialog .login-dialog-user-list-view,
.login-dialog .login-dialog-prompt-layout {
background-color: rgba(24, 28, 38, 0.72);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 16px;
padding: 20px 24px;
}

.login-dialog StEntry {
background-color: rgba(16, 19, 27, 0.85);
border: 1px solid rgba(153, 193, 241, 0.35);
border-radius: 10px;
}

Next, generate a .gresource.xml manifest listing every extracted file plus gdm-sunset-bg.jpg, and compile it with glib-compile-resources (from libglib2.0-dev-bin) into /usr/local/share/gnome-shell/gdm-sunset-theme.gresource.

Step 2: Register via update-alternatives and Verify

Register the compiled bundle as a higher-priority alternative for gdm-theme.gresource (priority 50, beating Yaru’s 15 and the default GNOME Shell theme’s 10):

1
2
3
4
sudo update-alternatives --install \
/usr/share/gnome-shell/gdm-theme.gresource \
gdm-theme.gresource \
/usr/local/share/gnome-shell/gdm-sunset-theme.gresource 50

Verify the active link immediately with --display:

1
update-alternatives --display gdm-theme.gresource

Confirm that auto mode points to /usr/local/share/gnome-shell/gdm-sunset-theme.gresource while stock priorities 15 and 10 remain intact:

1
2
3
4
5
6
7
gdm-theme.gresource - auto mode
link best version is /usr/local/share/gnome-shell/gdm-sunset-theme.gresource
link currently points to /usr/local/share/gnome-shell/gdm-sunset-theme.gresource
link gdm-theme.gresource is /usr/share/gnome-shell/gdm-theme.gresource
/usr/local/share/gnome-shell/gdm-sunset-theme.gresource - priority 50
/usr/share/gnome-shell/gnome-shell-theme.gresource - priority 10
/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource - priority 15

Step 3: Permission Isolation + Dedicated GDM dconf Database

Right after installing the .gresource, you will likely notice the login screen still shows the stock black cursor and default Ubuntu font instead of Inter. That comes down to Linux permission isolation: GDM runs as the restricted gdm system user, while Ubuntu sets user home directories (/home/<user>) to mode 750, so gdm cannot read anything inside ~/.local/share/icons or ~/.local/share/fonts.

The clean solution is to mirror only the required cursor and font files into system-wide read-only paths:

  1. Cursor theme: copy Bibata-Modern-Ice to /usr/share/icons/Bibata-Modern-Ice.
  2. Fonts: copy Inter (both variable fonts: Inter[opsz,wght].ttf and Inter-Italic[opsz,wght].ttf) and HarmonyOS Sans SC (Light, Regular, Medium, Bold) to /usr/local/share/fonts/gdm-ui/, enforce 0644/0755 permissions, and rebuild the system cache with sudo fc-cache -fv.
  3. Write a dedicated GDM dconf override at /etc/dconf/db/gdm.d/01-custom-theme (exact 6 tested lines):
1
2
3
4
5
6
[org/gnome/desktop/interface]
color-scheme='prefer-dark'
cursor-theme='Bibata-Modern-Ice'
font-name='Inter 10'
font-antialiasing='rgba'
font-hinting='slight'

Verify that /etc/dconf/profile/gdm includes system-db:gdm, then run sudo dconf update to compile the override into /etc/dconf/db/gdm.

3. Bash Engineering Postmortem: set -u Colliding with local + trap RETURN

While automating the GDM build pipeline into a script, I ran into a subtle Bash bug worth unpacking.

The symptom: following standard defensive scripting habits, the script started with set -euo pipefail. Inside the .gresource build function, I added what looked like tidy automatic temp-directory cleanup:

1
2
3
4
5
6
7
8
9
# ❌ Buggy pattern: triggers "workdir: unbound variable" after the function returns
build_gresource() {
local workdir
workdir="$(mktemp -d)"
trap 'rm -rf "$workdir"' RETURN
# ... extract, patch CSS, compile ...
}

build_gresource && install_alternative && update_gdm_dconf

In practice, build_gresource compiled the .gresource without error—and then the script abruptly aborted when a subsequent function returned:

1
./apply-gdm-theme.sh: line 42: workdir: unbound variable

That single error cut off the entire && install_alternative && update_gdm_dconf chain halfway through!

Root cause:

  1. Bash trap handlers are not lexical closures—they evaluate dynamically at trigger time.
  2. trap '...' RETURN shares a single global slot in the shell process and does not automatically clear itself after the first function returns. Whenever later functions return, the previously registered RETURN trap fires again.
  3. By then, local workdir has gone out of scope and been destroyed. With set -u (nounset) enabled, expanding "$workdir" raises an unbound-variable error and terminates the script.

The clean fix:

  • Preferred approach (zero side effects): never bind a RETURN trap to a function-local variable. Clean up explicitly inside the function, backed by a script-global WORK_DIR="" and a process-level trap cleanup EXIT safety net.
  • Alternative (if you insist on a local RETURN trap): always use defensive expansion ${workdir:-} and immediately clear the trap inside itself with trap - RETURN.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# ✅ Recommended pattern: script-level global + EXIT safety net, avoiding RETURN trap scoping bugs
WORK_DIR=""
cleanup() {
if [[ -n "${WORK_DIR:-}" && -d "${WORK_DIR}" ]]; then
rm -rf "${WORK_DIR}"
fi
}
trap cleanup EXIT

build_gresource() {
WORK_DIR="$(mktemp -d)"
# ... extract, patch CSS, compile ...
rm -rf "${WORK_DIR}"
WORK_DIR=""
}

4. Complete Non-Destructive GDM Deploy & --restore Script

Here is the sanitized, production-tested apply-gdm-theme.sh incorporating all of the safeguards above:

Expand full non-destructive GDM deploy and --restore script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/usr/bin/env bash
set -euo pipefail

YARU_GRESOURCE="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource"
CUSTOM_GRESOURCE="/usr/local/share/gnome-shell/gdm-sunset-theme.gresource"
ALT_LINK="/usr/share/gnome-shell/gdm-theme.gresource"
ALT_NAME="gdm-theme.gresource"
ALT_PRIORITY="50"

GDM_DCONF_PROFILE="/etc/dconf/profile/gdm"
GDM_DCONF_FILE="/etc/dconf/db/gdm.d/01-custom-theme"
GDM_FONT_DIR="/usr/local/share/fonts/gdm-ui"
SYS_ICON_DIR="/usr/share/icons/Bibata-Modern-Ice"

WALLPAPER=""
USER_HOME=""
RESTORE_MODE=false
WORK_DIR=""

cleanup() {
if [[ -n "${WORK_DIR:-}" && -d "${WORK_DIR}" ]]; then
rm -rf "${WORK_DIR}"
fi
}
trap cleanup EXIT

usage() {
cat <<'EOF'
Usage:
sudo ./apply-gdm-theme.sh --wallpaper <wallpaper_path> [--user-home <user_home_dir>]
sudo ./apply-gdm-theme.sh --restore

Notes:
- Never modifies any package-managed .gresource file;
- Writes output to /usr/local/share/gnome-shell/gdm-sunset-theme.gresource and registers via update-alternatives;
- Copies Bibata-Modern-Ice cursors and Inter / HarmonyOS Sans SC fonts to system read-only paths for gdm permission isolation.
EOF
}

require_root() {
if [[ "${EUID}" -ne 0 ]]; then
echo "Error: please run this script with sudo." >&2
exit 1
fi
}

check_deps() {
local cmd
for cmd in gresource glib-compile-resources update-alternatives dconf fc-cache python3; do
if ! command -v "${cmd}" >/dev/null 2>&1; then
echo "Missing dependency: ${cmd} (install libglib2.0-dev-bin, dconf-cli, fontconfig, python3-pil)" >&2
exit 1
fi
done
}

resolve_user_home() {
if [[ -n "${USER_HOME}" ]]; then
return
fi
if [[ -n "${SUDO_USER:-}" ]]; then
USER_HOME="$(getent passwd "${SUDO_USER}" | cut -d: -f6)"
else
USER_HOME="${HOME}"
fi
}

prepare_gdm_wallpaper() {
local src="$1"
local dst="$2"
python3 - "$src" "$dst" <<'PY'
import sys
from PIL import Image, ImageEnhance, ImageOps

src, dst = sys.argv[1], sys.argv[2]
with Image.open(src) as img:
img = img.convert("RGB")
resample = getattr(Image, "Resampling", Image).LANCZOS
fitted = ImageOps.fit(img, (1920, 1080), method=resample, centering=(0.5, 0.5))
darkened = ImageEnhance.Brightness(fitted).enhance(0.78)
darkened.save(dst, format="JPEG", quality=90, optimize=True, progressive=False)
PY
}

build_gresource() {
if [[ ! -f "${YARU_GRESOURCE}" ]]; then
echo "Error: base Yaru resource not found at ${YARU_GRESOURCE}" >&2
exit 1
fi

WORK_DIR="$(mktemp -d)"
local theme_root="${WORK_DIR}/theme"
mkdir -p "${theme_root}"

while IFS= read -r res_path; do
local rel_path="${res_path#/org/gnome/shell/theme/}"
mkdir -p "${theme_root}/$(dirname "${rel_path}")"
gresource extract "${YARU_GRESOURCE}" "${res_path}" > "${theme_root}/${rel_path}"
done < <(gresource list "${YARU_GRESOURCE}")

prepare_gdm_wallpaper "${WALLPAPER}" "${theme_root}/gdm-sunset-bg.jpg"

local css_patch
css_patch="$(cat <<'CSS'

/* === Sunset Dark Frosted Glass GDM Patch === */
#lockDialogGroup {
background: #141720 url(resource:///org/gnome/shell/theme/gdm-sunset-bg.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}

.login-dialog {
background-color: rgba(20, 23, 32, 0.42);
}

.login-dialog .login-dialog-user-list-view,
.login-dialog .login-dialog-prompt-layout {
background-color: rgba(24, 28, 38, 0.72);
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 16px;
padding: 20px 24px;
}

.login-dialog StEntry {
background-color: rgba(16, 19, 27, 0.85);
border: 1px solid rgba(153, 193, 241, 0.35);
border-radius: 10px;
}
CSS
)"

local target_css
for target_css in gdm.css gdm3.css gnome-shell.css gnome-shell-dark.css; do
if [[ -f "${theme_root}/${target_css}" ]]; then
printf '%s\n' "${css_patch}" >> "${theme_root}/${target_css}"
fi
done

local xml_file="${theme_root}/gdm-sunset-theme.gresource.xml"
{
echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<gresources>'
echo ' <gresource prefix="/org/gnome/shell/theme">'
(cd "${theme_root}" && find . -type f ! -name "gdm-sunset-theme.gresource.xml" | sed 's|^\./||' | sort) | while IFS= read -r f; do
printf ' <file>%s</file>\n' "${f}"
done
echo ' </gresource>'
echo '</gresources>'
} > "${xml_file}"

mkdir -p "$(dirname "${CUSTOM_GRESOURCE}")"
glib-compile-resources \
--sourcedir="${theme_root}" \
--target="${CUSTOM_GRESOURCE}" \
"${xml_file}"
chmod 0644 "${CUSTOM_GRESOURCE}"

rm -rf "${WORK_DIR}"
WORK_DIR=""
}

sync_gdm_assets() {
resolve_user_home

# 1. Copy cursor theme to a system path so gdm can read it despite restricted /home/<user>
local src_cursor=""
if [[ -d "${USER_HOME}/.local/share/icons/Bibata-Modern-Ice" ]]; then
src_cursor="${USER_HOME}/.local/share/icons/Bibata-Modern-Ice"
elif [[ -d "${USER_HOME}/.icons/Bibata-Modern-Ice" ]]; then
src_cursor="${USER_HOME}/.icons/Bibata-Modern-Ice"
fi
if [[ -n "${src_cursor}" ]]; then
rm -rf "${SYS_ICON_DIR}"
cp -r "${src_cursor}" "${SYS_ICON_DIR}"
chmod -R a+rX "${SYS_ICON_DIR}"
fi

# 2. Copy Inter (2 variable fonts) and HarmonyOS Sans SC (4 weights) to system font directory
local src_fonts="${USER_HOME}/.local/share/fonts"
if [[ -d "${src_fonts}" ]]; then
mkdir -p "${GDM_FONT_DIR}"
find "${src_fonts}" -type f \( \
-name 'Inter[[]opsz,wght[]].ttf' -o \
-name 'Inter-Italic[[]opsz,wght[]].ttf' -o \
-name 'HarmonyOS_Sans_SC_Light.ttf' -o \
-name 'HarmonyOS_Sans_SC_Regular.ttf' -o \
-name 'HarmonyOS_Sans_SC_Medium.ttf' -o \
-name 'HarmonyOS_Sans_SC_Bold.ttf' \
\) -exec cp -f {} "${GDM_FONT_DIR}/" \;
chmod -R a+rX "${GDM_FONT_DIR}"
fc-cache -fv >/dev/null
fi
}

apply_gdm_dconf() {
mkdir -p "$(dirname "${GDM_DCONF_PROFILE}")" "$(dirname "${GDM_DCONF_FILE}")"
if [[ ! -f "${GDM_DCONF_PROFILE}" ]]; then
cat > "${GDM_DCONF_PROFILE}" <<'EOF'
user-db:user
system-db:gdm
file-db:/usr/share/gdm/greeter-dconf-defaults
EOF
fi

cat > "${GDM_DCONF_FILE}" <<'EOF'
[org/gnome/desktop/interface]
color-scheme='prefer-dark'
cursor-theme='Bibata-Modern-Ice'
font-name='Inter 10'
font-antialiasing='rgba'
font-hinting='slight'
EOF
chmod 0644 "${GDM_DCONF_FILE}"
dconf update
}

do_apply() {
if [[ -z "${WALLPAPER}" || ! -f "${WALLPAPER}" ]]; then
echo "Error: specify a valid wallpaper file via --wallpaper." >&2
exit 1
fi

check_deps
build_gresource
update-alternatives --install "${ALT_LINK}" "${ALT_NAME}" "${CUSTOM_GRESOURCE}" "${ALT_PRIORITY}"
update-alternatives --auto "${ALT_NAME}"
sync_gdm_assets
apply_gdm_dconf

echo "[OK] Non-destructive GDM sunset frosted-glass theme deployed:"
update-alternatives --display "${ALT_NAME}"
}

do_restore() {
if [[ -e "${CUSTOM_GRESOURCE}" ]]; then
update-alternatives --remove "${ALT_NAME}" "${CUSTOM_GRESOURCE}" || true
rm -f "${CUSTOM_GRESOURCE}"
fi
update-alternatives --auto "${ALT_NAME}" || true

rm -f "${GDM_DCONF_FILE}"
dconf update

if [[ -d "${GDM_FONT_DIR}" ]]; then
rm -rf "${GDM_FONT_DIR}"
fc-cache -fv >/dev/null
fi

echo "[OK] GDM cleanly rolled back to stock Yaru theme:"
update-alternatives --display "${ALT_NAME}" || true
}

while [[ $# -gt 0 ]]; do
case "$1" in
--wallpaper)
WALLPAPER="${2:-}"
shift 2
;;
--user-home)
USER_HOME="${2:-}"
shift 2
;;
--restore)
RESTORE_MODE=true
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage
exit 1
;;
esac
done

require_root
if [[ "${RESTORE_MODE}" == "true" ]]; then
do_restore
else
do_apply
fi

Frosted dark sunset GDM login screen rendered from local gdm-sunset-theme.gresource background and CSS


Stage 4: Seamless User-Space Lockscreen Alignment

After theming GDM, there is one easily missed distinction when you press Super+L during the workday: the GDM login screen only runs at boot and logout under the gdm system user, whereas the lockscreen runs inside your own logged-in GNOME Shell session.

To match the lockscreen to the exact same twilight sunset frosted-glass aesthetic as the desktop and GDM, pair two settings:

  1. Point the unlockDialogBackground extension (dconf path /org/gnome/shell/extensions/unlock-dialog-background/) to twilight-island-sea.jpg for both light and dark URIs (replace /home/<user> with your actual $HOME path):
1
2
3
4
5
dconf write /org/gnome/shell/extensions/unlock-dialog-background/picture-uri \
"'file:///home/<user>/Pictures/Wallpapers/Sunset/twilight-island-sea.jpg'"

dconf write /org/gnome/shell/extensions/unlock-dialog-background/picture-uri-dark \
"'file:///home/<user>/Pictures/Wallpapers/Sunset/twilight-island-sea.jpg'"
  1. Confirm Blur my Shell lockscreen blur (enabled back in Part 2):
1
dconf write /org/gnome/shell/extensions/blur-my-shell/lockscreen/blur true

Verify both dconf subtrees right away:

1
2
dconf dump /org/gnome/shell/extensions/unlock-dialog-background/
dconf dump /org/gnome/shell/extensions/blur-my-shell/lockscreen/

Hit Super+L to test: the desktop fades smoothly into a softly blurred twilight sunset lockscreen, and entering your password snaps cleanly back into your workspace. The visual loop from power button to daily lockscreen is now completely closed.

User-space frosted-glass lockscreen rendered from twilight-island-sea.jpg with Blur my Shell Gaussian blur


Wrap-Up: Global Rollback Matrix & Dual-Machine Verification Checklist

Across these four visual-unification guides, we touched the desktop shell, fonts, IME, terminal CLI, Qt5, browser, bootloader, and login greeter. To ensure you can revert any individual layer on demand—or replicate the entire setup on a fresh machine in 10 minutes, here are two reference tables to keep on hand.

1. Layered One-Command Rollback Matrix

Layer Components & Modified Paths One-Command Rollback How It Takes Effect
1. Desktop / GTK / dconf Fluent-round-Dark, Colloid-Dark, Blur my Shell, ~/.config/gtk-3.0/gtk.css, ~/.config/gtk-4.0/gtk.css Run ~/.local/share/desktop-theme-backup-<timestamp>/restore.sh generated in Part 2 nautilus -q + log out and back in
2. Fonts / fontconfig / IME / Shortcuts ~/.config/fontconfig/fonts.conf, ~/.config/fcitx5/, show-desktop binding Move fonts.conf aside and run fc-cache -fv; restore ~/.config/fcitx5/ backup and run fcitx5-remote -r; gsettings reset org.gnome.desktop.wm.keybindings show-desktop Immediate (restart open apps for default fonts)
3. Terminal CLI / Qt5 / Editors eza / bat / btop / fastfetch, QT_QPA_PLATFORMTHEME=qt5ct, ~/.config/qt5ct/, VS Code & Cursor settings.json Comment out CLI aliases and QT_QPA_PLATFORMTHEME in .zshrc, move ~/.config/qt5ct/ aside, restore editor settings.json backups Open a new shell / restart affected apps
4. Chrome Dark Unification ~/.config/google-chrome/Default/Preferences Close all Chrome processes and run ./apply-chrome-theme.sh --restore Relaunch Chrome
5. GDM Login Screen /usr/local/share/gnome-shell/gdm-sunset-theme.gresource, /etc/dconf/db/gdm.d/01-custom-theme, /usr/local/share/fonts/gdm-ui/ Run sudo ./apply-gdm-theme.sh --restore (removes alternatives entry, dconf override, and rebuilds caches) Next logout or GDM restart
6. GRUB / Plymouth /etc/default/grub, /boot/grub/themes/tela-sunset/, default.plymouth Run sudo ./apply-boot-theme.sh --restore (restores /etc/default/grub, Plymouth, and re-runs update-grub + update-initramfs -u) Next reboot

2. Dual-Machine (Ubuntu 22.04 LTS / 24.04 LTS) Verification Checklist

Whether you replicated this setup on Ubuntu 22.04.5 LTS (GNOME 42.9 + Blur my Shell v47 + GTK3 Nautilus) or Ubuntu 24.04.5 LTS (GNOME 46.0 + Blur my Shell v78 + GTK4 Nautilus), run this read-only verification block to inspect every critical piece at a glance:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 1. Desktop theme, cursor, font, and shortcut gsettings baseline
gsettings get org.gnome.desktop.interface gtk-theme
gsettings get org.gnome.desktop.interface icon-theme
gsettings get org.gnome.desktop.interface cursor-theme
gsettings get org.gnome.desktop.interface font-name
gsettings get org.gnome.desktop.interface monospace-font-name
gsettings get org.gnome.desktop.wm.keybindings show-desktop

# 2. fontconfig strong binding & color emoji verification (Inter + HarmonyOS Sans SC and Sarasa first; Noto Color Emoji keeps embeddedbitmap=True)
fc-match -s sans-serif | head -n 6
fc-match -s monospace | head -n 6
fc-match -s "Inter:lang=zh-cn" | head -n 5
fc-match -v "Noto Color Emoji" | grep -E 'color:|embeddedbitmap:'

# 3. GTK / Qt5 unified visual check dashboard
fastfetch

# 4. Lockscreen background extension and lockscreen blur state
dconf dump /org/gnome/shell/extensions/unlock-dialog-background/
dconf dump /org/gnome/shell/extensions/blur-my-shell/lockscreen/

# 5. Non-destructive GDM alternatives mount and dedicated dconf override
update-alternatives --display gdm-theme.gresource
cat /etc/dconf/db/gdm.d/01-custom-theme

# 6. GRUB theme, Baseline JPEG encoding, and Plymouth status
grep -E '^GRUB_(TIMEOUT_STYLE|TIMEOUT|GFXMODE|THEME)=' /etc/default/grub
file /boot/grub/themes/tela-sunset/background.jpg
update-alternatives --display default.plymouth | head -n 5

💡 Cross-version replication notes: When syncing between Ubuntu 22.04 and 24.04, fonts, icons, fontconfig, IME, terminal CLI tools, qt5ct, Chrome, GRUB/Plymouth, and GDM configs are 100% reusable. Only two spots need version-specific adjustments:

  • Nautilus opaque CSS override path: ~/.config/gtk-3.0/gtk.css on 22.04 vs. ~/.config/gtk-4.0/gtk.css on 24.04 (wrapped via @import to preserve theme symlinks).
  • Blur my Shell parameters: opacity=190 / brightness=1.0 / hacks-level=3 on 22.04 (v47, eliminates vertical striping on GNOME 42 X11 + discrete GPU; laptops can use 2 if preferred), vs. opacity=205 / pipeline_default brightness=0.6 with dynamic-opacity off on 24.04 (v78).

From the darkened Tela sunset GRUB menu at power-on, through the minimal dark bgrt splash and frosted GDM greeter, into the day/night sunset frosted-glass desktop and unified app stack—the full Ubuntu GNOME visual pipeline is now complete.

Next up—Terminal Dev Suite: If you also write C/C++ or preview Markdown inside terminal Vim, continue to Part 6 👉 Ubuntu vimplus Setup and Configuration Guide (building a lightweight terminal IDE with vimplus + coc.nvim + clangd and glow).


Series Navigation

# Article Core Topics
#0 Ubuntu Workstation Setup · Series Index End-to-end architecture blueprint, visual design goals, and dual-machine baseline
#1 Ubuntu 22.04 GNOME Desktop Configuration Guide Base extensions, Extension Manager, and initial desktop ergonomics
#2 Ubuntu GNOME Dark Frosted-Glass Desktop Framework and Dual File Manager Blur Opacity Fix (22.04 / 24.04) Fluent + Colloid + dynamic wallpaper, Blur my Shell tuning, and Nautilus/Nemo opacity fix
#3 Font Stack, Strict fontconfig Binding, fcitx5, and Shortcut Pitfalls Inter + HarmonyOS Sans SC + Sarasa, strong binding override, and Chrome Ctrl+C / Win+D fixes
#4 Terminal CLI, Qt5 Unification, VS Code/Cursor, and Chrome Alignment eza/bat/btop/fastfetch, qt5ct palette alignment, editors, and offline-safe Chrome script
#5 End-to-End Boot and Lockscreen Loop: GRUB, Plymouth, GDM, and Lockscreen (Current post) GRUB progressive JPEG fix, Plymouth bgrt, non-destructive GDM, lockscreen loop, and global rollback matrix
#6 Ubuntu vimplus Setup and Configuration Guide Terminal dev suite: vimplus + coc.nvim + clangd and Markdown preview
#7 No Neovim Required: Non-Invasively Turn Classic Vim 9 + vimplus into a Modern Dark Frosted-Glass Editor Transparent Catppuccin Mocha, opaque rounded popups, pill status line, and large-file freeze protection
#8 End-to-End Ubuntu Dev Tools Visual & Workflow Unification: VS Code, Cursor, tmux, Git Delta, fzf, and Typora VS Code/Cursor polish, plugin-free tmux pill status bar, delta/fzf/fd/zoxide chain, and Typora/Guake/gedit alignment