From: Samir Benmendil Date: Sat, 4 Jan 2014 02:25:56 +0000 (+0100) Subject: add mutt stuff X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/c3a03e540dae7adafed0124b1a83c63436b597d7 add mutt stuff --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dbfb78d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.log +*.pyc diff --git a/Makefile b/Makefile index 2db38d0..453ae77 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ APATH := $(realpath .) FILES := bin -DOTFILES := aliases bash* conky* flexget git* vim* weechat xbindkeysrc Xmodmap Xresources xprofile zsh* +DOTFILES := aliases bash* conky* flexget git* goobookrc msmtp* mutt offlineimap* vim* weechat xbindkeysrc Xmodmap Xresources xprofile zsh* CONFIGFILES := retroarch compton.conf mimeo.conf .PHONY: install $(FILES) $(DOTFILES) $(CONFIGFILES) diff --git a/bin/offlineimap_utils.py b/bin/offlineimap_utils.py new file mode 100644 index 0000000..3f21e66 --- /dev/null +++ b/bin/offlineimap_utils.py @@ -0,0 +1,41 @@ +import re + +mapping = { 'INBOX': 'inbox' + , '[Google Mail]/All Mail': 'all_mail' + , '[Google Mail]/Drafts': 'drafts' + , '[Google Mail]/Important': 'important' + , '[Google Mail]/Sent Mail': 'sent' + , '[Google Mail]/Spam': 'spam' + , '[Google Mail]/Starred': 'flagged' + , '[Google Mail]/Bin': 'bin' + } + +r_mapping = { val: key for key, val in mapping.items() } + +def transremote(foldername): + return mapping.get(foldername, foldername) + +def translocal(foldername): + return r_mapping.get(foldername, foldername) + +top = [ 'inbox' + , 'chakra' + , 'unimaas' + , 'clementine' + , 'youtube' + , 'hotmail' + ] + +bot = [ 'flagged' + , 'drafts' + , 'spam' + , 'bin' + ] + +def sort_key(d): + folder = d['foldername'] + if folder in top: + return top.index(folder) + elif folder in bot: + return 21 + bot.index(folder) + return 20 diff --git a/dwb/.gitignore b/dwb/.gitignore index 2f9578f..f65ac1a 100644 --- a/dwb/.gitignore +++ b/dwb/.gitignore @@ -6,3 +6,4 @@ default/history default/navigate.history default/search.history default/session +/mail/ diff --git a/dwb/keys b/dwb/keys index eb0d685..dbeb3df 100644 --- a/dwb/keys +++ b/dwb/keys @@ -1,4 +1,180 @@ [default] +save_search_field=gs +tab_new=ga +allow_session_cookie_tmp=CT +allow_cookie=CC +allow_session_cookie=CS +bookmark=M +buffers=gt +cancel_download=ad +sanitize= +clear_tab=gc +only=co +close_tab=d +entry_escape=Control c +entry_confirm=Control g +entry_history_back=Control k +entry_history_forward=Control j +entry_delete_letter=Control h +entry_delete_line=Control u +entry_delete_line_end=Control e +entry_delete_word=Control w +entry_delete_word_forward=Control e +entry_word_back=Control b +entry_word_forward=Control f +complete_bookmarks=Control B +complete_history=Control H +complete_path=Control p +complete_searchengines=Control S +complete_userscript=Control U +download=gd +download_set_execute=Control x +command_mode=: +tabdo= +execute_javascript= +eval= +execute_userscript=eu +find_backward_ic=c? +find_backward=? +find_forward_ic=c/ +find_forward=/ +find_next=n +find_previous=N +focus_input=gi +focus_next=K +focus_tab=T +focus_prev=J +win_hist_back=wh +tab_hist_back=th +history_back=H +win_hist_forward=wl +tab_hist_forward=tl +history_forward=L +insert_mode=i +show_keys=Sk +load_html= +load_html_tab= +lock_domain=xd +lock_uri=xu +tab_move_left=gl +tab_move_right=gr +tab_move=gm +normal_mode=Control n +open_editor=Control e +quickmark=b +tab_quickmark=B +win_quickmark=wb +start_page=Control h +web_inspector=wi +paste=pp +tab_paste=Pp +win_paste=wp +paste_primary=pP +win_paste_primary=wP +tab_paste_primary=PP +print=Control Mod1 p +protect=Control P +quit=Control q +reload_bookmarks= +reload=r +reload_bypass_cache=R +reload_quickmarks= +reload_userscripts= +save=sf +save_session=ZZ +save_named_session=gZZ +save_quickmark=m +scroll_down=j +scroll_right=l +scroll_left=h +scroll_page_down=Control f +scroll_page_up=Control b +scroll_halfpage_down=Control d +scroll_halfpage_up=Control u +scroll_bottom=G +scroll_top=gg +scroll_up=k +local_set= +set= +set_key=sk +set_local_setting=sl +set_setting=ss +show_settings=Ss +print_preview= +show_bookmarks=Sb +show_downloads=Sd +show_history=Sh +show_quickmarks=Sq +stop_loading=Control s +toggle_local_setting= +toggle_setting= +toggle_tab=Control @Tab@ +toggle_plugins_host_tmp=pth +toggle_scripts_host=tsh +toggle_scripts_host_tmp=tth +toggle_scripts_uri=tsu +toggle_plugins_uri_tmp=ptu +toggle_scripts_uri_tmp=ttu +fullscreen=@F11@ +toggle_hidden_files=g. +toggle_plugins_host=ph +toggle_plugins_uri=pu +presentation_mode=@F12@ +proxy=Control p +visible=xv +toggle_bars=xx +toggle_statusbar=xb +toggle_tabbar=xt +undo=u +view_source=gf +dump= +yank_title=yt +yank_title_primary=yT +yank=yy +yank_primary=yY +zoom== +zoom_in=+ +zoom_out=- +hints_background=;b +hints_images_background=.i +hints_url_background=.o +backopen_url=xO +backopen=xo +bookmarks=gb +hints=f +hints_clipboard=;y +hints_download=;d +hints_editable=;e +hints_images=;i +hints_links=;; +hints_primary=;Y +hints_rapid=;r +hints_url=;o +new_tab=V +new_win=W +open_url=go +open=o +hints_tab=F +hints_images_tab=;I +hints_url_tab=;O +tab_bookmarks=gB +tabopen_url=gO +tabopen=O +hints_win=wf +hints_rapid_win=;R +win_bookmarks=wB +winopen_url=wO +winopen=wo +adblock_reload_rules= +visual_mode=v +tabgrep= +repeat=. +entry_delete_active=Control d +jump=' +mark=` +hints_selector= + +[mail] save_search_field= gs tab_new= ga allow_session_cookie_tmp= CT diff --git a/dwb/settings b/dwb/settings index f063a59..693c69a 100644 --- a/dwb/settings +++ b/dwb/settings @@ -161,3 +161,165 @@ hint-offset-left=0 enable-ipc=true block-insecure-content=false adblocker-element-hider=true + +[mail] +load-on-focus=false +adblocker-filterlist=/home/ramsi/.config/dwb/adblock_lists +javascript-can-access-clipboard=false +hint-offset-top=0 +file-sync-interval=120 +download-gradient-end=#00aa00 +status-allowed-color=#00ff00 +tab-number-color=#7ac5cd +enable-default-context-menu=true +editable=false +background-tabs=false +enable-webgl=false +minimum-logical-font-size=5 +enable-page-cache=false +cache-model=webbrowser +sans-serif-font-family=sans-serif +prompt-color=#00ff00 +complete-searchengines=false +update-search-delay=200 +fantasy-font-family=serif +hint-fg-color=#000000 +sync-files=all +default-height=600 +javascript-api=automatic +scrollbars=false +hint-bg-color=#ffffff +show-single-tab=true +private-color=#505050 +enable-developer-extras=false +complete-bookmarks=true +zoom-level=1.00 +download-use-external-program=false +enable-xss-auditor=true +custom-encoding= +print-previewer= +normal-completion-fg-color=#eeeeee +close-tab-focus-policy=left +enable-dns-prefetching=true +new-tab-position-policy=right +mouse-cycles-through-tabs=true +auto-shrink-images=true +print-backgrounds=true +enable-caret-browsing=false +enable-scripts=true +proxy=false +user-agent= +full-content-zoom=false +tab-orientation=horizontal +editor=xterm -e vim dwb_uri +hsts=false +enable-private-browsing=false +enable-favicon=true +hint-active-color=#00ff00 +resizable-text-areas=true +javascript-schemes=true +adblocker-element-hider=true +download-gradient-start=#0000aa +hint-normal-color=#ffff99 +spell-checking-languages= +cookies-accept-policy=always +font-nofocus= +status-blocked-color=#ffffff +download-fg-color=#ffffff +enable-plugins=true +enable-frame-flattening=false +ssl-use-system-ca-file=true +cookies-store-policy=session +bars-padding=0 +active-completion-fg-color=#53868b +hint-font=bold 10px monospace +progress-bar-full-color=#ffffff +tabbed-browsing=true +hint-highlight-links=false +active-completion-bg-color=#000000 +enable-spell-checking=false +font-hidden-statusbar=normal 10px helvetica +tab-normal-fg-color-2=#dddddd +tab-normal-fg-color-1=#cccccc +default-monospace-font-size=10 +save-session=false +enable-ipc=true +tabbar-visible=2.00 +auto-insert-mode=false +tab-normal-bg-color-2=#707070 +tab-normal-bg-color-1=#505050 +serif-font-family=serif +accept-language= +enable-html5-local-storage=true +tab-protected-color=#ff0000 +hint-letter-seq=FDSARTGBVECWXQYIOPMNHZULKJ +progress-bar-style=default +maximum-tabs=0 +passthrough-keys=webkit +enable-html5-database=true +hint-autofollow=true +enable-dom-paste=false +javascript-can-open-windows-automatically=false +max-visible-completions=11 +hint-border=1px solid #000000 +widget-packing=dtws +ssl-trusted-color=#00ff00 +enable-java-applet=true +hints-key-lock=250 +navigation-history-max=500 +hint-style=letter +enable-site-specific-quirks=false +auto-resize-window=false +zoom-step=0.10 +default-font-family=sans-serif +ssl-untrusted-color=#ff0000 +plugin-blocker=true +startpage=dwb:bookmarks +normal-completion-bg-color=#151515 +cookie-expiration=0 +cursive-font-family=serif +default-encoding= +error-color=#ff0000 +searchengine-submit-pattern= +hint-opacity=0.80 +font-entry= +proxy-url= +font=monospace 8 +monospace-font-family=monospace +addressbar-dns-lookup=false +enable-universal-access-from-file-uris=true +background-color=#000000 +do-not-track=true +progress-bar-empty-color=#ffffff +default-width=800 +single-instance=true +auto-completion=false +minimum-font-size=5 +font-completion= +enable-spatial-navigation=false +block-insecure-content=false +download-directory= +adblocker=false +download-external-command=xterm -e wget dwb_uri -O dwb_output --load-cookies dwb_cookies +user-stylesheet-uri= +auto-load-images=true +tab-active-fg-color=#ffffff +tab-width=100 +hint-offset-left=0 +history-length=500 +tab-active-bg-color=#000000 +download-bg-color=#000000 +download-no-confirm=false +enable-file-access-from-file-uris=true +complete-history=true +close-last-tab-policy=ignore +tab-key-cycles-through-elements=true +enforce-96-dpi=false +ssl-strict=true +scroll-step=0.00 +complete-userscripts=false +foreground-color=#ffffff +message-delay=2 +scheme-handler= +default-font-size=12 +enable-offline-web-application-cache=true diff --git a/goobookrc b/goobookrc new file mode 100644 index 0000000..c99050b --- /dev/null +++ b/goobookrc @@ -0,0 +1,12 @@ +# "#" or ";" at the start of a line makes it a comment. +[DEFAULT] +# If not given here, email and password is taken from .netrc using +# machine google.com +;email: user@gmail.com +;password: top secret +# or if you want to get the password from a commmand: +;passwordeval: gpg --batch -d ~/.mutt/pw.gpg +# The following are optional, defaults are shown +cache_filename: ~/.cache/goobook_cache +;cache_expiry_hours: 24 +;filter_groupless_contacts: yes diff --git a/msmtp/msmtpq b/msmtp/msmtpq new file mode 100755 index 0000000..7a4850e --- /dev/null +++ b/msmtp/msmtpq @@ -0,0 +1,486 @@ +#!/usr/bin/env bash + +##-------------------------------------------------------------- +## +## msmtpq : queue funtions to both use & manage the msmtp queue, +## as it was defined by Martin Lambers +## Copyright (C) 2008, 2009, 2010, 2011 Chris Gianniotis +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or, at +## your option, any later version. +## +##-------------------------------------------------------------- + +## msmtpq is meant to be used by an email client - in 'sendmail' mode +## for this purpose, it is invoked directly as 'msmtpq' +## it is also meant to be used to maintain the msmtp queue +## evoked by the wrapper script 'msmtp-queue' +## (which calls this script as msmtpq --q-mgmt) + +## there is a queue log file, distinct from the msmtp log, +## for all events & operations on the msmtp queue +## that is defined below + +## (mutt users, using msmtpq in 'sendmail' mode, +## should make at least the following two settings in their .muttrc +## set sendmail = /path/to/msmtpq +## set sendmail_wait = -1 +## +## please see the msmtp man page and docs for further mutt settings +## and optimisations +## ) + +## msmtpq now uses the following environment variables : +## EMAIL_CONN_NOTEST if set will suppress any testing for a connection +## EMAIL_CONN_TEST if unset or =p will use a ping test (debian.org) for a connection +## if =P will use a fast ping test (8.8.8.8) for a connection +## if =n will use netcat (nc) to test for a connection +## if =s will use bash sockets to test for a connection +## EMAIL_QUEUE_QUIET if set will cause suppression of messages and 'chatter' + +## two essential patches by Philipp Hartwig +## 19 Oct 2011 & 27 Oct 2011 + +##-------------------------------------------------------------- +## the msmtp queue contains unique filenames of the following form : +## two files for each mail in the queue +## +## creates new unique filenames of the form : +## MLF: ccyy-mm-dd-hh.mm.ss[-x].mail -- mail file +## MSF: ccyy-mm-dd-hh.mm.ss[-x].msmtp -- msmtp command line file +## where x is a consecutive number only appended for uniqueness +## if more than one mail per second is sent +##-------------------------------------------------------------- + + +dsp() { local L ; for L ; do [ -n "$L" ] && echo " $L" || echo ; done ; } +err() { dsp '' "$@" '' ; exit 1 ; } + + +## ====================================================================================== +## !!! please define or confirm the following three vars !!! +## !!! before using the msmtpq or msmtp-queue scripts !!! +## ====================================================================================== +## +## only if necessary (in unusual circumstances - e.g. embedded systems), +## enter the location of the msmtp executable (no quotes !!) +## e.g. ( MSMTP=/path/to/msmtp ) +MSMTP=msmtp +#[ -x "$MSMTP" ] || \ +# log -e 1 "msmtpq : can't find the msmtp executable [ $MSMTP ]" # if not found - complain ; quit +## +## set the queue var to the location of the msmtp queue directory +## if the queue dir doesn't yet exist, better to create it (0700) +## before using this routine +## e.g. ( mkdir msmtp.queue ) +## ( chmod 0700 msmtp.queue ) +## +## the queue dir - modify this to reflect where you'd like it to be (no quotes !!) +Q=~/.msmtp/queue +[ -d "$Q" ] || \ + err '' "msmtpq : can't find msmtp queue directory [ $Q ]" '' # if not present - complain ; quit +## +## set the queue log file var to the location of the msmtp queue log file +## where it is or where you'd like it to be +## ( note that the LOG setting could be the same as the ) +## ( 'logfile' setting in .msmtprc - but there may be ) +## ( some advantage in keeping the two logs separate ) +## if you don't want the log at all unset (comment out) this var +## LOG=~/log/msmtp.queue.log --> #LOG=~/log/msmtp.queue.log +## (doing so would be inadvisable under most conditions, however) +## +## the queue log file - modify (or comment out) to taste (but no quotes !!) +LOG=~/.msmtp/queue.log +## ====================================================================================== + +umask 077 # set secure permissions on created directories and files + +declare -i CNT # a count of mail(s) currently in the queue +declare -a Q_LST # queue list array ; used selecting a mail (to send or remove) + +## do ; test this ! +#for sig in INT TERM EXIT; do +# trap "rm -f \"\$TMPFILE\"; [[ $sig == EXIT ]] || kill -$sig $$" $sig +#done +trap on_exit INT TERM EXIT # run 'on_exit' on exit +on_exit() { + [ -n "$LKD" ] && lock_queue -u 2>/dev/null # unlock the queue on exit if the lock was set here +} + +# +## ----------------------------------- common functions +# + +## make an entry to the queue log file, possibly an error +## (log queue changes only ; not interactive chatter) +## usage : log [ -e errcode ] msg [ msg ... ] +## opts : -e an error ; log msg & terminate w/prejudice +## display msg to user, as well +log() { + local ARG RC PFX="$('date' +'%Y %d %b %H:%M:%S')" + # time stamp prefix - "2008 13 Mar 03:59:45 " + if [ "$1" = '-e' ] ; then # there's an error exit code + RC="$2" # take it + shift 2 # shift opt & its arg off + fi + + [ -z "$EMAIL_QUEUE_QUIET" ] && dsp "$@" # display msg to user, as well as logging it + + if [ -n "$LOG" ] ; then # log is defined and in use + for ARG ; do # each msg line out + [ -n "$ARG" ] && \ + echo "$PFX : $ARG" >> "$LOG" # line has content ; send it to log + done + fi + + if [ -n "$RC" ] ; then # an error ; leave w/error return + [ -n "$LKD" ] && lock_queue -u # unlock here (if locked) + [ -n "$LOG" ] && \ + echo " exit code = $RC" >> "$LOG" # logging ok ; send exit code to log + exit $RC # exit w/return code + fi +} + +## write/remove queue lockfile for a queue op +lock_queue() { # <-- '-u' to remove lockfile + local LOK="${Q}/.lock" # lock file name + local -i MAX=240 SEC=0 # max seconds to gain a lock ; seconds waiting + + if [ -z "$1" ] ; then # lock queue + ## Philipp Hartwig patch #2 + 'mkdir' "$LOK" 2>/dev/null && LKD='t' + while [ -z "$LKD" ] && (( SEC < MAX )) ; do # lock file present + sleep 1 # wait a second + (( ++SEC )) # accumulate seconds + 'mkdir' "$LOK" 2>/dev/null && LKD='t' # make lockdir ; lock queue ; set flag + done # try again while locked for MAX secs + [ -z "$LKD" ] && \ + err '' "cannot use queue $Q : waited $MAX seconds for"\ + " lockdir [ $LOK ] to vanish ; giving up"\ + 'if you are certain that no other instance of this script'\ + " is running, then 'rmdir' the lock dir manually" '' # lock file still there, give up + + elif [ "$1" = '-u' ] ; then # unlock queue + 'rmdir' "$LOK" # remove the lock + unset LKD # unset flag + fi +} + +## test whether system is connected +## returns t/f (0/1) +connect_test() { + if [ -z "$EMAIL_CONN_TEST" ] || \ + [ "$EMAIL_CONN_TEST" = 'p' ] ; then # use ping test (default) + # verify net connection - ping ip address of debian.org + # would ping -qnc2 -w4 be better ? + # would ping -qnc1 -w10 or -w20 be better ? + ping -qnc1 -w4 debian.org >/dev/null 2>&1 || return 1 + elif [ "$EMAIL_CONN_TEST" = 'P' ] ; then # use quicker ping test + # I personally think that including a DNS lookup + # is a better connection test but some + # have found the above test too slow + ping -qnc1 -w4 8.8.8.8 >/dev/null 2>&1 || return 1 + elif [ "$EMAIL_CONN_TEST" = 'n' ] ; then # use netcat (nc) test + # must, of course, have netcat (nc) installed + which nc >/dev/null 2>&1 || \ + log -e 1 "msmtpq : can't find netcat executable [ nc ]" # if not found - complain ; quit + 'nc' -vz www.debian.org 80 || return 1 + elif [ "$EMAIL_CONN_TEST" = 's' ] ; then # use sh sockets test + # note that this does not work on debian systems + # where bash opened sockets are suppressed for security reasons + # this should be ok for single user systems (including embedded systems) + # test whether this is supported on your system before using + exec 3<>/dev/udp/debian.org/80 || return 1 # open socket on site ; use dns + exec 3<&- ; exec 3>&- # close socket + fi + return 0 +} + +# +## ----------------------------------- functions for queue management +## ----------------------------------- queue maintenance mode - (msmtp-queue) +# + +## show queue maintenance functions +usage() { # <-- error msg + dsp ''\ + 'usage : msmtp-queue functions' ''\ + ' msmtp-queue < op >'\ + ' ops : -r run (flush) mail queue - all mail in queue'\ + ' -R send selected individual mail(s) in queue'\ + ' -d display (list) queue contents (<-- default)'\ + ' -p purge individual mail(s) from queue'\ + ' -a purge all mail in queue'\ + ' -h this helpful blurt' ''\ + ' ( one op only ; any others ignored )' '' + [ -z "$1" ] && exit 0 || { dsp "$@" '' ; exit 1 ; } +} + +## get user [y/n] acknowledgement +ok() { + local R YN='Y/n' # default to yes + + [ "$1" = '-n' ] && \ + { YN='y/N' ; shift ; } # default to no ; change prompt ; shift off spec + + dsp "$@" + while true ; do + echo -n " ok [${YN}] ..: " + read R + case $R in + y|Y) return 0 ;; + n|N) return 1 ;; + '') [ "$YN" = 'Y/n' ] && return 0 || return 1 ;; + *) echo 'yYnN only please' ;; + esac + done +} + +## send a queued mail out via msmtp +send_queued_mail() { # <-- mail id + local FQP="${Q}/${1}" # fully qualified path name + local -i RC=0 # for msmtp exit code + + if [ -f "${FQP}.msmtp" ] ; then # corresponding .msmtp file found + [ -z "$EMAIL_CONN_NOTEST" ] && { # connection test + connect_test || \ + log "mail [ $2 ] [ $1 ] from queue ; couldn't be sent - host not connected" + } + + if $MSMTP $(< "${FQP}.msmtp") < "${FQP}.mail" ; then # this mail goes out the door + log "mail [ $2 ] [ $1 ] from queue ; send was successful ; purged from queue" # good news to user + 'rm' -f ${FQP}.* # nuke both queue mail files + ALT='t' # set queue changed flag + else # send was unsuccessful + RC=$? # take msmtp exit code + log "mail [ $2 ] [ $1 ] from queue ; send failed ; msmtp rc = $RC" # bad news ... + fi + return $RC # func returns exit code + else # corresponding MSF file not found + log "preparing to send .mail file [ $1 ] [ ${FQP}.mail ] but"\ + " corresponding .msmtp file [ ${FQP}.msmtp ] was not found in queue"\ + ' skipping this mail ; this is worth looking into' # give user the bad news + fi # (but allow continuation) +} + +## run (flush) queue +run_queue() { # <- 'sm' mode # run queue + local M LST="$('ls' $Q/*.mail 2>/dev/null)" # list of mails in queue + local -i NDX=0 + + if [ -n "$LST" ] ; then # something in queue + for M in $LST ; do # process all mails + ((NDX++)) + send_queued_mail "$(basename $M .mail)" "$NDX" # send mail - pass {id} only + done + else # queue is empty + [ -z "$1" ] && \ + dsp '' 'mail queue is empty (nothing to send)' '' + fi # inform user (if not running in sendmail mode) +} + +## display queue contents +display_queue() { # <-- { 'purge' | 'send' } (op label) ; { 'rec' } (record array of mail ids) + local M ID LST="$('ls' ${Q}/*.mail 2>/dev/null)" # list of mail ids in queue + + CNT=0 + if [ -n "$LST" ] ; then # list has contents (any mails in queue) + for M in $LST ; do # cycle through each + ID="$(basename $M .mail)" # take mail id from filename + ((CNT++)) + dsp '' "mail num=[ $CNT ] id=[ $ID ]" # show mail id ## patch in + 'egrep' -s --colour -h '(^From:|^To:|^Subject:)' "$M" # show mail info + [ -n "$2" ] && Q_LST[$CNT]="$ID" # bang mail id into array (note 1-based array indexing) + done + echo + else # no mails ; no contents + [ -z "$1" ] && \ + dsp '' 'no mail in queue' '' || \ + dsp '' "mail queue is empty (nothing to $1)" '' # inform user + exit 0 + fi +} + +## delete all mail in queue, after confirmation +purge_queue() { + display_queue 'purge' # show queue contents + if ok -n 'remove (purge) all mail from the queue' ; then + lock_queue # lock here + 'rm' -f "$Q"/*.* + log 'msmtp queue purged (all mail)' + lock_queue -u # unlock here + else + dsp '' 'nothing done ; queue is untouched' '' + fi +} + +## select a single mail from queue ; delete it or send it +## select by mail index (position in queue) or mail id +select_mail() { # <-- < 'purge' | 'send' > + local OK ID # mail id + local -i I NDX # mail index (position in queue) + + while true ; do # purge an individual mail from queue + display_queue "$1" 'rec' # show queue contents ; make mail ids array + + ## allow selection also by mail index + if [ $CNT -eq 1 ] ; then # only one mail in queue ; take its id + NDX=1 + ID="${Q_LST[1]}" + else # more than one mail ; select its id + while true ; do # get mail id + OK='t' # optimistic to a fault + dsp "enter mail number or id to $1" # <-- num or file name (only, no suff) + echo -n ' ( alone to exit ) ..: ' + read ID + [ -n "$ID" ] || return # entry made - or say good bye + + if [ "${ID:4:1}" != '-' ] ; then # mail id *not* entered ; test index num + for (( I=0 ; I<${#ID} ; I++ )) ; do # test index number + if [[ "${ID:${I}:1}" < '0' || \ + "${ID:${I}:1}" > '9' ]] ; then + dsp '' "[ $ID ] is neither a valid mail id"\ + 'nor a valid mail number' '' + unset OK + fi + done + [ -z "$OK" ] && continue # format not ok (not all nums) + + NDX=$ID + if [ $NDX -lt 1 ] || [ $NDX -gt $CNT ] ; then # test number range (1 - $CNT) + dsp '' "[ $NDX ] is out of range as a mail number"\ + "validity is from 1 to $CNT" + continue # try again + fi + + ID="${Q_LST[$NDX]}" # format & range were ok ; use it + break # valid mail selection + else # mail id entered + for (( NDX=1 ; NDX<=${#Q_LST[*]} ; NDX++ )) ; do # find entered id in queue list + [ "$ID" = "${Q_LST[$NDX]}" ] && break + done + [ $NDX -le ${#Q_LST[*]} ] && \ + break || \ + dsp '' "mail [ $ID ] not found ; invalid id" # mail selection valid (found) or + fi # fell through (not found) complain + done # and ask again + fi + + if ok '' "$1 :"\ + " mail num=[ $NDX ]"\ + " id=[ $ID ]" '' ; then # confirm mail op + if [ "$1" = 'purge' ] ; then # purging + lock_queue # lock here + 'rm' -f "$Q"/"$ID".* # msmtp - nukes single mail (both files) in queue + log "mail [ $ID ] purged from queue" # log op + lock_queue -u # unlock here + ALT='t' # mark that a queue alteration has taken place + else # sending + lock_queue # lock here + send_queued_mail "$ID" "$NDX" # send out the mail + lock_queue -u # unlock here + fi + else # user opts out + dsp '' 'nothing done to this queued email' # soothe user + [ $CNT -eq 1 ] && break # single mail ; user opted out + fi + dsp '' "--------------------------------------------------" + done + + if [ -n "$ALT" ] ; then # queue was changed + dsp '' 'done' '' + else # queue is untouched + dsp '' 'nothing done ; queue is untouched' '' + fi +} + +# +## ----------------------------------- functions for directly sending mail +## ----------------------------------- 'sendmail' mode - (msmtpq) +# + +## ('sendmail' mode only) +## make base filename id for queue +make_id() { + local -i INC # increment counter for (possible) base fqp name collision + + ID="$(date +%Y-%m-%d-%H.%M.%S)" # make filename id for queue (global + FQP="${Q}/$ID" # make fully qualified pathname vars) + ## Philipp Hartwig patch #1 + if [ -f "${FQP}.mail" -o -f "${FQP}.msmtp" ] ; then # ensure fqp name is unique + INC=1 # initial increment + while [ -f "${FQP}-${INC}.mail" -o -f "${FQP}-${INC}.msmtp" ] ; do # fqp name w/incr exists + (( ++INC )) # bump increment + done + ID="${ID}-${INC}" # unique ; set id + FQP="${FQP}-${INC}" # unique ; set fqp name + fi +} + +## ('sendmail' mode only) +## enqueue a mail +enqueue_mail() { # <-- all mail args ; mail text via TMP + if echo "$@" > "${FQP}.msmtp" ; then # write msmtp command line to queue .msmtp file + log "enqueued mail as : [ $ID ] ( $* ) : successful" # (queue .mail file is already there) + else # write failed ; bomb + log -e "$?" "queueing - writing msmtp cmd line { $* }"\ + " to [ ${ID}.msmtp ] : failed" + fi +} + +## ('sendmail' mode only) +## send a mail (if possible, otherwise enqueue it) +## if send is successful, msmtp will also log it (if enabled in ~/.msmtprc) +send_mail() { # <-- all mail args ; mail text via TMP + [ -z "$EMAIL_CONN_NOTEST" ] && { # connection test + connect_test || { + log "mail for [ $* ] : couldn't be sent - host not connected" + enqueue_mail "$@" # enqueue the mail + } + } + + if $MSMTP "$@" < "${FQP}.mail" > /dev/null ; then # send mail using queue .mail fil + log "mail for [ $* ] : send was successful" # log it + 'rm' -f ${FQP}.* # remove all queue mail files .mail & .msmtp file + run_queue 'sm' # run/flush any other mails in queue + else # send failed - the mail stays in the queue + log "mail for [ $* ] : send was unsuccessful ; msmtp exit code was $?"\ + "enqueued mail as : [ $ID ] ( $* )" # (queue .mail file is already there) + fi +} + +# +## -- entry point +# + +if [ ! "$1" = '--q-mgmt' ] ; then # msmtpq - sendmail mode + lock_queue # lock here + make_id # make base queue filename id for this mail + # write mail body text to queue .mail file + cat > "${FQP}.mail" || \ + log -e "$?" "creating mail body file [ ${FQP}.mail ] : failed" # test for error + # write msmtp command line to queue .msmtp file + echo "$@" > "${FQP}.msmtp" || \ + log -e "$?" "creating msmtp cmd line file { $* }"\ + " to [ ${ID}.msmtp ] : failed" # test for error + send_mail "$@" # send the mail if possible, queue it if not + lock_queue -u # unlock here +else # msmtp-queue - queue management mode + shift # trim off first (--q-mgmt) arg + OP=${1:1} # trim off first char of OP arg + case "$OP" in # sort ops ; run according to spec + r) lock_queue + run_queue + lock_queue -u ;; # run (flush) the queue + R) select_mail send ;; # send individual mail(s) in queue + d|'') display_queue ;; # display (list) all mail in queue (default) + p) select_mail purge ;; # purge individual mail(s) from queue + a) purge_queue ;; # purge all mail in queue + h) usage ;; # show help + *) usage "[ -$OP ] is an unknown msmtp-queue option" ;; + esac +fi + +exit 0 diff --git a/msmtprc b/msmtprc new file mode 100644 index 0000000..75b5d98 --- /dev/null +++ b/msmtprc @@ -0,0 +1,21 @@ +defaults +tls on +tls_trust_file /etc/ssl/certs/ca-certificates.crt +logfile ~/.msmtp/msmtp.log + +# gmail +account gmail +host smtp.gmail.com +port 587 +protocol smtp +auth on +from samir.benmendil@gmail.com +user samir.benmendil@gmail.com +password + +# unimaas inherits from gmail +account unimaas : gmail +from s.benmendil@student.maastrichtuniversity.nl + +#set default account +account default : gmail diff --git a/mutt/.gitignore b/mutt/.gitignore new file mode 100644 index 0000000..ff045f9 --- /dev/null +++ b/mutt/.gitignore @@ -0,0 +1 @@ +mailboxes diff --git a/mutt/accounts/chakra b/mutt/accounts/chakra new file mode 100644 index 0000000..f2d9607 --- /dev/null +++ b/mutt/accounts/chakra @@ -0,0 +1,4 @@ +# vim: ft=muttrc +set realname = "Ram-Z" +set from = "ram-z@chakra-project.org" +my_hdr Bcc: $from diff --git a/mutt/accounts/gmail b/mutt/accounts/gmail new file mode 100644 index 0000000..f5e0422 --- /dev/null +++ b/mutt/accounts/gmail @@ -0,0 +1,4 @@ +# vim: ft=muttrc +set realname = "Samir Benmendil" +set from = "samir.benmendil@gmail.com" +my_hdr Bcc: $from diff --git a/mutt/accounts/unimaas b/mutt/accounts/unimaas new file mode 100644 index 0000000..0c624db --- /dev/null +++ b/mutt/accounts/unimaas @@ -0,0 +1,4 @@ +# vim: ft=muttrc +set realname = "Samir Benmendil" +set from = "s.benmendil@student.maastrichtuniversity.nl" +my_hdr Bcc: $from diff --git a/mutt/bindings b/mutt/bindings new file mode 100644 index 0000000..f27ac96 --- /dev/null +++ b/mutt/bindings @@ -0,0 +1,28 @@ +# vim: ft=muttrc + +# moving around +bind pager J next-line +bind pager K previous-line +bind index,pager j next-undeleted +bind index,pager k previous-undeleted + +# completion +bind editor complete-query +bind editor ^T complete + +# sidebar +bind index,pager \CP sidebar-prev +bind index,pager \CN sidebar-next +bind index,pager \CO sidebar-open + +macro index b "toggle sidebar_visible" "Toggle sidebar" +macro pager b "toggle sidebar_visible" "Toggle sidebar" + +# Remap bounce-message function to “B” +bind index B bounce-message + +# open mailcap in attach view +bind attach view-mailcap + +# add sender to goobook +macro index,pager a "goobook add" "add the sender address to goobook" diff --git a/mutt/colors b/mutt/colors new file mode 100644 index 0000000..8865c7b --- /dev/null +++ b/mutt/colors @@ -0,0 +1,69 @@ +# vim: ft=muttrc +## Theme kindly inspired from +## https://github.com/pbrisbin/dotfiles/blob/master/host-teal/mutt/colors + +## Default color definitions +color normal white default + +color status green default +color indicator brightwhite blue +color tree blue default +color error brightred default +color message brightyellow default + +uncolor index * +# messages from me +color index cyan default ~P +# threads containing new messages +color index brightblue default "~(~N)" +# new messages + sidebar +color index brightyellow default "~N" +color sidebar_new brightyellow default +# threads containing old messages +color index blue default "~(~O)" +# old messages +color index yellow default "~O" +# tagged +color index brightgreen default "~T" +# deleted +color index brightred default "~D" + +uncolor header * +# set up the headers +color header brightyellow default "^from:" +color header yellow default "^to:" +color header yellow default "^cc:" +color header blue default "^date:" +color header brightblue default "^subject:" + +# message bodies +color attachment brightyellow default +color search red brightblack +color signature cyan default +color tilde green default + +uncolor body * +# gpg +color body brightgreen default "^gpg: Good signature.*" +color body brightred default "^gpg: BAD signature.*" +color body yellow default "^gpg: Can't check signature.*" +# urls +color body brightblue default "(^|<| )mailto:[^ ]+@[^ ]( |>|$)" +color body brightblue default "(^|<|\(| )(http|https|ftp|file|telnet|news|finger)://[^ ]+( |\)|>|$)" +# smileys, the right way and the backward-ass euro way +color body brightmagenta default "(^| )+(|[<>|])[8;:](|[^ ])[)(/|DOPS]( |$)+" +color body brightmagenta default "(^| )+[)(/|DOPS](|[^ ])[8;:](|[<>|])( |$)+" +# *bold*, _underline_, and /italic/ +color body brightcyan default "(^| )\\*[^*]+\\*( |$)" +color body brightcyan default "(^| )_[^_]+_( |$)" +color body brightcyan default "(^| )/[^/]+/( |$)" + +# quote blocks +color quoted magenta default +color quoted1 cyan default +color quoted2 green default +color quoted3 magenta default +color quoted4 cyan default +color quoted5 green default +color quoted6 magenta default +color quoted7 cyan default diff --git a/mutt/hooks b/mutt/hooks new file mode 100644 index 0000000..fa323c2 --- /dev/null +++ b/mutt/hooks @@ -0,0 +1,6 @@ +# vim: ft=muttrc +folder-hook . source ~/.mutt/accounts/gmail +folder-hook chakra source ~/.mutt/accounts/chakra +folder-hook unimaas source ~/.mutt/accounts/unimaas + +folder-hook * "exec collapse-all" diff --git a/mutt/mailcap b/mutt/mailcap new file mode 100644 index 0000000..fc569d9 --- /dev/null +++ b/mutt/mailcap @@ -0,0 +1,3 @@ +text/html; ~/.mutt/mutt_bgrun dwb -p mail --name dwb-mail %s; test=test -n "$DISPLAY"; +text/html; w3m -I %{charset} -T text/html; copiousoutput; +image/*; ~/.mutt/mutt_bgrun feh %s; diff --git a/mutt/mutt_bgrun b/mutt/mutt_bgrun new file mode 100755 index 0000000..793207b --- /dev/null +++ b/mutt/mutt_bgrun @@ -0,0 +1,114 @@ +#!/bin/sh +# @(#) mutt_bgrun $Revision: 1.4 $ + +# mutt_bgrun - run an attachment viewer from mutt in the background +# Copyright (C) 1999-2002 Gary A. Johnson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# SYNOPSIS +# mutt_bgrun viewer [viewer options] file +# +# DESCRIPTION +# Mutt invokes external attachment viewers by writing the +# attachment to a temporary file, executing the pipeline specified +# for that attachment type in the mailcap file, waiting for the +# pipeline to terminate, writing nulls over the temporary file, +# then deleting it. This causes problems when using graphical +# viewers such as qvpview and acroread to view attachments. +# +# If qvpview, for example, is executed in the foreground, the mutt +# user interface is hung until qvpview exits, so the user can't do +# anything else with mutt until he or she finishes reading the +# attachment and exits qvpview. This is especially annoying when +# a message contains several MS Office attachments--one would like +# to have them all open at once. +# +# If qvpview is executed in the background, it must be given +# enough time to completely read the file before returning control +# to mutt, since mutt will then obliterate the file. Qvpview is +# so slow that this time can exceed 20 seconds, and the bound is +# unknown. So this is again annoying. +# +# The solution provided here is to invoke the specified viewer +# from this script after first copying mutt's temporary file to +# another temporary file. This script can then quickly return +# control to mutt while the viewer can take as much time as it +# needs to read and render the attachment. +# +# EXAMPLE +# To use qvpview to view MS Office attachments from mutt, add the +# following lines to mutt's mailcap file. +# +# application/msword; mutt_bgrun qvpview %s +# application/vnd.ms-excel; mutt_bgrun qvpview %s +# application/vnd.ms-powerpoint; mutt_bgrun qvpview %s +# +# AUTHOR +# Gary A. Johnson +# +# +# ACKNOWLEDGEMENTS +# My thanks to the people who have commented on this script and +# offered solutions to shortcomings and bugs, especially Edmund +# GRIMLEY EVANS and Andreas Somogyi +# . + +prog=${0##*/} + +# Check the arguments first. + +if [ "$#" -lt "2" ] +then + echo "usage: $prog viewer [viewer options] file" >&2 + exit 1 +fi + +# Separate the arguments. Assume the first is the viewer, the last is +# the file, and all in between are options to the viewer. + +viewer="$1" +shift + +while [ "$#" -gt "1" ] +do + options="$options $1" + shift +done + +file=$1 + +# Create a temporary directory for our copy of the temporary file. +# +# This is more secure than creating a temporary file in an existing +# directory. + +tmpdir=/tmp/$LOGNAME$$ +umask 077 +mkdir "$tmpdir" || exit 1 +tmpfile="$tmpdir/${file##*/}" + +# Copy mutt's temporary file to our temporary directory so that we can +# let mutt overwrite and delete it when we exit. + +cp "$file" "$tmpfile" + +# Run the viewer in the background and delete the temporary files when done. + +( + "$viewer" $options "$tmpfile" >/dev/null 2>&1 + rm -f "$tmpfile" + rmdir "$tmpdir" +) & diff --git a/mutt/muttrc b/mutt/muttrc new file mode 100644 index 0000000..c08c9c9 --- /dev/null +++ b/mutt/muttrc @@ -0,0 +1,63 @@ +# general settings +alternates samir.benmendil@.* ram-z@.* s.benmendil@.* +set mail_check = 0 +set envelope_from +set forward_format = "Fwd: %s" +set forward_quote = yes + +set edit_headers +set askcc +set editor = vim + +# goobook +set query_command = "goobook query '%s'" + +unset move + +# sort/threading +set sort = threads +set sort_aux = last-date-received +set sort_re = yes +set duplicate_threads = yes +set collapse_unread = no + +# look and feel +set pager_index_lines = 12 +set pager_context = 5 +set pager_stop = yes # don't jump to next message +set menu_scroll = yes +set smart_wrap = yes # wrap at word boundaries +set tilde = yes # fills end of messages with tilde +set markers = no +set status_on_top = yes # also help on bottom +set index_format="%Z %{%b %d} %-15.15L (%?l?%4l&%4c?) %s" + +# sidebar +set sidebar_width = 12 +set sidebar_visible = yes +set sidebar_delim = '|' +set sidebar_sort = no +set sidebar_shortpath = yes +set sidebar_format = "%B%* %?N?%N?" + +# deal with crap +set mailcap_path = ~/.mutt/mailcap +auto_view text/html # view html automatically +alternative_order text/plain text/enriched text/html # save html for last + +# IMAP: offlineimap +set folder = "~/mail" # mail folder +set spoolfile = "+gmail/inbox" # set inbox +unset record # do not move sent msgs to a folder, gmail does that +set postponed = "+gmail/drafts" # drafts folder +set header_cache = "~/.cache/mutt" # cache headers for speedss +source ~/.mutt/mailboxes # source mailboxes generetated by offlineimap + +# SMTP: msmtp (with queue) +set sendmail = ~/.msmtp/msmtpq # use msmtp message queue +set sendmail_wait = -1 # fork sendmail to the background +set send_charset="us-ascii:utf-8" # only use ascii and utf8 + +source ~/.mutt/hooks +source ~/.mutt/bindings +source ~/.mutt/colors # color theme diff --git a/offlineimaprc b/offlineimaprc new file mode 100644 index 0000000..d2e893b --- /dev/null +++ b/offlineimaprc @@ -0,0 +1,675 @@ +# Offlineimap sample configuration file + +# This file documents *all* possible options and can be quite scary. +# Looking for a quick start? Take a look at offlineimap.conf.minimal. +# More details can be found in the included user documention, which is +# also available at: http://docs.offlineimap.org/en/latest/ + +# NOTE: Settings generally support python interpolation. This means +# values can contain python format strings which refer to other values +# in the same section, or values in a special DEFAULT section. This +# allows you for example to use common settings for multiple accounts: +# +# [Repository Gmail1] +# trashfolder: %(gmailtrashfolder)s +# +# [Repository Gmail2] +# trashfolder: %(gmailtrashfolder)s +# +# [DEFAULT] +# gmailtrashfolder = [Gmail]/Papierkorb +# +# would set the trashfolder setting for your German Gmail accounts. + +# NOTE2: This implies that any '%' needs to be encoded as '%%' + +################################################## +# General definitions +################################################## + +[general] + +# This specifies where offlineimap is to store its metadata. +# This directory will be created if it does not already exist. + +#metadata = ~/.offlineimap + +# This variable specifies which accounts are defined. Separate them +# with commas. Account names should be alphanumeric only. +# You will need to specify one section per account below. You may +# not use "general" for an account name. + +accounts = gmail + +# Offlineimap can synchronize more than one account at a time. If you +# want to enable this feature, set the below value to something +# greater than 1. To force it to synchronize only one account at a +# time, set it to 1. +# +# Note: if you are using autorefresh and have more than one account, +# you must set this number to be >= to the number of accounts you have; +# since any given sync run never "finishes" due to a timer, you will never +# sync your additional accounts if this is 1. + +maxsyncaccounts = 1 + +# You can specify one or more user interface modules for OfflineIMAP +# to use. OfflineIMAP will try the first in the list, and if it +# fails, the second, and so forth. +# +# The pre-defined options are: +# Blinkenlights -- A fancy (terminal) interface +# TTYUI -- a text-based (terminal) interface +# Basic -- Noninteractive interface suitable for cron'ing +# Quiet -- Noninteractive interface, generates no output +# except for errors. +# MachineUI -- Interactive interface suitable for machine +# parsing. +# +# You can override this with a command-line option -u. + +#ui = basic + +# If you try to synchronize messages to a folder which the IMAP server +# considers read-only, OfflineIMAP will generate a warning. If you want +# to suppress these warnings, set ignore-readonly to yes. Read-only +# IMAP folders allow reading but not modification, so if you try to +# change messages in the local copy of such a folder, the IMAP server +# will prevent OfflineIMAP from propagating those changes to the IMAP +# server. Note that ignore-readonly is unrelated to the "readonly" +# setting which prevents a repository from being modified at all. + +#ignore-readonly = no + +########## Advanced settings + +# You can give a Python source filename here and all config file +# python snippets will be evaluated in the context of that file. +# This allows you to e.g. define helper functions in the Python +# source file and call them from this config file. You can find +# an example of this in the manual. +# +pythonfile = ~/bin/offlineimap_utils.py + +# By default, OfflineIMAP will not exit due to a network error until +# the operating system returns an error code. Operating systems can sometimes +# take forever to notice this. Here you can activate a timeout on the +# socket. This timeout applies to individual socket reads and writes, +# not to an overall sync operation. You could perfectly well have a 30s +# timeout here and your sync still take minutes. +# +# Values in the 30-120 second range are reasonable. +# +# The default is to have no timeout beyond the OS. Times are given in seconds. +# +socktimeout = 120 + +# By default, OfflineIMAP will use fsync() to force data out to disk at +# opportune times to ensure consistency. This can, however, reduce +# performance. Users where /home is on SSD (Flash) may also wish to reduce +# write cycles. Therefore, you can disable OfflineIMAP's use of fsync(). +# Doing so will come at the expense of greater risk of message duplication +# in the event of a system crash or power loss. Default is fsync = true. +# Set fsync = false to disable fsync. +# +# fsync = true + +################################################## +# Mailbox name recorder +################################################## + +[mbnames] + +# offlineimap can record your mailbox names in a format you specify. +# You can define the header, each mailbox item, the separator, +# and the footer. Here is an example for Mutt. +# If enabled is yes, all six setting must be specified, even if they +# are just the empty string "". +# +# The header, peritem, sep, and footer are all Python expressions passed +# through eval, so you can (and must) use Python quoting. +# +# The following hash key are available to the expansion for 'peritem': +# - accountname: the name of the corresponding account; +# - foldername: the name of the folder; +# - localfolders: path to the local directory hosting all Maildir +# folders for the account. + +enabled = yes +filename = ~/.mutt/mailboxes +header = "mailboxes " +peritem = "+%(accountname)s/%(foldername)s" +sep = " " +footer = "\n" + +# You can also specify a folderfilter. It will apply to the +# *translated* folder name here, and it takes TWO arguments: +# accountname and foldername. In all other ways, it will +# behave identically to the folderfilter for accounts. Please see +# that section for more information and examples. +# +# Note that this filter can be used only to further restrict mbnames +# to a subset of folders that pass the account's folderfilter. +# +# +# You can customize the order in which mailbox names are listed in the +# generated file by specifying a sort_keyfunc, which takes a single +# dict argument containing keys 'accountname' and 'foldername'. This +# function will be called once for each mailbox, and should return a +# suitable sort key that defines this mailbox' position in the custom +# ordering. +# +# This is useful with e.g. Mutt-sidebar, which uses the mailbox order +# from the generated file when listing mailboxes in the sidebar. +# +# Default setting is +# sort_keyfunc = lambda d: (d['accountname'], d['foldername']) +sort_keyfunc = sort_key + + +################################################## +# Accounts +################################################## + +# This is an account definition clause. You'll have one of these +# for each account listed in general/accounts above. + +[Account gmail] +########## Basic settings + +# These settings specify the two folders that you will be syncing. +# You'll need to have a "Repository ..." section for each one. + +localrepository = gmail-local +remoterepository = gmail-remote + +########## Advanced settings + +# You can have offlineimap continue running indefinitely, automatically +# syncing your mail periodically. If you want that, specify how +# frequently to do that (in minutes) here. You can also specify +# fractional minutes (ie, 3.25). + +autorefresh = 1 + +# OfflineImap can replace a number of full updates by quick +# synchronizations. It only synchronizes a folder if 1) a Maildir +# folder has changed, or 2) if an IMAP folder has received new messages +# or had messages deleted, ie it does not update if only IMAP flags have +# changed. Full updates need to fetch ALL flags for all messages, so +# this makes quite a performance difference (especially if syncing +# between two IMAP servers). +# Specify 0 for never, -1 for always (works even in non-autorefresh +# mode), or a positive integer to do quick updates before doing +# another full synchronization (requires autorefresh). Updates are +# always performed after minutes, be they quick or full. + +quick = 10 + +# You can specify a pre and post sync hook to execute a external command. +# In this case a call to imapfilter to filter mail before the sync process +# starts and a custom shell script after the sync completes. +# The pre sync script has to complete before a sync to the account will +# start. + +# presynchook = imapfilter +# postsynchook = notifysync.sh + +# You can also specify parameters to the commands +# presynchook = imapfilter -c someotherconfig.lua + +# OfflineImap caches the state of the synchronisation to e.g. be able to +# determine if a mail has been deleted on one side or added on the +# other. +# +# The default and historical backend is 'plain' which writes out the +# state in plain text files. On Repositories with large numbers of +# mails, the performance might not be optimal, as we write out the +# complete file for each change. Another new backend 'sqlite' is +# available which stores the status in sqlite databases. +# +# If you switch the backend, you may want to delete the old cache +# directory in ~/.offlineimap/Account-/LocalStatus manually +# once you are sure that things work. +# +status_backend = sqlite + +# If you have a limited amount of bandwidth available you can exclude larger +# messages (e.g. those with large attachments etc). If you do this it +# will appear to offlineimap that these messages do not exist at all. They +# will not be copied, have flags changed etc. For this to work on an IMAP +# server the server must have server side search enabled. This works with Gmail +# and most imap servers (e.g. cyrus etc) +# The maximum size should be specified in bytes - e.g. 2000000 for approx 2MB + +# maxsize = 2000000 + + +# When you are starting to sync an already existing account you can tell +# offlineimap to sync messages from only the last x days. When you do +# this messages older than x days will be completely ignored. This can +# be useful for importing existing accounts when you do not want to +# download large amounts of archive email. +# +# Messages older than maxage days will not be synced, their flags will +# not be changed, they will not be deleted etc. For offlineimap it will +# be like these messages do not exist. This will perform an IMAP search +# in the case of IMAP or Gmail and therefore requires that the server +# support server side searching. This will calculate the earliest day +# that would be included in the search and include all messages from +# that day until today. e.g. maxage = 3 to sync only the last 3 days +# mail +# +# maxage = + + +# Maildir file format uses colon (:) separator between uniq name and info. +# Unfortunatelly colon is not allowed character in windows file name. If you +# enable maildir-windows-compatible option, offlineimap will be able to store +# messages on windows drive, but you will probably loose compatibility with +# other programs working with the maildir +# +#maildir-windows-compatible = no + + +[Repository gmail-local] + +# Each repository requires a "type" declaration. The types supported for +# local repositories are Maildir and IMAP. + +type = Maildir + +# Specify local repository. Your IMAP folders will be synchronized +# to maildirs created under this path. OfflineIMAP will create the +# maildirs for you as needed. + +localfolders = ~/mail/gmail + +# You can specify the "folder separator character" used for your Maildir +# folders. It is inserted in-between the components of the tree. If you +# want your folders to be nested directories, set it to "/". 'sep' is +# ignored for IMAP repositories, as it is queried automatically. +# +#sep = . + +# Some users may not want the atime (last access time) of folders to be +# modified by OfflineIMAP. If 'restoreatime' is set to yes, OfflineIMAP +# will restore the atime of the "new" and "cur" folders in each maildir +# folder to their original value after each sync. +# +# In nearly all cases, the default should be fine. +# +#restoreatime = no + +# function is defined in [general]pythonfile +nametrans = translocal + +[Repository gmail-remote] + +# A repository using Gmail's IMAP interface. Any configuration +# parameter of `IMAP` type repositories can be used here. Only +# `remoteuser` (or `remoteusereval` ) is mandatory. Default values +# for other parameters are OK, and you should not need fiddle with +# those. +# +# The Gmail repository will use hard-coded values for `remotehost`, +# `remoteport`, `tunnel` and `ssl`. (See +# http://mail.google.com/support/bin/answer.py?answer=78799&topic=12814) +# Any attempt to set those parameters will be silently ignored. + +type = Gmail + +# Specify the Gmail user name. This is the only mandatory parameter. +remoteuser = samir.benmendil@gmail.com + +# function is defined in [general]pythonfile +nametrans = transremote + +folderfilter = lambda foldername: foldername not in '[Google Mail]/All Mail' + +sslcacertfile = /etc/ssl/certs/ca-certificates.crt + +# The trash folder name may be different from [Gmail]/Trash +# for example on German Gmail, this setting should be +# +trashfolder = '[Google Mail]/Bin' + +# You should look for the localized names of the spam folder too: +# "spamfolder" tunable will help you to override the standard name. +spamfolder = '[Google Mail]/Spam' + +# OfflineIMAP can use multiple connections to the server in order +# to perform multiple synchronization actions simultaneously. +# This may place a higher burden on the server. In most cases, +# setting this value to 2 or 3 will speed up the sync, but in some +# cases, it may slow things down. The safe answer is 1. You should +# probably never set it to a value more than 5. + +maxconnections = 3 + +# OfflineIMAP normally closes IMAP server connections between refreshes if +# the global option autorefresh is specified. If you wish it to keep the +# connection open, set this to true. If not specified, the default is +# false. Keeping the connection open means a faster sync start the +# next time and may use fewer server resources on connection, but uses +# more server memory. This setting has no effect if autorefresh is not set. +# +holdconnectionopen = yes + +# If you want to have "keepalives" sent while waiting between syncs, +# specify the amount of time IN SECONDS between keepalives here. Note that +# sometimes more than this amount of time might pass, so don't make it +# tight. This setting has no effect if autorefresh and holdconnectionopen +# are not both set. +# +keepalive = 60 + +# Enable 1-way synchronization. See above for explanation. +# +#readonly = False + +[Repository RemoteExample] +# And this is the remote repository. We only support IMAP or Gmail here. + +type = IMAP + +# The following can fetch the account credentials via a python expression that +# is parsed from the pythonfile parameter. For example, a function called +# "getcredentials" that parses a file "filename" and returns the account +# details for "hostname". +# remotehosteval = getcredentials("filename", "hostname", "hostname") +# remoteporteval = getcredentials("filename", "hostname", "port") +# remoteusereval = getcredentials("filename", "hostname", "user") +# remotepasseval = getcredentials("filename", "hostname", "passwd") + +# Specify the remote hostname. +remotehost = examplehost + +# Whether or not to use SSL. +ssl = yes + +# SSL Client certificate (optional) +# sslclientcert = /path/to/file.crt + +# SSL Client key (optional) +# sslclientkey = /path/to/file.key + +# SSL CA Cert(s) to verify the server cert against (optional). +# No SSL verification is done without this option. If it is +# specified, the CA Cert(s) need to verify the Server cert AND +# match the hostname (* wildcard allowed on the left hand side) +# The certificate should be in PEM format. +# sslcacertfile = /path/to/cacertfile.crt + +# If you connect via SSL/TLS (ssl=true) and you have no CA certificate +# specified, offlineimap will refuse to sync as it connects to a server +# with an unknown "fingerprint". If you are sure you connect to the +# correct server, you can then configure the presented server +# fingerprint here. OfflineImap will verify that the server fingerprint +# has not changed on each connect and refuse to connect otherwise. +# You can also configure this in addition to CA certificate validation +# above and it will check both ways. + +#cert_fingerprint = + +# SSL version (optional) +# It is best to leave this unset, in which case the correct version will be +# automatically detected. In rare cases, it may be necessary to specify a +# particular version from: tls1, ssl2, ssl3, ssl23 (SSLv2 or SSLv3) + +# ssl_version = ssl23 + +# Specify the port. If not specified, use a default port. +# remoteport = 993 + +# Specify the remote user name. +remoteuser = username + +# Specify the user to be authorized as. Sometimes we want to +# authenticate with our login/password, but tell the server that we +# really want to be treated as some other user; perhaps server will +# allow us to do that (or, may be, not). Some IMAP servers migrate +# account names using this functionality: your credentials remain +# intact, but remote identity changes. +# +# Currently this variable is used only for SASL PLAIN authentication +# mechanism, so consider using auth_mechanisms to prioritize PLAIN +# or even make it the only mechanism to be tried. +# +# remote_identity = authzuser + +# Specify which authentication/authorization mechanisms we should try +# and the order in which OfflineIMAP will try them. NOTE: any given +# mechanism will be tried only if it is supported by the remote IMAP +# server. +# +# Due to the technical limitations, if you're specifying GSSAPI +# as the mechanism to try, it will be tried first, no matter where +# it was specified in the list. +# +# Default value is +# auth_mechanisms = GSSAPI, CRAM-MD5, PLAIN, LOGIN +# ranged is from strongest to more weak ones. + +########## Passwords + +# There are six ways to specify the password for the IMAP server: +# +# 1. No password at all specified in the config file. +# If a matching entry is found in ~/.netrc (see netrc (5) for +# information) this password will be used. Do note that netrc only +# allows one entry per hostname. If there is no ~/.netrc file but +# there is an /etc/netrc file, the password will instead be taken +# from there. Otherwise you will be prompted for the password when +# OfflineIMAP starts when using a UI that supports this. +# +# 2. The remote password stored in this file with the remotepass +# option. Any '%' needs to be encoded as '%%'. Example: +# remotepass = mypassword +# +# 3. The remote password stored as a single line in an external +# file, which is referenced by the remotefile option. Example: +# remotepassfile = ~/Password.IMAP.Account1 +# +# 4. With a preauth tunnel. With this method, you invoke an external +# program that is guaranteed *NOT* to ask for a password, but rather +# to read from stdin and write to stdout an IMAP procotol stream that +# begins life in the PREAUTH state. When you use a tunnel, you do +# NOT specify a user or password (if you do, they'll be ignored.) +# Instead, you specify a preauthtunnel, as this example illustrates +# for Courier IMAP on Debian: +# preauthtunnel = ssh -q imaphost '/usr/bin/imapd ./Maildir' +# +# 5. If you are using Kerberos and have the Python Kerberos package +# installed, you should not specify a remotepass. If the user has a +# valid Kerberos TGT, OfflineIMAP will figure out the rest all by +# itself, and fall back to password authentication if needed. +# +# 6. Using arbitrary python code. With this method, you invoke a +# function from your pythonfile. To use this method assign the name +# of the function to the variable 'remotepasseval'. Example: +# remotepasseval = get_password("imap.example.net") +# You can also query for the username: +# remoteusereval = get_username("imap.example.net") +# This method can be used to design more elaborate setups, e.g. by +# querying the gnome-keyring via its python bindings. + +########## Advanced settings + +# Tunnels. There are two types: +# +# - preauth: they teleport your connection to the remote system +# and you don't need to authenticate yourself there; the sole +# fact that you succeeded to get the tunnel running is enough. +# This tunnel type was explained above in the 'Passwords' section. +# +# - transport: the just provide the transport (probably encrypted) +# to the IMAP server, but you still need to authenticate at the +# IMAP server. +# +# Tunnels are currently working only with IMAP servers and their +# derivatives (currently, GMail). Additionally, for GMail accounts +# preauth tunnel settings are ignored: we don't believe that there +# are ways to preauthenticate at Google mail system IMAP servers. +# +# You must choose at most one tunnel type, be wise M'Lord. +# +# preauthtunnel = ssh -q imaphost '/usr/bin/imapd ./Maildir' +# transporttunnel = openssl s_client -host myimap -port 993 -quiet + +# Some IMAP servers need a "reference" which often refers to the "folder +# root". This is most commonly needed with UW IMAP, where you might +# need to specify the directory in which your mail is stored. The +# 'reference' value will be prefixed to all folder paths refering to +# that repository. E.g. accessing folder 'INBOX' with reference = Mail +# will try to access Mail/INBOX. Note that the nametrans and +# folderfilter functions will still apply the full path including the +# reference prefix. Most users will not need this. +# +# reference = Mail + +# In between synchronisations, OfflineIMAP can monitor mailboxes for new +# messages using the IDLE command. If you want to enable this, specify here +# the folders you wish to monitor. Note that the IMAP protocol requires a +# separate connection for each folder monitored in this way, so setting +# this option will force settings for: +# maxconnections - to be at least the number of folders you give +# holdconnectionopen - to be true +# keepalive - to be 29 minutes unless you specify otherwise +# +# This feature isn't complete and may well have problems. See the manual +# for more details. +# +# This option should return a Python list. For example +# +# idlefolders = ['INBOX', 'INBOX.Alerts'] +# + +# OfflineIMAP can use multiple connections to the server in order +# to perform multiple synchronization actions simultaneously. +# This may place a higher burden on the server. In most cases, +# setting this value to 2 or 3 will speed up the sync, but in some +# cases, it may slow things down. The safe answer is 1. You should +# probably never set it to a value more than 5. + +#maxconnections = 2 + +# OfflineIMAP normally closes IMAP server connections between refreshes if +# the global option autorefresh is specified. If you wish it to keep the +# connection open, set this to true. If not specified, the default is +# false. Keeping the connection open means a faster sync start the +# next time and may use fewer server resources on connection, but uses +# more server memory. This setting has no effect if autorefresh is not set. +# +#holdconnectionopen = no + +# If you want to have "keepalives" sent while waiting between syncs, +# specify the amount of time IN SECONDS between keepalives here. Note that +# sometimes more than this amount of time might pass, so don't make it +# tight. This setting has no effect if autorefresh and holdconnectionopen +# are not both set. +# +# keepalive = 60 + +# Normally, OfflineIMAP will expunge deleted messages from the server. +# You can disable that if you wish. This means that OfflineIMAP will +# mark them deleted on the server, but not actually delete them. +# You must use some other IMAP client to delete them if you use this +# setting; otherwise, the messages will just pile up there forever. +# Therefore, this setting is definitely NOT recommended. +# +#expunge = no + +# Specify whether to process all mail folders on the server, or only +# those listed as "subscribed". +# +#subscribedonly = no + +# You can specify a folder translator. This must be a eval-able +# Python expression that takes a foldername arg and returns the new +# value. I suggest a lambda. This example below will remove "INBOX." from +# the leading edge of folders (great for Courier IMAP users) +# +# See the user documentation for details and use cases. They are also +# online at: +# http://docs.offlineimap.org/en/latest/nametrans.html +# +# WARNING: you MUST construct this such that it NEVER returns +# the same value for two folders, UNLESS the second values are +# filtered out by folderfilter below. Failure to follow this rule +# will result in undefined behavior +# +# nametrans = lambda foldername: re.sub('^INBOX\.', '', foldername) + +# Using Courier remotely and want to duplicate its mailbox naming +# locally? Try this: +# +# nametrans = lambda foldername: re.sub('^INBOX\.*', '.', foldername) + +# You can specify which folders to sync using the folderfilter +# setting. You can provide any python function (e.g. a lambda function) +# which will be invoked for each foldername. If the filter function +# returns True, the folder will be synced, if it returns False, it. The +# folderfilter operates on the *UNTRANSLATED* name (before any nametrans +# translation takes place). +# +# Example 1: synchronizing only INBOX and Sent. +# +# folderfilter = lambda foldername: foldername in ['INBOX', 'Sent'] +# +# Example 2: synchronizing everything except Trash. +# +# folderfilter = lambda foldername: foldername not in ['Trash'] +# +# Example 3: Using a regular expression to exclude Trash and all folders +# containing the characters "Del". +# +# folderfilter = lambda foldername: not re.search('(^Trash$|Del)', foldername) +# +# If folderfilter is not specified, ALL remote folders will be +# synchronized. +# +# You can span multiple lines by indenting the others. (Use backslashes +# at the end when required by Python syntax) For instance: +# +# folderfilter = lambda foldername: foldername in +# ['INBOX', 'Sent Mail', 'Deleted Items', +# 'Received'] + + + +# You can specify folderincludes to include additional folders. It +# should return a Python list. This might be used to include a folder +# that was excluded by your folderfilter rule, to include a folder that +# your server does not specify with its LIST option, or to include a +# folder that is outside your basic reference. The 'reference' value +# will not be prefixed to this folder name, even if you have specified +# one. For example: +# folderincludes = ['debian.user', 'debian.personal'] + + +# If you do not want to have any folders created on this repository, +# set the createfolders variable to False, the default is True. Using +# this feature you can e.g. disable the propagation of new folders to +# the new repository. +#createfolders = True + + +# You can specify 'foldersort' to determine how folders are sorted. +# This affects order of synchronization and mbnames. The expression +# should return -1, 0, or 1, as the default Python cmp() does. The two +# arguments, x and y, are strings representing the names of the folders +# to be sorted. The sorting is applied *AFTER* nametrans, if any. The +# default is to sort IMAP folders alphabetically +# (case-insensitive). Usually, you should never have to modify this. To +# eg. reverse the sort: +# +# foldersort = lambda x, y: -cmp(x, y) + +# Enable 1-way synchronization. When setting 'readonly' to True, this +# repository will not be modified during synchronization. Use to +# e.g. backup an IMAP server. The readonly setting can be applied to any +# type of Repository (Maildir, Imap, etc). +# +#readonly = False + diff --git a/zshrc b/zshrc index 6fe91a6..aa3508e 100644 --- a/zshrc +++ b/zshrc @@ -42,6 +42,7 @@ done # vim stuff export EDITOR=vim export VISUAL=vim +export BROWSER=dwb # set up a few named directories hash -d Skaro=/mnt/Skaro