diff --git a/.config/mutt/account.com.gmail_nemoinho.muttrc b/.config/mutt/account.com.gmail_nemoinho.muttrc new file mode 100644 index 0000000..3362117 --- /dev/null +++ b/.config/mutt/account.com.gmail_nemoinho.muttrc @@ -0,0 +1,13 @@ +set realname = "Felix Nehrke" +set from = "nemoinho@gmail.com" + +set smtp_url = "smtp://nemoinho@gmail.com@smtp.gmail.com:587/" +set smtp_pass = `gmail-app-credentials pass nemoinho@gmail.com` + +set folder = ~/.local/state/offlineimap/nemoinho_gmail + +set header_cache = "$XDG_CACHE_HOME/mutt/com.gmail_nemoinho/cache/headers" +set message_cachedir = "$XDG_CACHE_HOME/mutt/com.gmail_nemoinho/cache/bodies" +set certificate_file = "$XDG_CACHE_HOME/mutt/com.gmail_nemoinho/certificates" + +source "$XDG_CONFIG_HOME/mutt/gmail.muttrc" diff --git a/.config/mutt/account.info.nehrke_felix.muttrc b/.config/mutt/account.info.nehrke_felix.muttrc new file mode 100644 index 0000000..df31f16 --- /dev/null +++ b/.config/mutt/account.info.nehrke_felix.muttrc @@ -0,0 +1,13 @@ +set realname = "Felix Nehrke" +set from = "felix@nehrke.info" + +set smtp_url = "smtp://felix@nehrke.info@smtp.gmail.com:587/" +set smtp_pass = `gmail-app-credentials pass felix@nehrke.info` + +set folder = ~/.local/state/offlineimap/felix_nehrke_info_gmail + +set header_cache = "$XDG_CACHE_HOME/mutt/info.nehrke_felix/cache/headers" +set message_cachedir = "$XDG_CACHE_HOME/mutt/info.nehrke_felix/cache/bodies" +set certificate_file = "$XDG_CACHE_HOME/mutt/info.nehrke_felix/certificates" + +source "$XDG_CONFIG_HOME/mutt/gmail.muttrc" diff --git a/.config/mutt/gmail.muttrc b/.config/mutt/gmail.muttrc new file mode 100644 index 0000000..ab3aa19 --- /dev/null +++ b/.config/mutt/gmail.muttrc @@ -0,0 +1,34 @@ +# Location of inbox +set spoolfile = "=INBOX" +set postponed = "=[Gmail]/Drafts" +set record = "=[Gmail]/Sent Mail" + +# In Gmail the trash works different... +unset trash + +mailboxes =INBOX \ + -label Drafts "=[Gmail]/Drafts" \ + -label Sent "=[Gmail]/Sent Mail" \ + -label Trash "=[Gmail]/Trash" \ + -label Spam "=[Gmail]/Spam" \ + -label Archive "=[Gmail]/All Mail" \ + +# Headers to show +ignore * +unignore date from to cc subject x-mailer resent-from reply-to +bind pager,index d noop +bind pager,index e noop + +macro index,pager d "=[Gmail]/Trash" "Move message to chosen folder" +macro pager d "=[Gmail]/Trash" "Move message to chosen folder" +macro index,pager e "" "Move message to chosen folder" +macro index,pager ga "=[Gmail]/All^V Mail" "Switch to Archive" +macro index,pager gd "=[Gmail]/Drafts" "Switch to Drafts" +macro index,pager gi "=INBOX" "Switch to Inbox" +macro index,pager gs "=[Gmail]/Sent^V Mail" "Switch to Sent Mail" +macro index,pager gS "=[Gmail]/Spam" "Switch to Spam" +macro index,pager gt "=[Gmail]/Trash" "Switch to Trash" +macro index,pager ml "?" "Move message to chosen folder" +macro index,pager mi "=INBOX" "Add to Inbox" +macro index,pager mr "O" "Mark as read" +macro index,pager mu "O" "Mark as read" diff --git a/.config/mutt/mailcap b/.config/mutt/mailcap new file mode 100644 index 0000000..e3dcdc9 --- /dev/null +++ b/.config/mutt/mailcap @@ -0,0 +1,7 @@ +text/html; lynx -force_html -dump %s; copiousoutput +application/pdf; evince %s +application/vnd.openxmlformats-officedocument.wordprocessingml.document; pandoc --from docx --to markdown %s; copiousoutput +application/vnd.oasis.opendocument.text; pandoc --from odt --to markdown %s; copiousoutput +image/png; feh --scale-down %s +image/jpeg; feh --scale-down %s +image/gif; feh --scale-down %s diff --git a/.config/mutt/muttrc b/.config/mutt/muttrc new file mode 100644 index 0000000..ea6a41c --- /dev/null +++ b/.config/mutt/muttrc @@ -0,0 +1,56 @@ +set allow_8bit +set smart_wrap +set reverse_name +set reverse_realname +#set sidebar_visible +set wait_key = no +set confirm_append = no +set editor = vim +set sort_aux = last-date-received +set mailcap_path = "$XDG_CONFIG_HOME/mutt/mailcap" + +auto_view text/plain text/html text/calendar application/ics +alternative_order text/plain text/html text/calendar application/ics + +bind index 0 first-entry +bind index G last-entry + +bind pager 0 top +bind pager G bottom +bind pager j next-line +bind pager k previous-line +bind pager previous-entry +bind pager next-entry +bind pager next-entry + +bind pager,index \ch sidebar-toggle-visible +bind pager,index \cj sidebar-next +bind pager,index \ck sidebar-prev +bind pager,index \co sidebar-open +bind pager,index c mail + +bind pager,index g noop # unbind g to be used with macros, e.g. gg +bind pager,index m noop # unbind M to be used with macros, e.g. mv + +macro index gg "" +macro index gr "" + +macro pager gg "" +macro pager gn "" +macro pager gp "" +macro pager gr "" +# Use urlscan instead to follow links instead of the builtin urlview +macro pager \cb 'urlscan -W' "Follow links with urlscan" + +macro index,pager mv "" "move message to chosen folder" + +# I prefer so see the IMAP folders instead of my mailboxes by default +macro index,pager y "?$folder" "show incoming mailboxes list" + +# Switch between accounts +macro index "source $XDG_CONFIG_HOME/mutt/account.info.nehrke_felix.muttrc=INBOX" +macro index "source $XDG_CONFIG_HOME/mutt/account.com.gmail_nemoinho.muttrc=INBOX" + +# Source my default account +source "$XDG_CONFIG_HOME/mutt/account.info.nehrke_felix.muttrc" +#source "$XDG_CONFIG_HOME/mutt/account.com.gmail_nemoinho.muttrc" diff --git a/.config/offlineimap/config b/.config/offlineimap/config new file mode 100644 index 0000000..3ba8457 --- /dev/null +++ b/.config/offlineimap/config @@ -0,0 +1,43 @@ +[general] +accounts = felix_nehrke_info_gmail,nemoinho_gmail +pythonfile = $XDG_CONFIG_HOME/offlineimap/utils.py + +[Account felix_nehrke_info_gmail] +localrepository = felix_nehrke_info_gmail-Local +remoterepository = felix_nehrke_info_gmail-Remote + +[Repository felix_nehrke_info_gmail-Local] +type = Maildir +localfolders = $XDG_STATE_HOME/offlineimap/felix_nehrke_info_gmail/ +sep = / + +[Repository felix_nehrke_info_gmail-Remote] +maxconnections = 2 +type = Gmail +remoteuser = felix@nehrke.info +remotepasseval = get_gmail_pass("felix@nehrke.info") +realdelete = no +# Necessary for SSL connections, if using offlineimap version > 6.5.4 +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +# Necessary to work around https://github.com/OfflineIMAP/offlineimap/issues/573 (versions 7.0.12, 7.2.1) +ssl_version = tls1_2 + +[Account nemoinho_gmail] +localrepository = nemoinho_gmail-Local +remoterepository = nemoinho_gmail-Remote + +[Repository nemoinho_gmail-Local] +type = Maildir +localfolders = $XDG_STATE_HOME/offlineimap/nemoinho_gmail/ +sep = / + +[Repository nemoinho_gmail-Remote] +maxconnections = 2 +type = Gmail +remoteuser = nemoinho@gmail.com +remotepasseval = get_gmail_pass("nemoinho@gmail.com") +realdelete = no +# Necessary for SSL connections, if using offlineimap version > 6.5.4 +sslcacertfile = /etc/ssl/certs/ca-certificates.crt +# Necessary to work around https://github.com/OfflineIMAP/offlineimap/issues/573 (versions 7.0.12, 7.2.1) +ssl_version = tls1_2 diff --git a/.config/offlineimap/utils.py b/.config/offlineimap/utils.py new file mode 100644 index 0000000..4b6ecb3 --- /dev/null +++ b/.config/offlineimap/utils.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python +from subprocess import check_output + +def get_gmail_pass(account): + return check_output("gmail-app-credentials pass " + account, shell=True).splitlines()[0] diff --git a/.gitignore b/.gitignore index 07780ce..311e63c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ README.* !README.adoc + +__pycache__ diff --git a/.local/bin/gmail-app-credentials b/.local/bin/gmail-app-credentials new file mode 100755 index 0000000..ee28487 --- /dev/null +++ b/.local/bin/gmail-app-credentials @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +type="$1" +account="$2" +jq_chain="." +vault_type="text" + +case "$type" in + pass) + jq_chain='select(.label == "gmail app-password") | .password' + ;; + user) + jq_chain='select(.label == "gmail app-password") | .login' + ;; + realname) + jq_chain='select(.label == "Real Name") | .password' + ;; + email) + vault_type="email" + jq_chain='select(.password != "") | .password' + ;; + smtp) + vault_type="email" + jq_chain='select(.password != "") | "smtp://" + .password + "@smtp.gmail.com:587/"' + ;; + *) + exit 1 + ;; +esac + +enpasscli \ + -vault ~/Documents/Enpass/Vaults/primary \ + -json \ + --type "$vault_type" \ + show "Google ($account)" \ + | jq -r '.[] | '"$jq_chain"