Skip to content

Commit 648bc54

Browse files
committed
Unify font sizes through qs.Commons.Style
Themes now drive typography the same way they drive colors: one [font] base-size in shell.toml is the rem root, and every Style.font.<token> (caption, bodySmall, body, subtitle, title, heading, display, displayLarge, iconSmall, icon, iconLarge) derives from it via a fixed multiplier. Themes can also pin individual tokens for stylistic emphasis. base-size is clamped 11..13 until row-height tokens exist. Bar dimensions move to the same singleton: [bar] size-horizontal / size-vertical replace the hardcoded 26/28 in Bar.qml, exposed as Style.bar.sizeHorizontal / sizeVertical. Style.qml also resolves the fontconfig 'monospace' alias via fc-match and exposes Style.font.resolvedFamily so panels can display the concrete family. Watches ~/.config/fontconfig/fonts.conf so it tracks 'omarchy font set <name>'. The qs.Ui kit (PillButton, Dropdown, Toggle, TextField, etc.) and every first-party plugin (bar widgets, settings, menu, clipboard, emoji, polkit, notifications, osd, image-picker, dev-gallery) now bind to Style.font.* instead of pixel literals. Only three deliberate display-scale outliers remain: the notification empty-state glyph and the weather flyout's hero temperature pair, all commented. Background plugin's applyTheme IPC fast-path also pushes shell.toml to Style so theme swaps update typography and bar size without waiting for inotify debounce. Dev gallery (omarchy dev ui-preview) now ships a Typography section that renders the full scale and theme tokens live, and its summon command is fixed (omarchy-shell-ipc -> omarchy-shell).
1 parent c26cf49 commit 648bc54

41 files changed

Lines changed: 762 additions & 285 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎bin/omarchy-dev-ui-preview‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# omarchy:summary=Open the omarchy-shell dev gallery (qs.Ui kit preview)
44

5-
omarchy-shell-ipc shell summon omarchy.dev-gallery '{}'
5+
omarchy-shell shell summon omarchy.dev-gallery '{}'

‎default/themed/shell.toml.tpl‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1-
# Omarchy shell colors. Defaults derive from colors.toml; themes can ship
2-
# themes/<name>/shell.toml to override individual keys.
1+
# Omarchy shell surfaces. Colors derive from colors.toml; sizes and the
2+
# typographic scale come from the keys below. Themes can ship
3+
# themes/<name>/shell.toml to override any individual key.
34

45
[bar]
56
background = "{{ background }}"
67
text = "{{ foreground }}"
78
# Modules calling attention to themselves (recording, voxtype, alerts, updates)
89
active = "{{ color1 }}"
10+
# Cross-axis size in px. size-horizontal is the height of top/bottom bars;
11+
# size-vertical is the width of left/right bars.
12+
size-horizontal = 26
13+
size-vertical = 28
14+
15+
[font]
16+
# base-size is the rem root for the type scale. Every Style.font.<token>
17+
# derives from it (e.g. body = base, subtitle ≈ base * 1.083,
18+
# heading ≈ base * 1.333). Clamped 11..13 by the shell — row heights are
19+
# fixed until we ship matching spacing tokens, so growth would clip.
20+
base-size = 12
21+
# Per-token overrides, in px. Uncomment any to pin a specific size without
22+
# affecting the rest of the scale. Useful for stylistic emphasis (a
23+
# minimalist theme that wants a bigger heading without scaling everything).
24+
# caption = 10
25+
# body-small = 11
26+
# body = 12
27+
# subtitle = 13
28+
# title = 14
29+
# heading = 16
30+
# display = 24
31+
# display-large = 28
32+
# icon-small = 11
33+
# icon = 14
34+
# icon-large = 18
935

1036
[popups]
1137
# Shared by every bar flyout. Body text inside flyouts is not separately

‎docs/omarchy-shell.md‎

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,80 @@ Rules:
9999
user `shell.json` exists, defaults are used verbatim. Once the user
100100
customizes, `shell.json` is canonical — there is no deep-merge.
101101

