This is tested on Omarchy Linux which uses waybar as the default bar. It should work on any distro that supports waybar.
Install jcal:
yay -S jcalThis script will be used to display the date and the tooltip in the waybar while keeping the colors. You can store it anywhere but I assume ~/jalai_date (update everywhere accordingly).
#!/usr/bin/env python3
import subprocess
import re
import json
# ANSI SGR color → Pango attribute mapping (Dayfox light theme)
ANSI_FG = {
'31': '#D14D41', # red → Fridays/holidays
# '37' (white) intentionally skipped — invisible on light bg, use tooltip default
}
ANSI_BG = {
'47': '#CECDC3', # white bg → today highlight
}
def escape_xml(s):
return s.replace('&', '&').replace('<', '<').replace('>', '>')
def ansi_to_pango(text):
result = []
span_depth = 0
pattern = re.compile(r'\x1b\[([0-9;]*)m')
last_end = 0
for match in pattern.finditer(text):
result.append(escape_xml(text[last_end:match.start()]))
code_str = match.group(1)
if code_str in ('0', ''):
if span_depth > 0:
result.append('</span>' * span_depth)
span_depth = 0
else:
fg = None
bg = None
for code in code_str.split(';'):
if code in ANSI_FG:
fg = ANSI_FG[code]
elif code in ANSI_BG:
bg = ANSI_BG[code]
attrs = []
if fg:
attrs.append(f"color='{fg}'")
if bg:
attrs.append(f"background='{bg}'")
if attrs:
result.append(f"<span {' '.join(attrs)}>")
span_depth += 1
last_end = match.end()
result.append(escape_xml(text[last_end:]))
if span_depth > 0:
result.append('</span>' * span_depth)
return ''.join(result)
text = subprocess.check_output(['jdate', '+%W'], text=True).strip()
cal_raw = subprocess.check_output(['jcal', '-p'], text=True).rstrip('\n')
cal_pango = ansi_to_pango(cal_raw)
tooltip = f"<small>{cal_pango}</small>"
print(json.dumps({"text": text, "tooltip": tooltip}))Update waybar config at ~/.config/waybar/config.jsonc:
Reload waybar in Omarchy by pressing Super+Shift+Space twice.
To add more space from the clock module you can add this to the ~/.config/waybar/style.css:
#clock {
margin-left: 20px;
}
{ // ... other configs ... "modules-center": ["custom/persian", ...], // ... other configs ... "custom/persian": { "exec": "~/jalali_date", "interval": 60, "return-type": "json" } }