After building the frosted-glass desktop foundation, strict fontconfig bindings, and fcitx5 styling in the previous two parts, an idle desktop already looks clean and cohesive. The illusion breaks the second you actually start working, though:

  1. You open your freshly tuned frosted-glass terminal, type ls, cat, or top, and get hit with monochrome 1990s plain text.
  2. You launch a Qt5 utility (a database client, screenshot tool, or media app), and a glaring light-gray, square-cornered window with broken icons punches a hole right through your dark desktop.
  3. You switch to VS Code or Cursor and notice mismatched font weights between editor and integrated terminal, skewed CJK/Latin columns, and missing Nerd glyphs.
  4. You open Chrome to check docs, only to see mismatched tabs, menus, and webpage fonts—and worse, when you follow a tutorial to edit Preferences, Chrome silently wipes your changes on restart.

In this guide, we unify all four of those rough edges in one pass. Everything follows the same engineering discipline as the rest of the series: zero sudo required (CLI binaries live in ~/.local/bin, Qt5 runs through user-space qt5ct, editor configs preserve existing JSONC comments losslessly, and Chrome changes are wrapped in an offline-safe script with --restore), with concrete verification checks and fast rollback at every step.


1. Modern Terminal CLI Suite (Rootless in ~/.local/bin)

In Part 3, we locked the terminal font to Sarasa Term SC Nerd 14 (strict 2:1 CJK/Latin width plus Nerd icons) on top of Zsh + Powerlevel10k + Terminator with a deep blue-gray backdrop (#131722 + #89b4fa cursor) and frosted transparency.

Next, drop four high-frequency CLI tools—eza, bat, btop, and fastfetch—as prebuilt single binaries straight into ~/.local/bin/. This avoids touching system packages with sudo, sidesteps outdated Ubuntu 22.04 apt versions, and lets you rsync the whole bin directory cleanly between 22.04 and 24.04.

First, verify ~/.local/bin sits at the front of PATH in ~/.zshrc:

1
export PATH="$HOME/.local/bin:$PATH"

1.1 eza: Modern ls with Icons, Directories First, and Git Status

eza is the actively maintained community successor to exa. Register four guarded aliases in ~/.zshrc:

1
2
3
4
5
6
if command -v eza >/dev/null 2>&1; then
alias ls='eza --icons=auto --group-directories-first'
alias ll='eza -lh --icons=auto --git --group-directories-first'
alias la='eza -lah --icons=auto --git --group-directories-first'
alias lt='eza --tree --level=2 --icons=auto --group-directories-first'
fi

Why these flags pay off daily:

  • --icons=auto: Renders Nerd filetype icons in interactive terminals (matching Sarasa Term SC Nerd cleanly), and automatically strips icons and ANSI colors when piped into grep or awk so scripts never break.
  • --group-directories-first: Always lists directories above files, making large source trees much faster to scan.
  • --git: Shows staged and modified Git status right beside each entry in ll and la.
  • lt: A crisp two-level directory tree that beats typing tree flags by hand when inspecting config directories.

1.2 bat: Syntax-Highlighted Inspection While Keeping Stock cat

bat adds syntax highlighting, line numbers, and Git diff gutter markers. Create ~/.config/bat/config:

1
2
3
4
# Modern dark bat configuration
--theme="OneHalfDark"
--style="numbers,changes,header"
--italic-text=always

Then wire up a short catp alias in ~/.zshrc:

1
2
3
if command -v bat >/dev/null 2>&1; then
alias catp='bat --paging=never'
fi

Why not alias cat='bat' directly?
I have been bitten by hijacking cat more than once. Even though bat degrades gracefully in most pipes, concatenating files quickly, copying clean plain text without line numbers or borders, or running inside certain terminal wrappers still trips years of muscle memory. Keeping native cat untouched preserves 100% script and clipboard predictability, while catp <file> gives you syntax-highlighted previews on demand.

1.3 btop: Transparent Rounded System Monitor

Compared to monochrome top or utilitarian htop, btop takes full advantage of 24-bit truecolor and rounded box borders. Here is the tested core ~/.config/btop/btop.conf (with adwaita-dark.theme placed in ~/.config/btop/themes/):

1
2
3
4
5
6
7
8
9
color_theme = "~/.config/btop/themes/adwaita-dark.theme"
theme_background = False
truecolor = True
rounded_corners = True
graph_symbol = "braille"
update_ms = 1000
proc_sorting = "cpu lazy"
proc_tree = False
show_battery = False

Three settings make the biggest visual difference:

  • theme_background = False: The key tweak. Drops the theme’s opaque background fill so Terminator’s dark tint and frosted glass show straight through instead of slapping a flat black rectangle onto your terminal.
  • rounded_corners = True + truecolor = True: Echoes the rounded geometry of Fluent-round-Dark.
  • graph_symbol = "braille": Draws CPU, memory, and network curves with fine braille dots instead of chunky blocks, which looks remarkably sharp in Sarasa Term SC Nerd. Keep show_battery = False on desktops to save vertical space, or flip it back to True on laptops.

1.4 fastfetch: Sky-Blue Dashboard and Cross-Toolkit Verification Probe

fastfetch isn’t just for desktop screenshots—in this series it doubles as an engineering verification probe that reports active Qt and GTK2/3/4 themes, icon sets, and fonts side by side in one command. We’ll use it directly in Section 2 to verify Qt5 alignment.

Write ~/.config/fastfetch/config.jsonc:

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
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1,
"left": 2,
"right": 3
}
},
"display": {
"separator": " ",
"color": {
"keys": "38;2;98;160;234",
"title": "38;2;153;193;241"
}
},
"modules": [
"title",
"separator",
{ "type": "os", "key": "OS " },
{ "type": "kernel", "key": "Kernel " },
{ "type": "uptime", "key": "Uptime " },
{ "type": "de", "key": "DE " },
{ "type": "wm", "key": "WM " },
{ "type": "theme", "key": "Theme " },
{ "type": "icons", "key": "Icons " },
{ "type": "font", "key": "Font " },
{ "type": "terminal", "key": "Term " },
{ "type": "terminalfont", "key": "TermFont" },
{ "type": "cpu", "key": "CPU " },
{ "type": "gpu", "key": "GPU " },
{ "type": "memory", "key": "Memory " },
"break",
"colors"
]
}

