Skip to content
Lucas Hoffmann edited this page Jul 8, 2020 · 1 revision

Passwords

I use pass to store my passwords, just like pazz. Check out his setup for more info

Fetching Mail (fetchmail)

I use fetchmail to pull all my mail. Fetchmail can do POP3 and IMAP but I mostly use POP3.

Because fetchmail can only store passwords in plain text in config file I encrypt the whole config file with gpg and only temporarily decrypt it when starting fetchmail. This is all wrapped in a systemd unit under ~/.config/systemd/user/fetchmail.service. When starting that service I have to unlock my gpg key once.

[Unit]
Description=Fetchmail Daemon

[Service]

# The "static" configiguration is ~/.config/fetchmail/fetchmailrc.gpg.
# Because fetchmail can accept its configuration from stdin, the decrypted
# file never needs to be stored on disk.

ExecStart=/bin/bash -c 'exec fetchmail --daemon 60 --nodetach --nosyslog --fetchmailrc - < <(gpg -v --decrypt --yes %h/.config/fetchmail/fetchmailrc.gpg)'

ExecStop=/usr/bin/fetchmail --quit

Environment=FETCHMAILHOME=%h/.config/fetchmail
Environment=NOTMUCH_CONFIG=%h/.config/notmuch/config
Environment=GNUPGHOME=%h/.config/gpg

# In case the gpg key is not available in the agent just retry later.
Restart=always
RestartSec=10

SyslogIdentifier=fetchmail

[Install]
WantedBy=default.target

The decrypted fetchmailrc file looks something like this:

defaults
protocol pop3
authenticate password
ssl
sslproto TLS1
sslcertck
fetchall
mda "notmuch insert --keep --create-folder --folder=inbox +unread"
poll pop.googlemail.com               username foo           password foobarbaz
poll pop.googlemail.com               username bar           password foobarbaz
poll posteo.de          protocol imap username foo@posteo.de password foobarbaz

I enabled this systemd service with systemctl --user enable fetchmail.service so it starts on boot and then fetches new mail in the background. The tagging script will then display a notification on my desktop (see below) if new mail arrives.

Tagging

I use afew and a custom shell script as my post insert hook in notmuch. The script first does all the tagging and then calls out to my window manager's bar to update the mail widget and also send a notification to the desktop:

#!/bin/sh
# remember the new incoming message
messages=$(notmuch search --output=messages -- tag:new)
# tag new mail
afew --new --tag
# check if X.org is running
[ -n "$DISPLAY" ] || exit
# update the widget in the bar
awesome-client 'require("widgets/notmuch"):update()'
# send notification only if new mail arrived in the inbox
if [ $(notmuch count $messages is:inbox) -ne 0 ]; then
  awesome-client 'require("widgets/notmuch"):notify()'
fi

Sending Mail (msmtp)

Like pazz's setup.

Awesome WM widget with notifications

I wrote an awesome widget to display in my bar at the top of the screen. It is updated from the notmuch post-insert hook and can also display notifications for new mail. It starts alot if I right click it and it vanishes if no new mail is present.

The full code is available from my awesome config repository.