432966a418
* copy URLs in foot to primary selection * remove rarely used/invalid choices from delegator * manually exit in mailsync because ! disabled set -e * emit OSC 7 cwd so foot can open new windows in current directory
42 lines
1.0 KiB
Bash
Executable File
42 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
export USER="$(whoami)"
|
|
export HOME=/home/"$USER"
|
|
export DISPLAY=":0"
|
|
|
|
set -e
|
|
|
|
# Don't sync mails while composing
|
|
if pgrep -f mcom > /dev/null; then exit; fi
|
|
if pgrep -f mfwd > /dev/null; then exit; fi
|
|
if pgrep -f mbnc > /dev/null; then exit; fi
|
|
if pgrep -f mrep > /dev/null; then exit; fi
|
|
|
|
# Split outbox emails
|
|
mlist -d /data/mail/outbox | mpick -t 'from =~~ "posteo"' | mflag -F | mrefile /data/mail/posteo/Sent
|
|
|
|
# check for internet connection
|
|
ip route ls | grep -q '.'
|
|
|
|
# check if the gpg-agent is running
|
|
pgrep gpg-agent > /dev/null
|
|
|
|
# Sync email
|
|
mbsync -a -q || true
|
|
|
|
# No further processing if there are no new mails
|
|
if ! mdirs /data/mail | mlist -N | grep -q .; then
|
|
exec sleep 1m
|
|
fi
|
|
|
|
# Incorporate new mails and store them in the temp sequence
|
|
s="$(mktemp)"
|
|
trap "rm '$s'" EXIT KILL
|
|
mdirs /data/mail | minc > "$s"
|
|
|
|
{
|
|
# Ignores
|
|
mpick -t 'subject =~ "\[hackers\] \[slstatus\]"' < "$s"
|
|
mpick -t 'subject =~ "\[hackers\] \[svkdb\]"' < "$s"
|
|
mpick -t 'subject ~~ "*Bump * from * to *" && "cc" !~~ "Felix*"' < "$s"
|
|
} | sort | uniq | mflag -Sf > /dev/null
|