From 6e49c7168da2b3e2467e6f38190944c88849b44c Mon Sep 17 00:00:00 2001 From: Tim Deeb-Swihart Date: Mon, 1 Apr 2019 13:01:12 -0400 Subject: [PATCH] updates. --- bin/watchman-process-files.py | 10 +++++++--- etc/stubby/stubby.yml | 12 ++++++------ hammerspoon/collection-scripts/com.apple.mail.scpt | 2 +- hammerspoon/global.lua | 2 +- hammerspoon/mail.lua | 2 +- ...t => local.timods.keepit.dailylog.plist.disabled} | 0 ... => local.timods.keepit.linkindex.plist.disabled} | 0 7 files changed, 16 insertions(+), 12 deletions(-) rename launchagents/{local.timods.keepit.dailylog.plist => local.timods.keepit.dailylog.plist.disabled} (100%) rename launchagents/{local.timods.keepit.linkindex.plist => local.timods.keepit.linkindex.plist.disabled} (100%) diff --git a/bin/watchman-process-files.py b/bin/watchman-process-files.py index 6f94520..00ee80d 100644 --- a/bin/watchman-process-files.py +++ b/bin/watchman-process-files.py @@ -6,7 +6,7 @@ import os import re import sys -from subprocess import check_output, STDOUT +from subprocess import check_output, STDOUT, CalledProcessError from tempfile import NamedTemporaryFile add_tmpl = ' add files {{POSIX file "{name}"}} by moving to ({fldr}) with tags {{{tags}}}' @@ -19,7 +19,7 @@ repeat until top level folder is not missing value delay 1 end repeat - set inbox to get folder id "A13B9FE9-7094-475F-8E9B-2452B3DEDCF0" + set inbox to default import destination {items} end tell """ @@ -142,7 +142,11 @@ def process_file(rules, variables, path: str, state: dict): scpt = script.format(items='\n'.join(items)) tempf.write(scpt) tempf.flush() - out = check_output(['/usr/bin/osascript', tempf.name], stderr=STDOUT) + try: + out = check_output(['/usr/bin/osascript', tempf.name], stderr=STDOUT) + except CalledProcessError as e: + print(e) + raise if out and out.strip() != b'true': print(out.decode()) diff --git a/etc/stubby/stubby.yml b/etc/stubby/stubby.yml index 5a78eb6..1e97155 100644 --- a/etc/stubby/stubby.yml +++ b/etc/stubby/stubby.yml @@ -18,10 +18,10 @@ upstream_recursive_servers: tls_auth_name: "cloudflare-dns.com" ## Quad 9 'secure' service - Filters, does DNSSEC, doesn't send ECS - - address_data: 9.9.9.9 - tls_auth_name: "dns.quad9.net" - - address_data: 149.112.112.112 - tls_auth_name: "dns.quad9.net" + # - address_data: 9.9.9.9 + # tls_auth_name: "dns.quad9.net" + # - address_data: 149.112.112.112 + # tls_auth_name: "dns.quad9.net" ####### IPv6 addresses ###### ## Cloudflare servers @@ -31,5 +31,5 @@ upstream_recursive_servers: tls_auth_name: "cloudflare-dns.com" ## Quad 9 'secure' service - Filters, does DNSSEC, doesn't send ECS - - address_data: 2620:fe::fe - tls_auth_name: "dns.quad9.net" + # - address_data: 2620:fe::fe + # tls_auth_name: "dns.quad9.net" diff --git a/hammerspoon/collection-scripts/com.apple.mail.scpt b/hammerspoon/collection-scripts/com.apple.mail.scpt index ec9435c..1b4017c 100644 --- a/hammerspoon/collection-scripts/com.apple.mail.scpt +++ b/hammerspoon/collection-scripts/com.apple.mail.scpt @@ -1 +1 @@ -mail-archive \ No newline at end of file +-- Import selected Mail messages & attachments to DEVONthink Pro. -- Created by Christian Grunenberg on Mon Mar 05 2012. -- Copyright (c) 2012-2015. All rights reserved. -- this string is used when the message subject is empty property pNoSubjectString : "(no subject)" on date_to_iso(dt) set {year:y, month:m, day:d} to dt set y to text 2 through -1 of ((y + 10000) as text) set m to text 2 through -1 of ((m + 100) as text) set d to text 2 through -1 of ((d + 100) as text) return y & "-" & m & "-" & d end date_to_iso on year_from_date(dt) set {year:y, month:m, day:d} to dt return (text 2 through -1 of ((y + 10000) as text)) & "" end year_from_date tell application "Mail" try set theSelection to the selection set theFolder to (POSIX path of (path to temporary items)) if the length of theSelection is less than 1 then error "One or more messages must be selected." repeat with theMessage in theSelection my importMessage(theMessage, theFolder) end repeat on error error_message number error_number if error_number is not -128 then display alert "Mail" message error_message as warning end try end tell on importMessage(theMessage, theFolder) tell application "Mail" try tell theMessage set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, subject, the source, the read status} set theISODate to my date_to_iso(theDateReceived) set theName to theISODate & " " & theSubject & ".eml" set theYear to my year_from_date(theDateReceived) end tell if theSubject is equal to "" then set theSubject to pNoSubjectString set theAttachmentCount to count of mail attachments of theMessage tell application "Keep It" repeat until top level folder is not missing value delay 1 end repeat set theGroup to default import destination if theAttachmentCount is greater than 0 then set theGroup to (make new folder in theGroup with properties {name:theSubject}) add text theSource as plain text file in theGroup with name theName end tell on error error_message number error_number if error_number is not -128 then display alert "Mail" message error_message as warning end try end tell end importMessage \ No newline at end of file diff --git a/hammerspoon/global.lua b/hammerspoon/global.lua index 56fd3a9..25e2127 100644 --- a/hammerspoon/global.lua +++ b/hammerspoon/global.lua @@ -34,7 +34,7 @@ end function collectFromFrontmostApp() local app = helpers.currentApp() if app == nil then return end - local bundleID = app:bundleID() + local bundleID = string.lower(app:bundleID()) local scpt = os.getenv("HOME") .. "/.hammerspoon/collection-scripts/" .. bundleID .. ".scpt" local js = os.getenv("HOME") .. "/.hammerspoon/collection-scripts/" .. bundleID .. ".js" if helpers.fexists(scpt) then diff --git a/hammerspoon/mail.lua b/hammerspoon/mail.lua index 3403cc0..6a4c0a5 100644 --- a/hammerspoon/mail.lua +++ b/hammerspoon/mail.lua @@ -4,7 +4,7 @@ local module = {} module.keybinds = { hs.hotkey.bind({"ctrl", "cmd"}, "a", function () - hs.osascript.applescriptFromFile("~/.hammerspoon/collection-scripts/keepit-com.apple.Mail.scpt") + hs.osascript.applescriptFromFile("~/.hammerspoon/collection-scripts/com.apple.mail.scpt") end)} for k, binding in pairs(module.keybinds) do diff --git a/launchagents/local.timods.keepit.dailylog.plist b/launchagents/local.timods.keepit.dailylog.plist.disabled similarity index 100% rename from launchagents/local.timods.keepit.dailylog.plist rename to launchagents/local.timods.keepit.dailylog.plist.disabled diff --git a/launchagents/local.timods.keepit.linkindex.plist b/launchagents/local.timods.keepit.linkindex.plist.disabled similarity index 100% rename from launchagents/local.timods.keepit.linkindex.plist rename to launchagents/local.timods.keepit.linkindex.plist.disabled