Customize waybar with Catppuccin Latte theme and niri modules
- Replace sway modules with niri/workspaces, niri/window, niri/language - Remove battery, backlight, mpd (desktop machine) - Add custom modules: GPU (nvidia-smi), weather (wttr.in), mail (Thunderbird) - Add disk, privacy modules - Catppuccin Latte colors with Mocha dark background - Wi-Fi signal level icon, bold 15px font - Scripts for GPU, weather, and mail monitoring Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
45
bazzite/waybar/scripts/mail.py
Normal file
45
bazzite/waybar/scripts/mail.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
import glob
|
||||
import json
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
profile_dirs = glob.glob(
|
||||
os.path.expanduser("~/.var/app/org.mozilla.Thunderbird/.thunderbird/*.default-esr")
|
||||
) or glob.glob(
|
||||
os.path.expanduser("~/.thunderbird/*.default-esr")
|
||||
)
|
||||
|
||||
if not profile_dirs:
|
||||
print(json.dumps({"text": "", "tooltip": "No Thunderbird profile found"}))
|
||||
exit()
|
||||
|
||||
db_path = os.path.join(profile_dirs[0], "global-messages-db.sqlite")
|
||||
if not os.path.exists(db_path):
|
||||
print(json.dumps({"text": "", "tooltip": "No message database"}))
|
||||
exit()
|
||||
|
||||
try:
|
||||
conn = sqlite3.connect(f"file:{db_path}?mode=ro&nolock=1", uri=True)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"SELECT COUNT(*) FROM messages WHERE jsonAttributes LIKE '%\"read\":false%' OR jsonAttributes LIKE '%\"read\": false%'"
|
||||
)
|
||||
count = cursor.fetchone()[0]
|
||||
conn.close()
|
||||
except Exception:
|
||||
# fallback: try folderStatus
|
||||
try:
|
||||
conn = sqlite3.connect(f"file:{db_path}?mode=ro&nolock=1", uri=True)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT SUM(numNewMessages) FROM folderlocations WHERE numNewMessages > 0")
|
||||
row = cursor.fetchone()
|
||||
count = row[0] if row and row[0] else 0
|
||||
conn.close()
|
||||
except Exception:
|
||||
count = 0
|
||||
|
||||
if count > 0:
|
||||
print(json.dumps({"text": f" {count}", "tooltip": f"{count} unread emails", "class": "unread"}))
|
||||
else:
|
||||
print(json.dumps({"text": "", "tooltip": "No unread emails"}))
|
||||
Reference in New Issue
Block a user