Jean-Tinland / simple-bar

A yabai status bar widget for Übersicht
https://www.jeantinland.com/toolbox/simple-bar
MIT License
1.21k stars 129 forks source link

Mail plugin #223

Closed BR00l closed 3 years ago

BR00l commented 3 years ago

Hello there, you have done an asthonishing work here, I really like the whole setup and the idea of this bar! I have one request though, Is there a possibility for a mail indicator plugin on the bar?

kvndrsslr commented 3 years ago

You can just implement this as a user plugin. The script for simple global inbox count:

osascript -l JavaScript -e '(x => {x.checkForNewMail();return x.inbox().unreadCount()})(Application("Mail"))'

My personal script (unread count over all mailboxes except my gmail accounts archive ('All Mail') to avoid duplicates):

osascript -l JavaScript -e '(x => {x.checkForNewMail();return x.accounts().flatMap(a => a.mailboxes()).filter(a => a.name() !== "All Mail").map(a => a.unreadCount()).reduce((a,b) => a+b, 0)})(Application("Mail"))'

To open Mail on clicking the widget use

osascript -l JavaScript -e '(x => x.activate() && x.messageViewers().length == 0 && x.MessageViewer().make())(Application("Mail"))'
Jean-Tinland commented 3 years ago

I think this indeed should be handled with the custom user widgets system as everyone has a different email setup!