From 5812a7d04a2436965da0db242ad1698df185f586 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 1 Jun 2026 11:59:30 +0200 Subject: [PATCH] No leading zeros on the date in the bar --- config/omarchy/shell.json | 2 +- migrations/1780294774.sh | 31 ++++++++++++++++++++++ shell/plugins/bar/widgets/Clock.qml | 2 +- test/shell.d/config-test.sh | 41 +++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 migrations/1780294774.sh diff --git a/config/omarchy/shell.json b/config/omarchy/shell.json index b1997a36..a1d73f13 100644 --- a/config/omarchy/shell.json +++ b/config/omarchy/shell.json @@ -21,7 +21,7 @@ { "id": "omarchy.clock", "format": "dddd HH:mm", - "formatAlt": "dd MMMM 'W'ww yyyy", + "formatAlt": "d MMMM 'W'ww yyyy", "verticalFormat": "HH\n\u2014\nmm" }, { diff --git a/migrations/1780294774.sh b/migrations/1780294774.sh new file mode 100644 index 00000000..149276a7 --- /dev/null +++ b/migrations/1780294774.sh @@ -0,0 +1,31 @@ +echo "Remove leading zero from bar clock date" + +config_file="$HOME/.config/omarchy/shell.json" + +if [[ -f $config_file ]] && omarchy-cmd-present jq; then + tmp=$(mktemp) + jq ' + def update_clock_format: + if type == "object" and (.id // "") == "omarchy.clock" and (.formatAlt // "") == "dd MMMM \u0027W\u0027ww yyyy" then + .formatAlt = "d MMMM \u0027W\u0027ww yyyy" + else + . + end; + + .bar.layout |= ( + if type == "object" then + with_entries( + .value |= ( + if type == "array" then + map(update_clock_format) + else + . + end + ) + ) + else + . + end + ) + ' "$config_file" >"$tmp" && mv "$tmp" "$config_file" || rm -f "$tmp" +fi diff --git a/shell/plugins/bar/widgets/Clock.qml b/shell/plugins/bar/widgets/Clock.qml index f1010793..fba368c0 100644 --- a/shell/plugins/bar/widgets/Clock.qml +++ b/shell/plugins/bar/widgets/Clock.qml @@ -12,7 +12,7 @@ BarWidget { property date displayDate: clock.date readonly property string activeFormat: alt - ? setting("formatAlt", "dd MMMM 'W'ww yyyy") + ? setting("formatAlt", "d MMMM 'W'ww yyyy") : (bar && bar.vertical ? setting("verticalFormat", "HH\n—\nmm") : setting("format", "dddd HH:mm")) function refresh() { diff --git a/test/shell.d/config-test.sh b/test/shell.d/config-test.sh index 7adcb52e..853f8dba 100755 --- a/test/shell.d/config-test.sh +++ b/test/shell.d/config-test.sh @@ -39,6 +39,11 @@ jq -e ' ' "$ROOT/config/omarchy/shell.json" >/dev/null pass "default center anchor exists in center layout" +jq -e ' + any(.bar.layout.center[]; (.id // .) == "omarchy.clock" and (.formatAlt // "") == "d MMMM \u0027W\u0027ww yyyy") +' "$ROOT/config/omarchy/shell.json" >/dev/null +pass "default clock date format has no leading zero" + ROOT="$ROOT" python3 <<'PY' import json import os @@ -235,3 +240,39 @@ HOME="$TMPDIR/home" bash "$migration" after=$(sha256sum "$TMPDIR/home/.config/omarchy/shell.json" | awk '{print $1}') [[ $before == "$after" ]] || fail "update placement migration is idempotent" pass "update placement migration is idempotent" + +clock_migration=$(grep -rl 'Remove leading zero from bar clock date' "$ROOT/migrations" | head -n 1 || true) +[[ -n $clock_migration ]] || fail "clock date format migration exists" + +cat >"$TMPDIR/home/.config/omarchy/shell.json" <<'JSON' +{ + "version": 1, + "bar": { + "layout": { + "left": [], + "center": [ + { "id": "omarchy.clock", "formatAlt": "dd MMMM 'W'ww yyyy" }, + { "id": "omarchy.weather" } + ], + "right": [ + { "id": "local.clock", "formatAlt": "dd MMMM 'W'ww yyyy" } + ] + } + }, + "plugins": [] +} +JSON + +HOME="$TMPDIR/home" bash "$clock_migration" + +jq -e ' + .bar.layout.center[0].formatAlt == "d MMMM \u0027W\u0027ww yyyy" and + .bar.layout.right[0].formatAlt == "dd MMMM \u0027W\u0027ww yyyy" +' "$TMPDIR/home/.config/omarchy/shell.json" >/dev/null +pass "clock date format migration removes leading zero from clock" + +before=$(sha256sum "$TMPDIR/home/.config/omarchy/shell.json" | awk '{print $1}') +HOME="$TMPDIR/home" bash "$clock_migration" +after=$(sha256sum "$TMPDIR/home/.config/omarchy/shell.json" | awk '{print $1}') +[[ $before == "$after" ]] || fail "clock date format migration is idempotent" +pass "clock date format migration is idempotent"