Those two RGB values weren’t picked at random: 38;2;98;160;234 (#62a0ea) for keys and 38;2;153;193;241 (#99c1f1) for title match Colloid-Dark‘s sky-blue folders and the link highlight roles in our Qt5 palette below.

Terminator showcase featuring fastfetch sky-blue dashboard, eza filetype icons, bat OneHalfDark highlighting, and btop transparent rounded braille graphs


2. Unifying Qt5 Apps (QT_QPA_PLATFORMTHEME=qt5ct, Rootless)

2.1 Why Qt5 Apps Revert to a Retro Light-Gray Look on GNOME

Ubuntu GNOME is a GTK-centric desktop without KDE Plasma’s platform integration daemon running in the background. When a Qt5 app launches, it asks QPA (Qt Platform Abstraction) for desktop styling; without a matching platform theme plugin in the environment, Qt5 falls back to a bare-bones light-gray default:

  • Ignores GNOME’s Fluent-round-Dark dark theme;
  • Misses the Colloid-Dark icon set, leaving toolbars with mismatched monochrome icons;
  • Ignores Inter 11 and pops up dated native Qt file open/save dialogs.

The lightest user-space solution is qt5ct (Qt5 Configuration Tool—once the qt5ct plugin is installed on the system, every config file, color palette, QSS stylesheet, and env var lives in your home directory with zero sudo). Export one environment variable in your desktop session:

1
QT_QPA_PLATFORMTHEME=qt5ct

Every Qt5 application will then read ~/.config/qt5ct/qt5ct.conf on startup, picking up unified widget styling, color roles, icons, fonts, file dialogs, and QSS stylesheets.

2.2 Main Config: ~/.config/qt5ct/qt5ct.conf

Create the directories first:

1
mkdir -p ~/.config/qt5ct/{colors,qss}

Write the tested ~/.config/qt5ct/qt5ct.conf (sanitized to core appearance, font, and interaction settings):

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
[Appearance]
color_scheme_path=/home/<user>/.config/qt5ct/colors/fluent-round-dark.conf
custom_palette=true
icon_theme=Colloid-Dark
standard_dialogs=gtk3
style=Fusion

[Fonts]
fixed="Sarasa Term SC Nerd,13,-1,5,50,0,0,0,0,0"
general="Inter,11,-1,5,50,0,0,0,0,0"

[Interface]
activate_item_on_single_click=1
buttonbox_layout=3
cursor_flash_time=1200
dialog_buttons_have_icons=1
double_click_interval=400
gui_effects=@Invalid()
keyboard_scheme=2
menus_have_icons=true
show_shortcuts_in_context_menus=true
stylesheets=/home/<user>/.config/qt5ct/qss/fluent-round-dark.qss
toolbutton_style=4
underline_shortcut=1
wheel_scroll_lines=3

Check four crucial details:

  1. Use absolute paths: color_scheme_path and stylesheets inside qt5ct.conf **do not expand ~ or $HOME**—replace /home/<user> with your actual $HOME path.
  2. style=Fusion + custom_palette=true: Fusion is Qt’s most predictable cross-platform widget engine and responds cleanly to custom palettes and QSS, avoiding the broken widget geometry and white-on-white text glitches common with third-party GTK2 bridge themes.
  3. icon_theme=Colloid-Dark + standard_dialogs=gtk3: Matches desktop icons identically, and routes Open/Save file dialogs directly to the native GTK3 file chooser.
  4. Exact font-size parity with GNOME: general="Inter,11,..." matches GNOME’s font-name='Inter 11', and fixed="Sarasa Term SC Nerd,13,..." matches monospace-font-name='Sarasa Term SC Nerd 13'. Combined with Part 3’s strong fontconfig binding, Chinese UI labels in Qt5 apps fall back seamlessly to HarmonyOS Sans SC.

2.3 21-Role Palette + Rounded QSS: Shaping Fusion to Match Fluent-round-Dark

Flipping Fusion to a generic dark gray isn’t enough. Making Qt5 windows indistinguishable from GTK at a glance takes a complete palette foundation paired with targeted QSS polish:

  • 21-role palette (fluent-round-dark.conf): Defines all 21 standard QPalette color roles across active_colors (focused), inactive_colors (unfocused), and disabled_colors (disabled). Window surfaces (#202020), input fields (#262626), alternating rows (#2b2b2b), and button faces (#323232) match the exact grayscale ramp sampled from Fluent-round-Dark in Part 2. Selection highlights lock to #3584e4 (matching Colloid-Dark sky blue), desaturating naturally to #2c68b0 when unfocused, while link colors #62a0ea / #99c1f1 mirror fastfetch. Because this sets the underlying QPalette, even Qt5 apps with heavy custom widgets stay legible with zero inverted-contrast disasters.
  • Rounded stylesheet (fluent-round-dark.qss): Stock Fusion widgets have boxy corners and thick scrollbars. Our QSS softens QToolTip, QMenu, QPushButton, QLineEdit / QComboBox, and QTabBar::tab to 6px–8px radii, highlights focused inputs, primary buttons, and active tab underlines in #3584e4, and slims vertical/horizontal scrollbars down to 8px transparent tracks with 4px rounded floating handles.

Both full tested files are ready to copy below:

Expand full 21-role palette: ~/.config/qt5ct/colors/fluent-round-dark.conf
1
2
3
4
[ColorScheme]
active_colors=#ffeceff4, #ff323232, #ff484848, #ff3c3c3c, #ff1e1e1e, #ff282828, #ffeceff4, #ffffffff, #ffeceff4, #ff262626, #ff202020, #ff141414, #ff3584e4, #ffffffff, #ff62a0ea, #ff99c1f1, #ff2b2b2b, #ffeceff4, #ff2c2c2c, #ffeceff4, #80eceff4
disabled_colors=#ff7a7a7a, #ff2b2b2b, #ff3c3c3c, #ff333333, #ff1a1a1a, #ff232323, #ff7a7a7a, #ffaaaaaa, #ff7a7a7a, #ff222222, #ff202020, #ff141414, #ff2b4c75, #ffaaaaaa, #ff4b72a3, #ff6c87a8, #ff272727, #ff7a7a7a, #ff2c2c2c, #ff999999, #50eceff4
inactive_colors=#ffd8dee9, #ff303030, #ff454545, #ff3a3a3a, #ff1e1e1e, #ff282828, #ffd8dee9, #ffffffff, #ffd8dee9, #ff262626, #ff202020, #ff141414, #ff2c68b0, #ffeceff4, #ff62a0ea, #ff99c1f1, #ff2b2b2b, #ffd8dee9, #ff2c2c2c, #ffeceff4, #70eceff4
Expand full rounded QSS stylesheet: ~/.config/qt5ct/qss/fluent-round-dark.qss
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
/* Fluent-round-Dark aligned Qt5 stylesheet (qt5ct) */

QToolTip {
color: #eceff4;
background-color: #2c2c2c;
border: 1px solid #444444;
border-radius: 6px;
padding: 4px 8px;
}

QMenu {
background-color: #262626;
border: 1px solid #3c3c3c;
border-radius: 8px;
padding: 4px;
}

QMenu::item {
padding: 6px 20px 6px 12px;
border-radius: 6px;
}

QMenu::item:selected {
background-color: #3584e4;
color: #ffffff;
}

QPushButton {
background-color: #323232;
border: 1px solid #424242;
border-radius: 6px;
padding: 5px 12px;
min-height: 20px;
}

QPushButton:hover {
background-color: #3c3c3c;
border-color: #525252;
}

QPushButton:pressed {
background-color: #2a2a2a;
}

QPushButton:default {
background-color: #3584e4;
border-color: #3584e4;
color: #ffffff;
}

QLineEdit, QPlainTextEdit, QTextEdit, QSpinBox, QDoubleSpinBox, QComboBox {
background-color: #262626;
border: 1px solid #3d3d3d;
border-radius: 6px;
padding: 4px 8px;
}

QLineEdit:focus, QPlainTextEdit:focus, QTextEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus, QComboBox:focus {
border: 1px solid #3584e4;
}

QTabBar::tab {
background-color: #282828;
border: 1px solid #383838;
border-bottom: none;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
padding: 6px 14px;
margin-right: 2px;
}

QTabBar::tab:selected {
background-color: #323232;
border-bottom: 2px solid #3584e4;
}

QScrollBar:vertical {
background: transparent;
width: 8px;
margin: 2px;
}

QScrollBar:horizontal {
background: transparent;
height: 8px;
margin: 2px;
}

QScrollBar::handle:vertical, QScrollBar::handle:horizontal {
background: #4e4e4e;
border-radius: 4px;
min-height: 24px;
min-width: 24px;
}

QScrollBar::handle:hover {
background: #6a6a6a;
}

QScrollBar::add-line, QScrollBar::sub-line, QScrollBar::add-page, QScrollBar::sub-page {
background: none;
border: none;
width: 0px;
height: 0px;
}

2.4 Inject User-Space Env Vars and Verify with fastfetch

So that both GNOME GUI launchers and terminal shells pick up QT_QPA_PLATFORMTHEME, write it into systemd’s user environment directory (rootless) and add a fallback line in ~/.profile:

1
2
3
4
5
mkdir -p ~/.config/environment.d
printf 'QT_QPA_PLATFORMTHEME=qt5ct\n' > ~/.config/environment.d/qt5ct.conf

grep -q 'QT_QPA_PLATFORMTHEME=qt5ct' ~/.profile 2>/dev/null || \
printf '\nexport QT_QPA_PLATFORMTHEME=qt5ct\n' >> ~/.profile

Log out and back into GNOME (or test immediately in your current shell via export QT_QPA_PLATFORMTHEME=qt5ct), then run fastfetch. Seeing these three aligned lines confirms Qt5 and GTK2/3/4 are locked together:

1
2
3
Theme     Fusion [Qt], Fluent-round-Dark [GTK2/3/4]
Icons Colloid-Dark [Qt], Colloid-Dark [GTK2/3/4]
Font Inter (11pt) [Qt], Inter (11pt) [GTK2/3/4]

qt5ct styled with the Fluent-round-Dark palette and rounded QSS alongside fastfetch [Qt]/[GTK2/3/4] alignment


3. Editor Alignment: Lossless VS Code & Cursor Sync

Writing code takes up the majority of your day on a workstation. If your editor still runs default Dark+ or a different monospace font, jumping between Terminator and VS Code / Cursor feels jarring every single time.

3.1 Install Theme and File Icon Extensions in One Pass

VS Code and Cursor keep separate extension directories, so install both core extensions via CLI for each editor:

1
2
3
4
5
6
7
# VS Code
code --install-extension catppuccin.catppuccin-vsc
code --install-extension pkief.material-icon-theme

# Cursor (if the cursor CLI is installed)
cursor --install-extension catppuccin.catppuccin-vsc
cursor --install-extension pkief.material-icon-theme

Why Catppuccin Mocha + Material Icon Theme? Mocha‘s muted blue-gray canvas and low-glare foreground sit in the exact same dark color range as Fluent-round-Dark and our Terminator palette (#131722 + #89b4fa), staying comfortable over long sessions. Material Icon Theme‘s clean flat file icons also echo eza in the terminal and Colloid-Dark in file managers.

3.2 Edit settings.json Losslessly (Pitfall: Never Overwrite JSONC with jq)

VS Code reads ~/.config/Code/User/settings.json; Cursor reads ~/.config/Cursor/User/settings.json.

Watch out for a classic gotcha: both settings.json files are JSONC (JSON with Comments), which allows // line comments, /* */ block comments, and trailing commas. Running jq '. + {...}' settings.json either crashes immediately on comments or silently strips every inline note you painstakingly wrote.

Back up both files first, then merge the snippet below directly inside the editor so existing comments and extension keys remain untouched:

1
2
3
# Back up before editing
cp ~/.config/Code/User/settings.json ~/.config/Code/User/settings.json.bak 2>/dev/null || true
cp ~/.config/Cursor/User/settings.json ~/.config/Cursor/User/settings.json.bak 2>/dev/null || true

Core keys to merge into settings.json:

1
2
3
4
5
6
7
8
{
"workbench.colorTheme": "Catppuccin Mocha",
"workbench.iconTheme": "material-icon-theme",
"editor.fontFamily": "'Sarasa Term SC Nerd', 'JetBrains Mono', Consolas, monospace",
"terminal.integrated.fontFamily": "'Sarasa Term SC Nerd', monospace",
"editor.fontWeight": "400",
"editor.fontLigatures": true
}

A few tested details worth highlighting:

  • Pin Sarasa Term SC Nerd first in editor.fontFamily: Guarantees strict 2:1 alignment between Chinese comments and English code (especially welcome in Markdown tables, ASCII diagrams, and aligned inline comments), with 'JetBrains Mono', Consolas, monospace as clean fallbacks.
  • Set terminal.integrated.fontFamily explicitly: Ensures Powerlevel10k, eza, and btop render icons and braille graphs cleanly inside the integrated terminal panel with zero missing-glyph boxes.
  • editor.fontWeight: "400" + editor.fontLigatures: true: Locks regular 400 weight to prevent overly thin rendering under certain Linux hinting configs, while enabling programming ligatures like =>, !==, ->, and <=.

VS Code running Catppuccin Mocha, Material Icon Theme, and Sarasa Term SC Nerd with programming ligatures enabled


4. Chrome Dark Unification (Overwrite Protection + --restore Script)

With the terminal, Qt5, and editors aligned, Chrome is the last major visual outlier. Many guides tell you to edit ~/.config/google-chrome/Default/Preferences by hand—only for every edit to vanish the next time you open Chrome. Let’s look at why that happens, then solve it permanently with a safe script.

4.1 Pitfall: Why Editing Preferences While Chrome Is Running Always Fails

On startup, Chrome loads ~/.config/google-chrome/Default/Preferences completely into memory. If you edit the file on disk while Chrome is still running—even if every window looks closed while background extension processes remain alive—Chrome’s next periodic flush or clean shutdown overwrites the disk file from its in-memory copy, wiping your theme and font changes instantly.

Hence the non-negotiable rule for Chrome config edits: verify every Chrome process has exited first, then back up and write atomically.

4.2 Chromium Linux Theme Keys and Enum Values

To align Chrome on Linux with GNOME’s dark chrome and our font stack, you only need to patch three exact nodes in Preferences JSON (never touching bookmarks, extensions, accounts, or cookies):

  1. extensions.theme.system_theme (Chromium Linux system theme integration enum):
    • 0 = Classic (Chromium’s default classic theme; does not follow the GTK shell)
    • 1 = GTK (follows the active GNOME GTK theme)
    • 2 = QT (inherits Qt styling)
      Pitfall warning: Under GTK3 themes with a translucent headerbar such as Fluent-round-Dark, enabling GTK integration (system_theme = 1) causes Chrome to mis-map the translucent top bar into dark text on a gray background, destroying text contrast on inactive tabs and tab groups. The best practice is therefore to keep **0 (Classic theme) + color_scheme2 = 2 (Dark mode)**—syncing only the three web font families without enabling GTK shell integration.
  2. browser.theme.color_scheme2 = 2:
    Explicitly pins the browser to dark mode (2 = Dark) so the tab strip, address bar, and internal settings pages all retain crisp native high-contrast dark styling and never flash white across desktop session switches.
  3. webkit.webprefs.fonts:
    Syncs default web font families with our typography stack:
    • standard / sansserif: Inter for common script (Zyyy), HarmonyOS Sans SC for Simplified Chinese (Hans);
    • fixed (code blocks / monospace): Sarasa Term SC Nerd for both Zyyy and Hans.

4.3 apply-chrome-theme.sh: Running-Process Guard + Atomic Write + --restore

Hand-editing a minified multi-megabyte Preferences JSON file is error-prone and easy to forget to back up. Instead, put this zero-dependency script (Bash + stock Python 3) at ~/.local/bin/apply-chrome-theme.sh, built around four safeguards:

  1. Running-process guard: Uses exact process-name matching (pgrep -x chrome / pgrep -x google-chrome, intentionally avoiding pgrep -f chrome so it never self-matches its own filename) and aborts immediately if Chrome is still running.
  2. Automatic timestamped backups: Snapshots the original Preferences into ~/.local/share/chrome-theme-backups/ and updates a latest.bak symlink before every write.
  3. Same-directory temp file + os.replace() atomic swap: Uses Python’s standard json module to patch only the 3 target keys, flushes and fsyncs a sibling temp file, then atomically replaces Preferences—so an interrupted run can never leave a corrupted file.
  4. Built-in --restore one-click rollback: Close Chrome and pass --restore to revert cleanly to the exact prior state at any time.
Expand full apply-chrome-theme.sh
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
#!/usr/bin/env bash
set -euo pipefail

PROFILE="Default"
MODE="apply"
RESTORE_TARGET=""

usage() {
cat <<'EOF'
Usage:
apply-chrome-theme.sh [--profile <ProfileName>]
apply-chrome-theme.sh --restore [backup_file] [--profile <ProfileName>]

Options:
--profile <name> Chrome profile directory under ~/.config/google-chrome (default: Default)
--restore [file] Restore Preferences from latest backup (or a specific backup file)
-h, --help Show this help message
EOF
}

while [[ $# -gt 0 ]]; do
case "$1" in
--profile)
[[ $# -ge 2 ]] || { echo "[ERROR] --profile requires an argument." >&2; exit 1; }
PROFILE="$2"
shift 2
;;
--restore)
MODE="restore"
if [[ $# -ge 2 && "$2" != --* ]]; then
RESTORE_TARGET="$2"
shift 2
else
shift
fi
;;
-h|--help)
usage
exit 0
;;
*)
echo "[ERROR] Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done

CHROME_DIR="$HOME/.config/google-chrome"
PREFS_FILE="$CHROME_DIR/$PROFILE/Preferences"
BACKUP_DIR="$HOME/.local/share/chrome-theme-backups/$PROFILE"
LATEST_LINK="$BACKUP_DIR/latest.bak"

ensure_chrome_stopped() {
if pgrep -x chrome >/dev/null 2>&1 || pgrep -x google-chrome >/dev/null 2>&1; then
echo "[ERROR] Detected running Google Chrome process." >&2
echo " Please close all Chrome windows (and background apps) first so your changes are not overwritten." >&2
exit 1
fi
}

ensure_chrome_stopped

if [[ "$MODE" == "restore" ]]; then
SRC="${RESTORE_TARGET:-$LATEST_LINK}"
if [[ ! -f "$SRC" ]]; then
echo "[ERROR] Backup file not found: $SRC" >&2
exit 1
fi
mkdir -p "$(dirname "$PREFS_FILE")"
cp -a "$SRC" "$PREFS_FILE"
echo "[OK] Restored $PREFS_FILE from $(readlink -f "$SRC")"
exit 0
fi

if [[ ! -f "$PREFS_FILE" ]]; then
echo "[ERROR] Preferences file not found: $PREFS_FILE" >&2
echo " Launch Chrome once with profile '$PROFILE', close it, then re-run this script." >&2
exit 1
fi

mkdir -p "$BACKUP_DIR"
STAMP="$(date +%Y%m%d-%H%M%S)"
BACKUP_FILE="$BACKUP_DIR/Preferences.$STAMP.bak"
cp -a "$PREFS_FILE" "$BACKUP_FILE"
ln -sfn "$BACKUP_FILE" "$LATEST_LINK"
echo "[OK] Backed up original Preferences -> $BACKUP_FILE"

python3 - "$PREFS_FILE" <<'PY'
import json
import os
import sys
import tempfile

prefs_path = sys.argv[1]

with open(prefs_path, "r", encoding="utf-8") as f:
data = json.load(f)

# 1. Chromium Linux system theme enum: 0 = Classic, 1 = GTK, 2 = QT
# Keep Classic (0) under translucent GTK3 themes like Fluent-round-Dark to avoid gray/low-contrast inactive tabs
ext_theme = data.setdefault("extensions", {}).setdefault("theme", {})
ext_theme["system_theme"] = 0

# 2. Explicit dark color scheme: 2 = Dark
browser_theme = data.setdefault("browser", {}).setdefault("theme", {})
browser_theme["color_scheme2"] = 2

# 3. Align web fallback fonts with Inter / HarmonyOS Sans SC / Sarasa Term SC Nerd
fonts = data.setdefault("webkit", {}).setdefault("webprefs", {}).setdefault("fonts", {})
fonts.setdefault("standard", {}).update({
"Zyyy": "Inter",
"Hans": "HarmonyOS Sans SC",
})
fonts.setdefault("sansserif", {}).update({
"Zyyy": "Inter",
"Hans": "HarmonyOS Sans SC",
})
fonts.setdefault("fixed", {}).update({
"Zyyy": "Sarasa Term SC Nerd",
"Hans": "Sarasa Term SC Nerd",
})

# Atomic write in the same directory to prevent partial writes
prefs_dir = os.path.dirname(prefs_path)
fd, tmp_path = tempfile.mkstemp(prefix=".Preferences.", suffix=".tmp", dir=prefs_dir)
try:
with os.fdopen(fd, "w", encoding="utf-8") as tmp_f:
json.dump(data, tmp_f, ensure_ascii=False, separators=(",", ":"))
tmp_f.flush()
os.fsync(tmp_f.fileno())
os.replace(tmp_path, prefs_path)
except Exception:
if os.path.exists(tmp_path):
os.unlink(tmp_path)
raise
PY

echo "[OK] Updated Chrome Classic dark theme & web fonts in: $PREFS_FILE"
echo " Re-open Chrome to verify. To roll back later, close Chrome and run:"
echo " $0 --restore --profile $PROFILE"

Mark it executable and run it in two steps:

1
2
3
4
5
6
7
chmod +x ~/.local/bin/apply-chrome-theme.sh

# 1. Close Chrome completely first, then apply
~/.local/bin/apply-chrome-theme.sh

# Roll back anytime (again, close Chrome first)
~/.local/bin/apply-chrome-theme.sh --restore

Relaunch Chrome and check three things to confirm everything took effect:

  1. The tab strip, address bar, and tab groups display crisp native high-contrast dark styling (without the gray-on-dark contrast drop caused by translucent GTK mapping).
  2. Open chrome://settings/appearance and verify the theme is set to Classic + Dark mode and Standard / Sans-serif / Fixed-width fonts reflect the new stack.
  3. Open any technical doc or code page and confirm crisp CJK/Latin rendering and cleanly aligned monospace code blocks.

Chrome running with dark GTK window chrome and unified Inter, HarmonyOS Sans SC, and Sarasa Term SC Nerd fonts


5. One-Click Rollback and What’s Next

Every change in this guide lives inside your home directory across four decoupled modules—any single piece can be rolled back in seconds without affecting the rest:

Module Quick Rollback
Terminal CLI Suite Remove the eza/catp aliases from ~/.zshrc, and remove ~/.config/{bat,btop,fastfetch} plus ~/.local/bin/{eza,bat,btop,fastfetch}
Qt5 Appearance Remove ~/.config/environment.d/qt5ct.conf and strip QT_QPA_PLATFORMTHEME=qt5ct from ~/.profile (or move ~/.config/qt5ct/ aside), then log out and back in
VS Code / Cursor Copy the pre-edit settings.json.bak back over settings.json, and run --uninstall-extension if desired
Chrome Dark Theme Close Chrome completely and run ~/.local/bin/apply-chrome-theme.sh --restore

Once you’re inside GNOME, the entire working environment—top bar, Dock, dual file managers, typography, IME, terminal CLI, Qt5 apps, VS Code/Cursor, and Chrome—now shares one seamless dark engineering aesthetic.

Only the first dozen seconds after power-on still break the spell: from pressing the power button to typing your login password—the stock magenta GRUB menu, mismatched boot splash, purple-gray GDM login screen, and uncoordinated lockscreen. In the next part, we close that final mile with a non-destructive, fully reversible GRUB → Plymouth → GDM → Lockscreen loop, plus a global rollback matrix for the entire desktop stack.


Series Navigation

# Article Core Topics
#0 Ubuntu Workstation Setup · Series Index End-to-end architecture, dual-machine baseline, and reading roadmap
#1 Ubuntu 22.04 GNOME Desktop Configuration Guide Fundamentals: GNOME extensions, window ergonomics, and X11 vs. Wayland
#2 Desktop Visual Foundation, Frosted Glass Blur, and Dual File Manager Pitfalls Fluent-round-Dark, Colloid-Dark, Blur my Shell, and Nautilus/Nemo opacity fix
#3 Ubuntu Font Rendering, Strict fontconfig Binding, fcitx5 Theming, and Shortcut Pitfalls Inter + HarmonyOS Sans SC + Sarasa, strong binding, fcitx5, and Win+D fix
#4 👉 Current: Ending Cross-Toolkit Visual Clashes: Terminal CLI Suite, Qt5, VS Code/Cursor, and Chrome Dark Unification Modern terminal CLI, qt5ct 21-role palette + QSS, lossless editor config, offline-safe Chrome script
#5 End-to-End Boot and Lockscreen Loop: GRUB, Plymouth, GDM, and Lockscreen Dark boot-to-lockscreen loop, non-destructive GDM via update-alternatives, and global rollback matrix
#6 Ubuntu vimplus Setup and Configuration Guide Terminal IDE stack: 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 statusline, and large-file freeze protection
#8 End-to-End Ubuntu Dev Tools Visual & Workflow Unification: VS Code, Cursor, tmux, Git Delta, fzf, and Typora Fine-tuned VS Code/Cursor, plugin-free tmux pill status bar, delta/fzf/fd/zoxide chain, and Typora/Guake/gedit polish