No leading zeros on the date in the bar
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
{
|
{
|
||||||
"id": "omarchy.clock",
|
"id": "omarchy.clock",
|
||||||
"format": "dddd HH:mm",
|
"format": "dddd HH:mm",
|
||||||
"formatAlt": "dd MMMM 'W'ww yyyy",
|
"formatAlt": "d MMMM 'W'ww yyyy",
|
||||||
"verticalFormat": "HH\n\u2014\nmm"
|
"verticalFormat": "HH\n\u2014\nmm"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -12,7 +12,7 @@ BarWidget {
|
|||||||
property date displayDate: clock.date
|
property date displayDate: clock.date
|
||||||
|
|
||||||
readonly property string activeFormat: alt
|
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"))
|
: (bar && bar.vertical ? setting("verticalFormat", "HH\n—\nmm") : setting("format", "dddd HH:mm"))
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ jq -e '
|
|||||||
' "$ROOT/config/omarchy/shell.json" >/dev/null
|
' "$ROOT/config/omarchy/shell.json" >/dev/null
|
||||||
pass "default center anchor exists in center layout"
|
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'
|
ROOT="$ROOT" python3 <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -235,3 +240,39 @@ HOME="$TMPDIR/home" bash "$migration"
|
|||||||
after=$(sha256sum "$TMPDIR/home/.config/omarchy/shell.json" | awk '{print $1}')
|
after=$(sha256sum "$TMPDIR/home/.config/omarchy/shell.json" | awk '{print $1}')
|
||||||
[[ $before == "$after" ]] || fail "update placement migration is idempotent"
|
[[ $before == "$after" ]] || fail "update placement migration is idempotent"
|
||||||
pass "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"
|
||||||
|
|||||||
Reference in New Issue
Block a user