102+
## Theme tokens
103+
104+
Themes ship colors in `themes/<name>/colors.toml` and surface roles +
105+
sizing in `themes/<name>/shell.toml`. Defaults are generated from
106+
`default/themed/shell.toml.tpl`; a theme may also drop a hand-written
107+
`shell.toml` next to its `colors.toml` to override individual keys.
108+
109+
The shell exposes these tokens to QML via two singletons in
110+
`qs.Commons`:
111+
112+
- `Color` — palette (`foreground`, `background`, `accent`, `urgent`)
113+
and per-surface roles (`Color.bar.*`, `Color.popups.*`,
114+
`Color.notifications.*`, `Color.menu.*`, `Color.imagePicker.*`).
115+
- `Style` — structural tokens (`cornerRadius`, focus affordances),
116+
the type scale (`Style.font.*`), and bar dimensions
117+
(`Style.bar.sizeHorizontal` / `Style.bar.sizeVertical`).
118+
119+
### Typography
120+
121+
`[font] base-size` is the rem root for the scale. Every
122+
`Style.font.<token>` derives from it via a fixed multiplier, so
123+
bumping `base-size` rescales the whole shell proportionally:
124+
125+
| Token | Multiplier | Default |
126+
|-----------------------|------------|---------|
127+
| `Style.font.caption` | 0.833 | 10 |
128+
| `Style.font.bodySmall` | 0.917 | 11 |
129+
| `Style.font.body` | 1.0 | 12 |
130+
| `Style.font.subtitle` | 1.083 | 13 |
131+
| `Style.font.title` | 1.167 | 14 |
132+
| `Style.font.heading` | 1.333 | 16 |
133+
| `Style.font.display` | 2.0 | 24 |
134+
| `Style.font.displayLarge` | 2.333 | 28 |
135+
| `Style.font.iconSmall` | bodySmall | 11 |
136+
| `Style.font.icon` | title | 14 |
137+
| `Style.font.iconLarge` | 1.5 | 18 |
138+
139+
A theme can either scale everything by tweaking `base-size`:
140+
141+
```toml
142+
[font]
143+
base-size = 13 # roomier
144+
```
145+
146+
…or pin individual tokens for stylistic emphasis without affecting
147+
the rest of the scale:
148+
149+
```toml
150+
[font]
151+
base-size = 12
152+
heading = 20
153+
display-large = 36
154+
```
155+
156+
Recognized override keys: `base-size`, `caption`, `body-small`,
157+
`body`, `subtitle`, `title`, `heading`, `display`, `display-large`,
158+
`icon-small`, `icon`, `icon-large`.
159+
160+
`base-size` is clamped to **11..13** because row heights and the bar
161+
cross-axis size are fixed; per-token overrides aren't clamped. The
162+
shell font family is the fontconfig `monospace` alias — themes don't
163+
set it, the user does via `omarchy font set <name>`.
164+
165+
### Bar size
166+
167+
`[bar] size-horizontal` / `size-vertical` set the cross-axis dimension
168+
of top/bottom and left/right bars respectively (in px):
169+
170+
```toml
171+
[bar]
172+
size-horizontal = 26 # top/bottom bar height
173+
size-vertical = 28 # left/right bar width
174+
```
175+
102176
## Custom bar modules
103177

104178
If a full plugin is overkill, declare a one-off module inline in

‎shell/Commons/Style.qml‎

Lines changed: 158 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Quickshell
44
import Quickshell.Io
55

