No leading zeros on the date in the bar

This commit is contained in:
David Heinemeier Hansson
2026-06-01 11:59:30 +02:00
parent 99bb924f37
commit 5812a7d04a
4 changed files with 74 additions and 2 deletions
+1 -1
View File
@@ -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"
},
{
+31
View File
@@ -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
+1 -1
View File
@@ -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() {
+41
View File
@@ -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"