dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | Submodules | README | LICENSE

adamsgaard.lua (5544B)


      1 -- see `man imapfilter_config` for info
      2 
      3 -- function to strip trailing newlines piped from ~/.mutt/offlineimap.py
      4 function trim(s)
      5     return (s:gsub("^%s*(.-)%s*$", "%1"))
      6 end
      7 
      8 
      9 --------------
     10 -- Accounts --
     11 --------------
     12 
     13 status, pass = pipe_from("python ~/.mutt/offlineimap-password-store.py anders@adamsgaard.dk-imap")
     14 account = IMAP {
     15     server = 'imap.fastmail.com',
     16     username = 'anders@adamsgaard.dk',
     17     password = trim(pass),
     18     ssl = 'ssl23'
     19 }
     20 
     21 -- Get a list of the available mailboxes and folders
     22 --mailboxes, folders = account:list_all()
     23 
     24 -- Get a list of the subscribed mailboxes and folders
     25 --mailboxes, folders = account:list_subscribed()
     26 
     27 
     28 -------------------
     29 -- Mailbox rules --
     30 -------------------
     31 
     32 -- Get the status of a mailbox
     33 --account.INBOX:check_status()
     34 
     35 -- Get all the messages in the mailbox
     36 --results = account.INBOX:select_all()
     37 
     38 -- Get newly arrived, unread messages
     39 --results = account.INBOX:is_new()
     40 
     41 --------------------
     42 -- Spam filtering --
     43 --------------------
     44 --all = account.INBOX:select_all()
     45 all = account.INBOX:is_new()
     46 spam = Set {}
     47 unsure = Set {}
     48 for _, msg in ipairs(all) do
     49     mbox, uid = unpack(msg)
     50     text = mbox[uid]:fetch_message()
     51     flag = pipe_to('bogofilter', text)
     52     if (flag == 0) then
     53         table.insert(spam, msg)
     54     elseif (flag == 2) then
     55         table.insert(unsure, msg)
     56     end
     57 end
     58 --account:create_mailbox('Spam/unsure')
     59 spam:move_messages(account['Spam'])
     60 --unsure:copy_messages(account['Junk/unsure'])
     61 unsure:move_messages(account['Spam/unsure'])
     62 
     63 
     64 -- Debian announcements list --
     65 addr = 'debian-announce@lists.debian.org'
     66 mailbox = 'maillists/debian/debian-announce'
     67 --account:create_mailbox(mailbox)
     68 --account:subscribe_mailbox(mailbox)
     69 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
     70 results:move_messages(account[mailbox])
     71 
     72 -- Debian laptop list --
     73 addr = 'debian-laptop@lists.debian.org'
     74 mailbox = 'maillists/debian/debian-laptop'
     75 --account:create_mailbox(mailbox)
     76 --account:subscribe_mailbox(mailbox)
     77 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
     78 results:move_messages(account[mailbox])
     79 
     80 -- Debian news list --
     81 addr = 'debian-news@lists.debian.org'
     82 mailbox = 'maillists/debian/debian-news'
     83 --account:create_mailbox(mailbox)
     84 --account:subscribe_mailbox(mailbox)
     85 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
     86 results:move_messages(account[mailbox])
     87 
     88 -- Debian photo list --
     89 addr = 'debian-photo@lists.debian.org'
     90 mailbox = 'maillists/debian/debian-photo'
     91 --account:create_mailbox(mailbox)
     92 --account:subscribe_mailbox(mailbox)
     93 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
     94 results:move_messages(account[mailbox])
     95 
     96 -- Debian security list --
     97 addr = 'debian-security-announce@lists.debian.org'
     98 mailbox = 'maillists/debian/debian-security-announce'
     99 --account:create_mailbox(mailbox)
    100 --account:subscribe_mailbox(mailbox)
    101 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    102 results:move_messages(account[mailbox])
    103 
    104 -- Debian security list --
    105 addr = 'debian-security@lists.debian.org'
    106 mailbox = 'maillists/debian/debian-security'
    107 ----account:create_mailbox(mailbox)
    108 --account:subscribe_mailbox(mailbox)
    109 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    110 results:move_messages(account[mailbox])
    111 
    112 -- Debian danish list --
    113 addr = 'debian-user-danish@lists.debian.org'
    114 mailbox = 'maillists/debian/debian-user-danish'
    115 --account:create_mailbox(mailbox)
    116 --account:subscribe_mailbox(mailbox)
    117 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    118 results:move_messages(account[mailbox])
    119 
    120 -- Debian security announcements list --
    121 addr = 'debian-security-announce@lists.debian.org'
    122 mailbox = 'maillists/debian/debian-security'
    123 --account:create_mailbox(mailbox)
    124 --account:subscribe_mailbox(mailbox)
    125 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    126 results:move_messages(account[mailbox])
    127 
    128 -- Debian testing security announcements list --
    129 addr = 'debian-testing-security-announce@lists.debian.org'
    130 mailbox = 'maillists/debian/debian-security'
    131 ----account:create_mailbox(mailbox)
    132 --account:subscribe_mailbox(mailbox)
    133 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    134 results:move_messages(account[mailbox])
    135 
    136 -- Debian science list --
    137 addr = 'debian-science@lists.debian.org'
    138 mailbox = 'maillists/debian/debian-science'
    139 --account:create_mailbox(mailbox)
    140 --account:subscribe_mailbox(mailbox)
    141 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    142 results:move_messages(account[mailbox])
    143 
    144 -- VTK users list --
    145 addr = 'vtkusers@vtk.org'
    146 mailbox = 'maillists/vtk-users'
    147 --account:create_mailbox(mailbox)
    148 --account:subscribe_mailbox(mailbox)
    149 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    150 results:move_messages(account[mailbox])
    151 
    152 -- Paraview list
    153 addr = 'paraview@paraview.org'
    154 mailbox = 'maillists/vtk-users'
    155 --account:create_mailbox(mailbox)
    156 --account:subscribe_mailbox(mailbox)
    157 results = account.INBOX:contain_to(addr) + account.INBOX:contain_cc(addr)
    158 results:move_messages(account[mailbox])
    159 
    160 
    161 -- Delete old DMI byvejr alerts --
    162 results = account.INBOX:contain_subject('Byvejr: ') * account.INBOX:is_older(1)
    163 results:delete_messages()
    164 
    165 -- Scholar alerts --
    166 -- results = account.INBOX:contain_from('scholaralerts-noreply@google.com')
    167 -- results:move_messages(account['academic-alerts'])
    168 
    169 -- Github --
    170 -- results = account.INBOX:contain_from('notifications@github.com')
    171 -- results:move_messages(account['github'])
    172