66
// Shared structural style tokens for the shell. Color is the palette
7-
// singleton; Style holds the *shape* and *focus-affordance* tokens that
8-
// every panel surface and qs.Ui component should bind to so they stay
9-
// in sync as the user toggles round/sharp corners or as themes change.
7+
// singleton; Style holds everything else themes can influence — corner
8+
// rounding, focus affordances, typography scale, and bar dimensions —
9+
// so panels and qs.Ui components have a single source of truth.
1010
//
1111
// `cornerRadius` mirrors Hyprland's `decoration:rounding`. Themes ship
1212
// their own rounding via theme/hyprland.lua; the user toggle via
@@ -15,9 +15,11 @@ import Quickshell.Io
1515
// up the change here by re-running `hyprctl getoption` whenever either
1616
// of those input files changes.
1717
//
18-
// Single source of truth lives in Hyprland; the shell follows. That
19-
// means a theme that ships `rounding = 10` gives us 10px panels by
20-
// default, and the round/sharp user toggle still works on top of it.
18+
// Typography and bar size come from `theme/shell.toml`. `[font] base-size`
19+
// is the rem root; every `Style.font.<token>` derives from it via the
20+
// scale multipliers below unless the theme pins that specific token.
21+
// `[bar] size-horizontal` / `size-vertical` set the cross-axis dimension
22+
// for top/bottom and left/right bars respectively.
2123
QtObject {
2224
id: root
2325

@@ -36,6 +38,69 @@ QtObject {
3638
readonly property color hotFill: Qt.rgba(Color.foreground.r, Color.foreground.g, Color.foreground.b, 0.08)
3739
readonly property color selectedFill: Qt.rgba(Color.foreground.r, Color.foreground.g, Color.foreground.b, 0.18)
3840

41+
// ---------------------------------------------------------- typography
42+
//
43+
// `fontFamily` defaults to "monospace" so the bar and every qs.Ui
44+
// component follows the fontconfig alias `omarchy-font-set` writes.
45+
// Themes can override per-token via [font] in shell.toml, but the
46+
// family stays system-wide.
47+
property string fontFamily: "monospace"
48+
49+
// The concrete family `monospace` resolves to right now, e.g.
50+
// "JetBrainsMono Nerd Font". Bind `font.family` to `fontFamily` (so the
51+
// alias path keeps working when the user runs `omarchy font set`), but
52+
// read `resolvedFontFamily` when you want to *display* what's drawing.
53+
property string resolvedFontFamily: "monospace"
54+
55+
// Clamped 11..13 by loadShell — bar height and row heights are fixed
56+
// until we ship matching spacing tokens, so unbounded growth clips.
57+
property int fontBaseSize: 12
58+
59+
// Parsed maps populated by loadShell. Keep them as plain dicts so
60+
// reassigning the whole property fires reactive bindings.
61+
property var fontOverrides: ({})
62+
property var barOverrides: ({})
63+
64+
function fontPx(mult) {
65+
return Math.max(1, Math.round(fontBaseSize * mult))
66+
}
67+
68+
function fontToken(key, fallback) {
69+
var v = fontOverrides[key]
70+
var n = Number(v)
71+
return (isFinite(n) && n > 0) ? Math.round(n) : fallback
72+
}
73+
74+
function barToken(key, fallback) {
75+
var v = barOverrides[key]
76+
var n = Number(v)
77+
return (isFinite(n) && n > 0) ? Math.round(n) : fallback
78+
}
79+
80+
readonly property QtObject font: QtObject {
81+
readonly property string family: root.fontFamily
82+
readonly property string resolvedFamily: root.resolvedFontFamily
83+
readonly property int baseSize: root.fontBaseSize
84+
85+
readonly property int caption: root.fontToken("caption", root.fontPx(0.833)) // 10
86+
readonly property int bodySmall: root.fontToken("body-small", root.fontPx(0.917)) // 11
87+
readonly property int body: root.fontToken("body", root.fontPx(1.0)) // 12
88+
readonly property int subtitle: root.fontToken("subtitle", root.fontPx(1.083)) // 13
89+
readonly property int title: root.fontToken("title", root.fontPx(1.167)) // 14
90+
readonly property int heading: root.fontToken("heading", root.fontPx(1.333)) // 16
91+
readonly property int display: root.fontToken("display", root.fontPx(2.0)) // 24
92+
readonly property int displayLarge: root.fontToken("display-large", root.fontPx(2.333)) // 28
93+
94+
readonly property int iconSmall: root.fontToken("icon-small", bodySmall)
95+
readonly property int icon: root.fontToken("icon", title)
96+
readonly property int iconLarge: root.fontToken("icon-large", root.fontPx(1.5)) // 18
97+
}
98+
99+
readonly property QtObject bar: QtObject {
100+
readonly property int sizeHorizontal: root.barToken("size-horizontal", 26)
101+
readonly property int sizeVertical: root.barToken("size-vertical", 28)
102+
}
103+
39104
function refresh() {
40105
hyprctlProc.running = true
41106
}
@@ -50,6 +115,43 @@ QtObject {
50115
}
51116
}
52117

118+
// Parse [font] base-size + per-token overrides and [bar] size-* keys
119+
// out of shell.toml. Color.qml owns the quoted-string side of the same
120+
// file; we only care about the unquoted integer values here.
121+
function loadShell(raw) {
122+
var fontOut = {}
123+
var barOut = {}
124+
var nextBase = 12
125+
var text = String(raw || "")
126+
if (text) {
127+
var lines = text.split("\n")
128+
var section = ""
129+
for (var i = 0; i < lines.length; i++) {
130+
var line = lines[i].replace(/^\s+|\s+$/g, "")
131+
if (!line || line.charAt(0) === "#") continue
132+
var sectionMatch = line.match(/^\[([A-Za-z0-9_-]+)\]\s*(#.*)?$/)
133+
if (sectionMatch) { section = sectionMatch[1]; continue }
134+
var kv = line.match(/^([A-Za-z0-9_-]+)\s*=\s*(-?\d+)\s*(#.*)?$/)
135+
if (!kv) continue
136+
var key = kv[1]
137+
var val = parseInt(kv[2], 10)
138+
if (section === "font") {
139+
if (key === "base-size") nextBase = val
140+
else fontOut[key] = val
141+
} else if (section === "bar" && (key === "size-horizontal" || key === "size-vertical")) {
142+
barOut[key] = val
143+
}
144+
}
145+
}
146+
// Clamp the rem root. Per-token overrides aren't clamped — a theme
147+
// that wants display-large = 64 should be allowed to ship it.
148+
if (nextBase < 11) nextBase = 11
149+
if (nextBase > 13) nextBase = 13
150+
fontBaseSize = nextBase
151+
fontOverrides = fontOut
152+
barOverrides = barOut
153+
}
154+
53155
property Process hyprctlProc: Process {
54156
id: hyprctlProc
55157
command: ["hyprctl", "-j", "getoption", "decoration:rounding"]
@@ -59,6 +161,34 @@ QtObject {
59161
}
60162
}
61163

164+
// Resolve the fontconfig alias to a concrete family name. `omarchy font
165+
// set <name>` rewrites ~/.config/fontconfig/fonts.conf and restarts the
166+
// shell, but rerun on file change anyway so manual edits propagate too.
167+
function resolveFontFamily() {
168+
fcMatchProc.running = true
169+
}
170+
171+
property Process fcMatchProc: Process {
172+
id: fcMatchProc
173+
command: ["fc-match", "-f", "%{family[0]}", "monospace"]
174+
stdout: StdioCollector {
175+
waitForEnd: true
176+
onStreamFinished: {
177+
var name = String(text || "").trim()
178+
if (name.length > 0) root.resolvedFontFamily = name
179+
}
180+
}
181+
}
182+
183+
property FileView fontconfigFile: FileView {
184+
path: Quickshell.env("HOME") + "/.config/fontconfig/fonts.conf"
185+
watchChanges: true
186+
printErrors: false
187+
onFileChanged: root.resolveFontFamily()
188+
onLoaded: root.resolveFontFamily()
189+
onLoadFailed: root.resolveFontFamily()
190+
}
191+
62192
// Re-poll Hyprland a beat after either input file changes. Hyprland's
63193
// auto-reload runs asynchronously when its sourced .lua files change,
64194
// so racing it with an immediate hyprctl gives the old value. 200ms is
@@ -71,12 +201,18 @@ QtObject {
71201
}
72202

73203
// The theme name flips whenever `omarchy-theme-set` swaps the theme/
74-
// symlink; that's when theme/hyprland.lua's `rounding` value changes.
204+
// symlink; that's when theme/hyprland.lua's `rounding` value changes
205+
// and the new theme/shell.toml drops into place. Force a reload of
206+
// shell.toml here so we don't wait on the inotify watch — Color.qml
207+
// uses the same tripwire for the same reason.
75208
property FileView themeNameFile: FileView {
76209
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme.name"
77210
watchChanges: true
78211
printErrors: false
79-
onFileChanged: refreshTimer.restart()
212+
onFileChanged: {
213+
refreshTimer.restart()
214+
shellTomlFile.reload()
215+
}
80216
}
81217

82218
// `omarchy style corners <round|sharp>` creates or removes this flag file.
@@ -91,5 +227,18 @@ QtObject {
91227
onLoadFailed: refreshTimer.restart()
92228
}
93229

94-
Component.onCompleted: refresh()
230+
property FileView shellTomlFile: FileView {
231+
id: shellTomlFile
232+
path: Quickshell.env("HOME") + "/.config/omarchy/current/theme/shell.toml"
233+
watchChanges: true
234+
printErrors: false
235+
onLoaded: root.loadShell(text())
236+
onLoadFailed: root.loadShell("")
237+
onFileChanged: reload()
238+
}
239+
240+
Component.onCompleted: {
241+
refresh()
242+
resolveFontFamily()
243+
}
95244
}

‎shell/Ui/ChoiceButton.qml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Rectangle {
2626
property color foreground: Color.foreground
2727
property color background: Color.background
2828
property color accent: Color.accent
29-
property string fontFamily: "monospace"
30-
property real fontSize: 12
29+
property string fontFamily: Style.font.family
30+
property real fontSize: Style.font.body
3131

3232
signal clicked()
3333
signal hovered(bool isHovered)

0 commit comments

Comments
 (0)