dunst: make the font size and width settings, defaulting to today's values (hq ADR 0262)

The laptop's 242 DPI panel shows Inter 10 at less than half the workstation's size. The
defaults keep every machine's file byte for byte as it is; a machine sets its own.
This commit is contained in:
jochen
2026-10-08 17:02:43 +02:00
parent bf542128ee
commit 4c34836037
5 changed files with 82 additions and 15 deletions
@@ -12,22 +12,30 @@ import (
// every desktop module that carries it.
type manifest struct {
Module string `json:"module"`
Version string `json:"version"`
Capabilities []string `json:"capabilities"`
Requires []string `json:"requires"`
Claims []claim `json:"claims"`
Seats []any `json:"seats"`
Tools []string `json:"tools"`
Emits []string `json:"emits"`
Environment *environment `json:"environment"`
Shell []shellCode `json:"shell"`
Resources []map[string]any `json:"resources"`
Module string `json:"module"`
Version string `json:"version"`
Capabilities []string `json:"capabilities"`
Requires []string `json:"requires"`
Claims []claim `json:"claims"`
Seats []any `json:"seats"`
Tools []string `json:"tools"`
Settings map[string]setting `json:"settings"`
Emits []string `json:"emits"`
Environment *environment `json:"environment"`
Shell []shellCode `json:"shell"`
Resources []map[string]any `json:"resources"`
Build struct {
Artifacts []map[string]any `json:"artifacts"`
} `json:"build"`
}
// setting is one key's default, as the definition gives it (novox/hq ADR 0262).
type setting struct {
Kind string `json:"kind"`
Default any `json:"default"`
Why string `json:"why"`
}
type claim struct {
Name string `json:"name"`
Scope string `json:"scope"`
+30 -1
View File
@@ -43,7 +43,8 @@ func TestItOwnsItsFileAndTheDropInDirectory(t *testing.T) {
func TestTheFileIsTheDecidedOneAndCallsTheSeatsMenu(t *testing.T) {
m := readManifest(t)
c := m.resource(t, "configuration")["content"].(string)
for _, want := range []string{"origin = top-right", "transparency = 0", "corner_radius = 0", "font = Inter 10", "dmenu = dmenu -p dunst"} {
for _, want := range []string{"origin = top-right", "transparency = 0", "corner_radius = 0", "font = Inter ${setting:font-size}",
"width = ${setting:width}", "dmenu = dmenu -p dunst"} {
if !strings.Contains(c, " "+want+"\n") {
t.Errorf("lacks %q", want)
}
@@ -55,6 +56,34 @@ func TestTheFileIsTheDecidedOneAndCallsTheSeatsMenu(t *testing.T) {
}
}
// The font size and the width are preferences with today's values as their defaults (novox/hq ADR
// 0262): a machine with a denser screen sets its own, and every other machine's file is unchanged.
func TestTheFontSizeAndWidthAreSettingsWithTodaysDefaults(t *testing.T) {
m := readManifest(t)
want := map[string]float64{"font-size": 10, "width": 250}
if len(m.Settings) != len(want) {
t.Fatalf("settings: %+v", m.Settings)
}
for key, value := range want {
s, ok := m.Settings[key]
if !ok || s.Kind != "preference" || s.Default != value || strings.TrimSpace(s.Why) == "" {
t.Errorf("%s: %+v, want a preference defaulting to %v with why", key, s, value)
}
}
// Filled with the defaults, the file is the one every machine had before it took settings.
c := m.resource(t, "configuration")["content"].(string)
c = strings.ReplaceAll(c, "${setting:font-size}", "10")
c = strings.ReplaceAll(c, "${setting:width}", "250")
for _, want := range []string{"font = Inter 10", "width = 250"} {
if !strings.Contains(c, " "+want+"\n") {
t.Errorf("filled with the defaults, lacks %q", want)
}
}
if strings.Contains(c, "${setting:") {
t.Errorf("asks for a setting it gives no default: %s", c)
}
}
func TestNothingStartsItButTheBus(t *testing.T) {
m := readManifest(t)
if m.Shell != nil {