From b29570327bb91eec20a9408395dd4ff5ba31be81 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 24 Sep 2020 21:07:46 +0200 Subject: [PATCH] polybar: Add simple mail display script module The module will pick up the current state of the systemd mbsync.timer and display an according icon (sleepy bell if auto-sync is off, mail icon if auto-sync is on). It will use notmuch counters to show only unread mails in the inbox, which generally constitute the 'new' mails one wants to know about. It will not display anything if it did not find 'new' mails. Lastly, right-clicking allows starting the auto-sync timer and left clicking allows to stop it. FIXME: The icon will only update on the next update interval of the module itself (which is set at 300 seconds). That means, after clicking the icon to start or stop the auto-sync, the actual state will not be reflected by the icon for a couple of minutes. --- polybar/.config/polybar/config | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config index 28070ae..2a3fd8e 100644 --- a/polybar/.config/polybar/config +++ b/polybar/.config/polybar/config @@ -59,7 +59,7 @@ module-margin-left = 2 modules-left = workspaces sxhkdmode pomo modules-center = music date papersdue -modules-right = networkspeed weather archupdates cpu temp backlight volume battery +modules-right = networkspeed mail weather archupdates cpu temp backlight volume battery ; do not use offsets for the bar, would only work with override-redirect ; and will mess up tray https://github.com/polybar/polybar/issues/1355 tray-position = right @@ -250,6 +250,15 @@ format-prefix = " " interval = 120 format-underline = ${colors.primary} +[module/mail] +type = custom/script +exec = echo "$( [ $(systemctl --user --property=ActiveState show mbsync.timer) = 'ActiveState=active' ] && echo "" || echo "" ) $(notmuch count tag:inbox and tag:unread)" +exec-if = [ "$(notmuch count tag:inbox and tag:unread)" -gt 0 ] +click-right = systemctl --user start mbsync.timer +click-left = systemctl --user stop mbsync.timer +interval = 300.0 +format-underline = ${colors.primary} + [module/weather] type = custom/script exec = $XDG_CONFIG_HOME/polybar/scripts/poly-weather '?format=%t+%C+(%p)'