+ declare -gi _seq; _seq+=1
+ echo "test body" | m mail -s "test mail from $HOSTNAME, $_seq" "${@:-root@localhost}"
+ # for testing to send from an external address, you can do for example
+ # -fian@iank.bid -aFrom:ian@iank.bid web-6fnbs@mail-tester.com
+ # note in exim, you can retry a deferred message
+ # s exim -M MSG_ID
+ # MSG_ID is in /var/log/exim4/mainlog, looks like 1ccdnD-0001nh-EN
+}
+
+# to test sieve, use below command. for fsf mail, see offlineimap-sync script
+# make modifications, then copy to live file, use -eW to actually modify mailbox
+#
+# Another option is to use sieve-test SCRIPT MAIL_FILE. note,
+# sieve-test doesnt know about envelopes, Im not sure if sieve-filter does.
+
+# sieve with output filter. arg is mailbox, like INBOX.
+# This depends on dovecot conf, notably mail_location in /etc/dovecot/conf.d/10-mail.conf
+
+_dosieve() {
+ sieve-filter "$@" 2> >(head; tail) >/tmp/testsieve.log && sed -rn '/^Performed actions:/,/^[^ ]/{/^ /p}' /tmp/testsieve.log | sort | uniq -c
+}
+
+# always run this first, edit the test files, then run the following
+testsieve() {
+ _dosieve ~/sieve/maintest.sieve ${1:-INBOX} delete
+}
+runsieve() {
+ c ~/sieve; cp personal{test,}.sieve; cp lists{test,}.sieve; cp personalend{test,}.sieve
+ _dosieve ~/sieve/main.sieve -eW ${1:-INBOX} delete
+}
+
+# mail related
+testexim() {
+ # testmail above calls sendmail, which is a link to exim/postfix.
+ # its docs dont say a way of adding an argument
+ # to sendmail to turn on debug output. We could make a wrapper, but
+ # that is a pain. Exim debug args are documented here:
+ # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
+ #
+ # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
+ # note, for exim daemon, you can turn on debug options by
+ # adding -d, etc to COMMONOPTIONS in
+ # /etc/default/exim4
+# exim -d -t <<'EOF'
+ exim -i 'test@zroe.org, t2@zroe.org' <<'EOF'
+From: ian@iankelling.org
+To: test@zroe.org, t2@zroe.org
+Subject: Testing Exim
+
+This is a test message.
+EOF
+}
+
+# toggle keyboard
+tk() {
+ # based on
+ # https://askubuntu.com/questions/160945/is-there-a-way-to-disable-a-laptops-internal-keyboard
+ id=$(xinput --list --id-only 'AT Translated Set 2 keyboard')
+ if xinput list | grep -F '∼ AT Translated Set 2 keyboard' &>/dev/null; then
+ echo enabling keyboard
+ # find the first slave keyboard number, they are all the same in my output.
+ # if they werent, worst case we would need to save the slave number somewhere
+ # when it got disabled.
+ slave=$(xinput list | sed -n 's/.*slave \+keyboard (\([0-9]*\)).*/\1/p' | head -n1)
+ xinput reattach $id $slave
+ else
+ xinput float $id
+ fi