diff --git a/Obsidian.alfredworkflow b/Obsidian.alfredworkflow deleted file mode 100644 index 7186bcc..0000000 Binary files a/Obsidian.alfredworkflow and /dev/null differ diff --git a/Obsidian/info.plist b/Obsidian/info.plist index d6253f5..f55bbf4 100644 --- a/Obsidian/info.plist +++ b/Obsidian/info.plist @@ -4,8 +4,6 @@ bundleid com.hauselin.obsidian - category - Productivity connections 08189677-1EA8-4DC2-9C09-DC2F2AF0866E @@ -512,6 +510,19 @@ + 8DC3F776-5D65-4B13-BC08-55A21B6E662A + + + destinationuid + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + modifiers + 0 + modifiersubtext + + vitoclose + + + 9295060C-B513-4806-8F12-52EC6D30C9A3 @@ -629,6 +640,19 @@ + C6A6B247-1F7A-4075-A172-1ED04F1F2188 + + + destinationuid + DA9276A8-80E4-45B4-A38A-7B2FB3805943 + modifiers + 0 + modifiersubtext + + vitoclose + + + CD6980A3-E50D-4689-B8D6-1A677CDE1914 @@ -655,6 +679,19 @@ + EB45D9BC-334F-4A40-A685-39AEE6C06B11 + + + destinationuid + 8DC3F776-5D65-4B13-BC08-55A21B6E662A + modifiers + 0 + modifiersubtext + + vitoclose + + + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 @@ -718,27 +755,6 @@ Obsidian objects - - config - - argumenttype - 2 - keyword - od - subtext - - text - Open Obsidian Daily Note - withspace - - - type - alfred.workflow.input.keyword - uid - B768A804-C61E-4133-AB9C-74C6448BFC62 - version - 1 - config @@ -751,11 +767,9 @@ focusedappvariablename hotkey - 31 + 0 hotmod - 1572864 - hotstring - O + 0 leftcursor modsmode @@ -792,17 +806,21 @@ config - paths - - /Applications/Obsidian.app - - toggle - + argumenttype + 2 + keyword + od + subtext + + text + Open Obsidian Daily Note + withspace + type - alfred.workflow.action.launchfiles + alfred.workflow.input.keyword uid - 001B3A3A-722E-440B-AA33-3589A525546C + B768A804-C61E-4133-AB9C-74C6448BFC62 version 1 @@ -827,6 +845,23 @@ version 1 + + config + + paths + + /Applications/Obsidian.app + + toggle + + + type + alfred.workflow.action.launchfiles + uid + 001B3A3A-722E-440B-AA33-3589A525546C + version + 1 + config @@ -940,7 +975,7 @@ if (date_format.includes('e')) { if (i == (date_format.length - 1) && date_format.charAt(i) == "e") { if (!isCharacterALetter(date_format.charAt(i - 1))) { date_format = date_format.substring(0, i) + '!!!' + date_format.substring(i + 1); - } + } } if (i == 0 && date_format.charAt(i) == "e") { if (!isCharacterALetter(date_format.charAt(i + 1))) { @@ -956,7 +991,7 @@ if (date_format.includes('e')) { date_format = date_format.substring(0, i) + '!!!' + date_format.substring(i + 1); } } - } + } } // if (date_format.includes('E')) { @@ -1536,6 +1571,25 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", version 1 + + config + + browser + + spaces + + url + https://publish.obsidian.md/help/Index + utf8 + + + type + alfred.workflow.action.openurl + uid + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + version + 1 + config @@ -1548,11 +1602,9 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", focusedappvariablename hotkey - 2 + 0 hotmod - 393216 - hotstring - D + 0 leftcursor modsmode @@ -1567,25 +1619,6 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", version 2 - - config - - browser - - spaces - - url - https://publish.obsidian.md/help/Index - utf8 - - - type - alfred.workflow.action.openurl - uid - 9F656256-DD01-4508-BF9F-CDB3168DB9B6 - version - 1 - config @@ -1663,7 +1696,7 @@ console.log(uri); escaping 68 keyword - on + oo queuedelaycustom 3 queuedelayimmediatelyinitially @@ -1673,7 +1706,7 @@ console.log(uri); queuemode 1 runningsubtext - Specify which vault to create a new note in + script ObjC.import('stdlib'); console.log('Running script') @@ -1682,7 +1715,7 @@ console.log('Running script') var vaults = [] var vaultpaths = [] // keep track of vaultpaths to prevent duplicating try { - for (i = 2; i < 100; i++) { + for (i = 1; i < 100; i++) { var vidx = 'vault' + i.toString() var vpath = $.getenv(vidx) var vname = $.getenv(vidx + 'name') @@ -1693,21 +1726,21 @@ try { vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) vaultpaths.push(vpath) } - } + } } catch { console.log('Found ' + (i-1).toString() + ' vaults') } -// list vaults +// list vaults JSON.stringify({items: vaults}) scriptargtype 1 scriptfile subtext - Specify which vault to create a new note in + Type something to autcomplete or space to list vaults title - Create new note in a vault + Which vault to open? type 7 withspace @@ -1716,41 +1749,20 @@ JSON.stringify({items: vaults}) type alfred.workflow.input.scriptfilter uid - 854EB1EE-9017-4F43-BC80-BAF317FC5315 + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 version 3 - - config - - argumenttype - 1 - subtext - {query}.md (default: {var:fname_default}) - text - New note title? - withspace - - - type - alfred.workflow.input.keyword - uid - 8B221971-0089-4DAC-A056-EC2C961C6EAB - version - 1 - config concurrently escaping - 0 + 68 script - /* cSpell:disable */ - -ObjC.import('stdlib'); -console.log('Running script - on') + ObjC.import('stdlib'); +console.log('Running script - fallback search') // get the current app to access the standard additions app = Application.currentApplication(); @@ -1759,55 +1771,12 @@ app.includeStandardAdditions = true; var v = $.getenv('vault'); var fname = $.getenv('fname'); -function interpolate_homepath(path) { - homepath = app.pathTo('home folder') - return path.replace(/^~/, homepath) -} - -if (fname == "") { // use default title - fname = $.getenv('fname_default') -} - -console.log(v) -console.log(fname) - -// get vault path -for (i = 2; i < 1000; i++) { - var vidx = 'vault' + i.toString() + 'name' - var temp = $.getenv(vidx) // throws error if variable doesn't exist - console.log(temp) - if (temp == v) { - var vpath = $.getenv('vault' + i.toString()) - vpath = interpolate_homepath(vpath) - console.log('vpath: ' + vpath) - break - } -} - -var filepath = vpath + "/" + fname + ".md"; -console.log("filepath: " + filepath) - -// create file -var path = Path(filepath) -var finderApp = Application("Finder") -if (!finderApp.exists(path)) { - console.log("Note doesn't exist. Creating note.") - var openedFile = app.openForAccess(path, {writePermission: true}) - app.write("", { to: openedFile, startingAt: app.getEof(openedFile) }) - app.closeAccess(openedFile) - delay(1) -} - -// open file // construct uri -uri = "obsidian://open?vault=" + encodeURIComponent(v) + "&file=" + encodeURIComponent(fname); +uri = "obsidian://search?vault=" + encodeURIComponent(v) + "&query=" + encodeURIComponent(fname); -// open file in vault +// search in vault app.openLocation(uri); -console.log(uri); - -delay(3.0); // temporary fix for Electron bug (open note twice) -app.openLocation(uri); +console.log(uri); scriptargtype 0 scriptfile @@ -1818,49 +1787,20 @@ app.openLocation(uri); type alfred.workflow.action.script uid - 3CF13837-2DBB-46AA-93B4-6CA9598A106E + DE762236-EFCC-45D3-85CA-A1B6B191762C version 2 config - argument - - passthroughargument - - variables - - fname - {query} - + text + Search Obsidian for {query} type - alfred.workflow.utility.argument + alfred.workflow.trigger.fallback uid - 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 - version - 1 - - - config - - argument - - passthroughargument - - variables - - fname_default - {date:yyyyMMdd_HHmmss} - vault - {query} - - - type - alfred.workflow.utility.argument - uid - 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + 1BD03BB0-06B9-47F5-9346-7A829C38B248 version 1 @@ -1879,8 +1819,6 @@ app.openLocation(uri); 1 escaping 68 - keyword - oo queuedelaycustom 3 queuedelayimmediatelyinitially @@ -1893,13 +1831,13 @@ app.openLocation(uri); script ObjC.import('stdlib'); -console.log('Running script') +console.log('Running script - retrieve vaults') // get all vaults var vaults = [] var vaultpaths = [] // keep track of vaultpaths to prevent duplicating try { - for (i = 1; i < 100; i++) { + for (i = 2; i < 100; i++) { var vidx = 'vault' + i.toString() var vpath = $.getenv(vidx) var vname = $.getenv(vidx + 'name') @@ -1910,12 +1848,12 @@ try { vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) vaultpaths.push(vpath) } - } + } } catch { console.log('Found ' + (i-1).toString() + ' vaults') } -// list vaults +// list vaults JSON.stringify({items: vaults}) scriptargtype 1 @@ -1924,7 +1862,7 @@ JSON.stringify({items: vaults}) subtext Type something to autcomplete or space to list vaults title - Which vault to open? + Which vault to search in? type 7 withspace @@ -1933,131 +1871,30 @@ JSON.stringify({items: vaults}) type alfred.workflow.input.scriptfilter uid - 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + CD6980A3-E50D-4689-B8D6-1A677CDE1914 version 3 config - concurrently - - escaping - 68 - script - ObjC.import('stdlib'); -console.log('Running script - fallback search') - -// get the current app to access the standard additions -app = Application.currentApplication(); -app.includeStandardAdditions = true; - -var v = $.getenv('vault'); -var fname = $.getenv('fname'); - -// construct uri -uri = "obsidian://search?vault=" + encodeURIComponent(v) + "&query=" + encodeURIComponent(fname); - -// search in vault -app.openLocation(uri); -console.log(uri); - scriptargtype - 0 - scriptfile - - type - 7 - - type - alfred.workflow.action.script - uid - DE762236-EFCC-45D3-85CA-A1B6B191762C - version - 2 - - - config - - text - Search Obsidian for {query} - - type - alfred.workflow.trigger.fallback - uid - 1BD03BB0-06B9-47F5-9346-7A829C38B248 - version - 1 - - - config - - alfredfiltersresults - - alfredfiltersresultsmatchmode - 0 - argumenttreatemptyqueryasnil - - argumenttrimmode - 0 argumenttype - 1 - escaping - 68 - queuedelaycustom - 3 - queuedelayimmediatelyinitially - - queuedelaymode 0 - queuemode - 1 - runningsubtext - - script - ObjC.import('stdlib'); -console.log('Running script - retrieve vaults') - -// get all vaults -var vaults = [] -var vaultpaths = [] // keep track of vaultpaths to prevent duplicating -try { - for (i = 2; i < 100; i++) { - var vidx = 'vault' + i.toString() - var vpath = $.getenv(vidx) - var vname = $.getenv(vidx + 'name') - if (vname == "") { - throw "catch" - } - if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet - vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) - vaultpaths.push(vpath) - } - } -} catch { - console.log('Found ' + (i-1).toString() + ' vaults') -} - -// list vaults -JSON.stringify({items: vaults}) - scriptargtype - 1 - scriptfile - + keyword + on subtext - Type something to autcomplete or space to list vaults - title - Which vault to search in? - type - 7 + Creating Note + text + {query} in {var:vault2name} withspace - + type - alfred.workflow.input.scriptfilter + alfred.workflow.input.keyword uid - CD6980A3-E50D-4689-B8D6-1A677CDE1914 + EB45D9BC-334F-4A40-A685-39AEE6C06B11 version - 3 + 1 config @@ -2102,21 +1939,22 @@ JSON.stringify({items: vaults}) config - argumenttype - 2 - keyword - oss - subtext - Press enter to continue - text - Search within vaults - withspace + argument + + passthroughargument + variables + + fname + {query} + vault + {var:vault2name} + type - alfred.workflow.input.keyword + alfred.workflow.utility.argument uid - 44D69DBA-085D-4208-86A1-CED1CA068AB3 + 8DC3F776-5D65-4B13-BC08-55A21B6E662A version 1 @@ -2227,7 +2065,7 @@ try { // loop through existing vault variables } else { vaultpaths.push(temp) } - } + } } catch { // create new variable if doesn't exist if (!vaultpaths.includes(path)) { // add vault variable only vault hasn't been added @@ -2247,6 +2085,24 @@ try { // loop through existing vault variables }); } + if (i==2){ + console.log('Assigned default vault to ' + vaultname); + + Application('com.runningwithcrayons.Alfred').setConfiguration("defaultVaultPath", { + toValue: path, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + + // store vault name + Application('com.runningwithcrayons.Alfred').setConfiguration("defaultVaultName", { + toValue: vaultname, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + } + + } scriptargtype 0 @@ -2265,10 +2121,49 @@ try { // loop through existing vault variables config - concurrently - + argumenttype + 1 + subtext + {query}.md (default: {var:fname_default}) + text + New note title? + withspace + + + type + alfred.workflow.input.keyword + uid + 8B221971-0089-4DAC-A056-EC2C961C6EAB + version + 1 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 escaping 68 + keyword + onv + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + Specify which vault to create a new note in script ObjC.import('stdlib'); console.log('Running script') @@ -2282,156 +2177,166 @@ try { var vpath = $.getenv(vidx) var vname = $.getenv(vidx + 'name') if (vname == "") { + console.log("vpath=",vpath) throw "catch" } if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) vaultpaths.push(vpath) } - } -} catch { - console.log('Found ' + (i-1).toString() + ' vaults') -} - - -// create json object to pass to next object -var jsonobj = { - "alfredworkflow" : { - "arg" : "{query}", - "config" : { - "scopes" : vaultpaths, } - } +} catch(err) { + console.log(err) + console.log('Found ' + (i-1).toString() + ' vaults') } -// pass to next object in workflow -JSON.stringify(jsonobj) +// list vaults +JSON.stringify({items: vaults}) scriptargtype - 0 + 1 scriptfile + subtext + Specify which vault to create a new note in + title + Create new note in a vault type 7 + withspace + type - alfred.workflow.action.script + alfred.workflow.input.scriptfilter uid - 46732892-62E0-47CE-B727-EBA967105197 + 854EB1EE-9017-4F43-BC80-BAF317FC5315 version - 2 + 3 config - anchorfields - - argumenttrimmode - 0 - argumenttype - 0 - daterange + concurrently + + escaping 0 - fields - - - field - kMDItemDisplayName - not - - split - - value - {query} - words - - - - field - kMDItemFinderComment - not - - split - - value - {query} - words - - - - field - kMDItemTextContent - not - - split - - value - {query} - words - - - - includesystem - - keyword - os - limit + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script - on') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +var v = $.getenv('vault'); +var fname = $.getenv('fname'); +console.log("got vname=",v,", and note_name=",fname) + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +if (fname == "") { // use default title + fname = $.getenv('fname_default') +} + +console.log(v) +console.log(fname) + +// get vault path +for (i = 2; i < 1000; i++) { + var vidx = 'vault' + i.toString() + 'name' + var temp = $.getenv(vidx) // throws error if variable doesn't exist + console.log(temp) + if (temp == v) { + var vpath = $.getenv('vault' + i.toString()) + vpath = interpolate_homepath(vpath) + console.log('vpath: ' + vpath) + break + } +} + +var filepath = vpath + "/" + fname + ".md"; +console.log("filepath: " + filepath) + +// create file +var path = Path(filepath) +var finderApp = Application("Finder") +if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write("", { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + delay(1) +} + +// open file +// construct uri +uri = "obsidian://open?vault=" + encodeURIComponent(v) + "&file=" + encodeURIComponent(fname); + +// open file in vault +app.openLocation(uri); +console.log(uri); + +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype 0 - runningsubtext + scriptfile - scopes - - sortmode - 0 - subtext - Search for {query} - title - Search markdown files - types - - net.daringfireball.markdown - net.ia.markdown - public.plain-text - - withspace - + type + 7 type - alfred.workflow.input.filefilter + alfred.workflow.action.script uid - 2CC3DBA2-EDA4-4548-A215-611A436E43DB + 3CF13837-2DBB-46AA-93B4-6CA9598A106E version 2 config - action - 0 argument - 0 - focusedappvariable - - focusedappvariablename - hotkey - 0 - hotmod - 0 - hotstring + passthroughargument + + variables + + fname + {query} + + + type + alfred.workflow.utility.argument + uid + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + version + 1 + + + config + + argument - leftcursor + passthroughargument - modsmode - 0 - relatedAppsMode - 0 + variables + + fname_default + {date:yyyyMMdd_HHmmss} + vault + {query} + type - alfred.workflow.trigger.hotkey + alfred.workflow.utility.argument uid - 9295060C-B513-4806-8F12-52EC6D30C9A3 + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 version - 2 + 1 config @@ -2561,39 +2466,18 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyvaultname", argumenttype 2 keyword - orr + oss subtext Press enter to continue text - Search within vaults (modified last 3 days) + Search within vaults withspace type alfred.workflow.input.keyword uid - 403F9FD9-33F0-42FC-8E20-FEC2C821B083 - version - 1 - - - config - - argumenttype - 0 - keyword - odailyformat - subtext - Examples: yyyy-mm-dd, mddyyyy, dd_MMM_yyyy (current: {var:dailyformat}) - text - Specify daily note format: {query} - withspace - - - type - alfred.workflow.input.keyword - uid - 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + 44D69DBA-085D-4208-86A1-CED1CA068AB3 version 1 @@ -2606,14 +2490,43 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyvaultname", 68 script ObjC.import('stdlib'); - console.log('Running script') -Application('com.runningwithcrayons.Alfred').setConfiguration("dailyformat", { - toValue: "{query}", - exportable: false, - inWorkflow: $.getenv('alfred_workflow_bundleid'), -}); +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +console.log("Found vaults",vaults) + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} +console.log("passing object next",JSON.stringify(jsonobj)) + +// pass to next object in workflow +JSON.stringify(jsonobj) scriptargtype 0 scriptfile @@ -2624,167 +2537,21 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyformat", { type alfred.workflow.action.script uid - D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + 46732892-62E0-47CE-B727-EBA967105197 version 2 config - concurrently - - escaping - 0 - script - /* cSpell:disable */ -ObjC.import('stdlib'); -console.log('Running script - search') - -// absolute file path to file -p="{query}"; - -// construct uri -uri = "obsidian://open?path=" + encodeURIComponent(p); -console.log(uri) - -// get the current app to access the standard additions -app = Application.currentApplication(); -app.includeStandardAdditions = true; - -// open file in vault -// app.openLocation(uri); -console.log(p); - - - -function interpolate_homepath(path) { - homepath = app.pathTo('home folder') - return path.replace(/^~/, homepath) -} - - - -// check if file path contains vault names; if not, append "file://" to it to open in default app -// get all vaults -var vaultpaths = [] // keep track of vaultpaths to prevent duplicating -try { - for (i = 2; i < 100; i++) { - var vidx = 'vault' + i.toString() - var vpath = $.getenv(vidx) - vpath = interpolate_homepath(vpath); - - var vname = $.getenv(vidx + 'name') - if (vname == "") { - throw "catch" - } - if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet - vaultpaths.push(vpath) - } - } -} catch { - console.log('Found ' + (i-1).toString() + ' vaults') -} - -console.log(vaultpaths) - -var invault = 0 -for (i=0; i<vaultpaths.length; i++) { - if (p.indexOf(vaultpaths[i]) >= 0) { - invault = 1 - } -} - -if (invault == 0) { - uri = uri.replace("obsidian://open?path=", "file:///") -} - -app.openLocation(uri); -console.log(uri); -delay(3.0); // temporary fix for Electron bug (open note twice) -app.openLocation(uri); - scriptargtype - 0 - scriptfile - - type - 7 - - type - alfred.workflow.action.script - uid - 70AEEB77-35DB-44B9-B633-BE1D2B43D581 - version - 2 - - - config - - concurrently - - escaping - 68 - script - ObjC.import('stdlib'); -console.log('Running script') - -// get all vaults -var vaults = [] -var vaultpaths = [] // keep track of vaultpaths to prevent duplicating -try { - for (i = 2; i < 100; i++) { - var vidx = 'vault' + i.toString() - var vpath = $.getenv(vidx) - var vname = $.getenv(vidx + 'name') - if (vname == "") { - throw "catch" - } - if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet - vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) - vaultpaths.push(vpath) - } - } -} catch { - console.log('Found ' + (i-1).toString() + ' vaults') -} - - -// create json object to pass to next object -var jsonobj = { - "alfredworkflow" : { - "arg" : "{query}", - "config" : { - "scopes" : vaultpaths, - } - } -} - -// pass to next object in workflow -JSON.stringify(jsonobj) - scriptargtype - 0 - scriptfile - - type - 7 - - type - alfred.workflow.action.script - uid - 249B0782-BFFB-4382-A857-5058D7C3D244 - version - 2 - - - config - - anchorfields - - argumenttrimmode + anchorfields + + argumenttrimmode 0 argumenttype 0 daterange - 2 + 0 fields @@ -2825,9 +2592,9 @@ JSON.stringify(jsonobj) includesystem - + keyword - or + os limit 0 runningsubtext @@ -2839,12 +2606,10 @@ JSON.stringify(jsonobj) subtext Search for {query} title - Search markdown files (modified last 3 days) + Search markdown files types - net.daringfireball.markdown - net.ia.markdown - public.plain-text + dyn.ah62d4rv4ge8043a withspace @@ -2852,7 +2617,59 @@ JSON.stringify(jsonobj) type alfred.workflow.input.filefilter uid - 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + version + 2 + + + config + + argumenttype + 0 + keyword + odailyformat + subtext + Examples: yyyy-mm-dd, mddyyyy, dd_MMM_yyyy (current: {var:dailyformat}) + text + Specify daily note format: {query} + withspace + + + type + alfred.workflow.input.keyword + uid + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyformat", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC version 2 @@ -2871,8 +2688,6 @@ JSON.stringify(jsonobj) 0 hotmod 0 - hotstring - leftcursor modsmode @@ -2883,7 +2698,7 @@ JSON.stringify(jsonobj) type alfred.workflow.trigger.hotkey uid - CEC4065E-BADA-44B7-A255-4A9D613685E2 + 9295060C-B513-4806-8F12-52EC6D30C9A3 version 2 @@ -3002,18 +2817,18 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytempabspath" argumenttype 2 keyword - ott + orr subtext Press enter to continue text - Search within vaults (modified today) + Search within vaults (modified last 3 days) withspace type alfred.workflow.input.keyword uid - FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 version 1 @@ -3026,14 +2841,41 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytempabspath" 68 script ObjC.import('stdlib'); - console.log('Running script') -Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { - toValue: "{query}", - exportable: false, - inWorkflow: $.getenv('alfred_workflow_bundleid'), -}); +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) scriptargtype 0 scriptfile @@ -3044,7 +2886,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { type alfred.workflow.action.script uid - 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + 249B0782-BFFB-4382-A857-5058D7C3D244 version 2 @@ -3058,7 +2900,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { argumenttype 0 daterange - 0 + 2 fields @@ -3101,7 +2943,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { includesystem keyword - odailypath + or limit 0 runningsubtext @@ -3111,12 +2953,12 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { sortmode 0 subtext - Type to search (current: {var:dailyabspath}) + Search for {query} title - Specify daily note directory + Search markdown files (modified last 3 days) types - public.folder + dyn.ah62d4rv4ge8043a withspace @@ -3124,7 +2966,38 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { type alfred.workflow.input.filefilter uid - 8C017EEF-38DD-4148-9291-9302EFCE33DE + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC version 2 @@ -3138,7 +3011,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { argumenttype 0 daterange - 1 + 0 fields @@ -3181,7 +3054,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { includesystem keyword - ot + odailypath limit 0 runningsubtext @@ -3191,14 +3064,12 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { sortmode 0 subtext - Search for {query} + Type to search (current: {var:dailyabspath}) title - Search markdown files (modified today) + Specify daily note directory types - net.daringfireball.markdown - net.ia.markdown - public.plain-text + public.folder withspace @@ -3206,7 +3077,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { type alfred.workflow.input.filefilter uid - C016E20E-3F44-4372-90DC-1B00DA8C07F8 + 8C017EEF-38DD-4148-9291-9302EFCE33DE version 2 @@ -3216,44 +3087,74 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { concurrently escaping - 68 + 0 script - ObjC.import('stdlib'); -console.log('Running script') + /* cSpell:disable */ +ObjC.import('stdlib'); +console.log('Running script - search') + +// absolute file path to file +p="{query}"; + +// construct uri +uri = "obsidian://open?path=" + encodeURIComponent(p); +console.log(uri) + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// open file in vault +// app.openLocation(uri); +console.log(p); + + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + +// check if file path contains vault names; if not, append "file://" to it to open in default app // get all vaults -var vaults = [] var vaultpaths = [] // keep track of vaultpaths to prevent duplicating try { for (i = 2; i < 100; i++) { var vidx = 'vault' + i.toString() var vpath = $.getenv(vidx) + vpath = interpolate_homepath(vpath); + var vname = $.getenv(vidx + 'name') if (vname == "") { throw "catch" } if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet - vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) vaultpaths.push(vpath) } - } + } } catch { console.log('Found ' + (i-1).toString() + ' vaults') } +console.log(vaultpaths) -// create json object to pass to next object -var jsonobj = { - "alfredworkflow" : { - "arg" : "{query}", - "config" : { - "scopes" : vaultpaths, - } - } +var invault = 0 +for (i=0; i<vaultpaths.length; i++) { + if (p.indexOf(vaultpaths[i]) >= 0) { + invault = 1 + } } -// pass to next object in workflow -JSON.stringify(jsonobj) +if (invault == 0) { + uri = uri.replace("obsidian://open?path=", "file:///") +} + +app.openLocation(uri); +console.log(uri); +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); scriptargtype 0 scriptfile @@ -3264,7 +3165,7 @@ JSON.stringify(jsonobj) type alfred.workflow.action.script uid - 6FF78F6F-9167-45D0-B022-7BE55106848C + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 version 2 @@ -3283,8 +3184,6 @@ JSON.stringify(jsonobj) 0 hotmod 0 - hotstring - leftcursor modsmode @@ -3295,7 +3194,7 @@ JSON.stringify(jsonobj) type alfred.workflow.trigger.hotkey uid - 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + CEC4065E-BADA-44B7-A255-4A9D613685E2 version 2 @@ -3341,10 +3240,20 @@ try { // loop through existing vault variables Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { inWorkflow: $.getenv('alfred_workflow_bundleid'), }); - } -} catch { + } +} catch { console.log("Removed " + (i-1).toString() + " variables"); -} +} + +Application('com.runningwithcrayons.Alfred').setConfiguration("defaultVaultName", { + toValue:"", + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + +Application('com.runningwithcrayons.Alfred').setConfiguration("defaultVaultPath", { + toValue:"", + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); scriptargtype 0 scriptfile @@ -3362,76 +3271,111 @@ try { // loop through existing vault variables config - concurrently + argumenttype + 2 + keyword + ott + subtext + Press enter to continue + text + Search within vaults (modified today) + withspace - escaping - 68 - script - ObjC.import('stdlib'); -console.log('Running script') - -var remove_vault = '{query}'; -console.log(remove_vault) - -try { // loop through existing vault variables - for (i = 2; i < 100; i++) { - var vidx = 'vault' + i.toString() - vname = $.getenv(vidx + 'name') - if (vname == remove_vault) { - console.log("Found vault. Clearing it.") - Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx, { - inWorkflow: $.getenv('alfred_workflow_bundleid'), - }); - Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { - inWorkflow: $.getenv('alfred_workflow_bundleid'), - }); - break - } - } -} catch { - console.log("Vault not found."); -} - scriptargtype - 0 - scriptfile - - type - 7 type - alfred.workflow.action.script + alfred.workflow.input.keyword uid - 67E25071-1FF8-4F8B-9A9F-2509093593B6 + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 version - 2 + 1 config - alfredfiltersresults - - alfredfiltersresultsmatchmode - 0 - argumenttreatemptyqueryasnil + anchorfields argumenttrimmode 0 argumenttype 0 - escaping - 68 + daterange + 1 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + keyword - oclearvault - queuedelaycustom - 3 - queuedelayimmediatelyinitially - - queuedelaymode + ot + limit 0 - queuemode - 1 runningsubtext + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files (modified today) + types + + dyn.ah62d4rv4ge8043a + + withspace + + + type + alfred.workflow.input.filefilter + uid + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + version + 2 + + + config + + concurrently + + escaping + 68 script ObjC.import('stdlib'); console.log('Running script') @@ -3448,35 +3392,86 @@ try { throw "catch" } if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet - vaults.push({title: "Clear vault: " + vname, arg: vname, subtitle: vpath, uid: vpath}) + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) vaultpaths.push(vpath) } - } + } } catch { console.log('Found ' + (i-1).toString() + ' vaults') } -// list vaults -JSON.stringify({items: vaults}) + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) scriptargtype - 1 + 0 scriptfile - subtext - Type something to autcomplete or space to list vaults - title - Clear one vault type 7 - withspace + + type + alfred.workflow.action.script + uid + 6FF78F6F-9167-45D0-B022-7BE55106848C + version + 2 + + + config + + concurrently + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +var remove_vault = '{query}'; +console.log(remove_vault) + +try { // loop through existing vault variables + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + vname = $.getenv(vidx + 'name') + if (vname == remove_vault) { + console.log("Found vault. Clearing it.") + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx, { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + break + } + } +} catch { + console.log("Vault not found."); +} + scriptargtype + 0 + scriptfile + + type + 7 type - alfred.workflow.input.scriptfilter + alfred.workflow.action.script uid - 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + 67E25071-1FF8-4F8B-9A9F-2509093593B6 version - 3 + 2 config @@ -3490,11 +3485,11 @@ JSON.stringify({items: vaults}) argumenttrimmode 0 argumenttype - 1 + 0 escaping 68 keyword - oterm + oclearvault queuedelaycustom 3 queuedelayimmediatelyinitially @@ -3513,7 +3508,7 @@ console.log('Running script') var vaults = [] var vaultpaths = [] // keep track of vaultpaths to prevent duplicating try { - for (i = 1; i < 100; i++) { + for (i = 2; i < 100; i++) { var vidx = 'vault' + i.toString() var vpath = $.getenv(vidx) var vname = $.getenv(vidx + 'name') @@ -3521,15 +3516,15 @@ try { throw "catch" } if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet - vaults.push({title: vname, arg: vpath, subtitle: vpath, uid: vpath}) + vaults.push({title: "Clear vault: " + vname, arg: vname, subtitle: vpath, uid: vpath}) vaultpaths.push(vpath) } - } + } } catch { console.log('Found ' + (i-1).toString() + ' vaults') } -// list vaults +// list vaults JSON.stringify({items: vaults}) scriptargtype 1 @@ -3538,7 +3533,7 @@ JSON.stringify({items: vaults}) subtext Type something to autcomplete or space to list vaults title - Which vault to open in bash? + Clear one vault type 7 withspace @@ -3547,45 +3542,36 @@ JSON.stringify({items: vaults}) type alfred.workflow.input.scriptfilter uid - 3F386808-4E4D-46DE-8331-6B983408DE48 + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 version 3 config - concurrently - - escaping + action 0 - script - // NOTE electron bug (if app isn't already opened, it will always open the last opened vault. -// https://discordapp.com/channels/686053708261228577/716028884885307432/755203478413902036 - -console.log('Running script - oterm') - -// get the current app to access the standard additions -app = Application.currentApplication(); -app.includeStandardAdditions = true; - -// get vault name -v="{query}"; - -// https://forum.keyboardmaestro.com/t/open-a-new-terminal-window-for-the-current-finder-folder/1324 -var terminal = Application("Terminal") -terminal.doScript("cd " + v.replaceAll(" ", "\ ")); -terminal.activate(); - scriptargtype + argument 0 - scriptfile + focusedappvariable + + focusedappvariablename - type - 7 + hotkey + 0 + hotmod + 0 + leftcursor + + modsmode + 0 + relatedAppsMode + 0 type - alfred.workflow.action.script + alfred.workflow.trigger.hotkey uid - 15356FC5-2D9E-4997-B906-08EEA245D255 + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 version 2 @@ -3647,41 +3633,93 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyheader", { argumenttype 0 keyword - oi + odi subtext - Append to the end of inbox note: {query} + Append to the end of daily note: {query} text - Append text to an inbox note + Append text to daily note withspace type alfred.workflow.input.keyword uid - 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + 8C013085-6514-493F-B7AE-18E02A0961A3 version 1 config - argumenttype + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode 0 + argumenttype + 1 + escaping + 68 keyword - odi + oterm + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 1; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vpath, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + subtext - Append to the end of daily note: {query} - text - Append text to daily note + Type something to autcomplete or space to list vaults + title + Which vault to open in bash? + type + 7 withspace - + type - alfred.workflow.input.keyword + alfred.workflow.input.scriptfilter uid - 8C013085-6514-493F-B7AE-18E02A0961A3 + 3F386808-4E4D-46DE-8331-6B983408DE48 version - 1 + 3 config @@ -3735,6 +3773,44 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodo", { version 1 + + config + + concurrently + + escaping + 0 + script + // NOTE electron bug (if app isn't already opened, it will always open the last opened vault. +// https://discordapp.com/channels/686053708261228577/716028884885307432/755203478413902036 + +console.log('Running script - oterm') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// get vault name +v="{query}"; + +// https://forum.keyboardmaestro.com/t/open-a-new-terminal-window-for-the-current-finder-folder/1324 +var terminal = Application("Terminal") +terminal.doScript("cd " + v.replaceAll(" ", "\ ")); +terminal.activate(); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 15356FC5-2D9E-4997-B906-08EEA245D255 + version + 2 + config @@ -3757,7 +3833,7 @@ function interpolate_homepath(path) { } // get inbox note path -var inbox_md = $.getenv('inbox_md'); +var inbox_md = $.getenv('dailytodaypath'); inbox_md = interpolate_homepath(inbox_md) // where to add timestamp @@ -3766,7 +3842,7 @@ var inbox_timestamp = $.getenv('inbox_timestamp'); // get timestamp var timestamp = $.getenv('date'); -// escape " +// escape " var query = "{query}"; // query = query.replaceAll('"', '\"'); query = query.replace(/\"/g, '\"'); // github #25 @jamiew @@ -3809,12 +3885,12 @@ console.log("CURRENT TEXT (string)"); console.log(filetext) // loop through each paragraph and append as separate bullet point -var formatted_text = ''; +var formatted_text = ''; for (i = 0; i < query.length; i++) { var text2append = query[i]; - - // parse string to remove extra spaces + + // parse string to remove extra spaces text2append = text2append.split(" ") text2append = text2append.filter(i => i.length > 0).join(" ") @@ -3831,10 +3907,10 @@ for (i = 0; i < query.length; i++) { } console.log("TEXT TO APPEND " + (i + 1)); console.log(text2append); - formatted_text += text2append; + formatted_text += text2append; } -var final_text = filetext + formatted_text; +var final_text = filetext + formatted_text; console.log("FINAL TEXT") console.log(final_text) @@ -3844,7 +3920,7 @@ str2write.writeToFileAtomicallyEncodingError(inbox_md, true, $.NSUTF8StringEncod // notification var oinotify = $.getenv('oinotify'); -if (oinotify == "on") { +if (oinotify == "on") { // https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayNotifications.html app.displayNotification("Added text to inbox", { withTitle: 'Obsidian Alfred workfow' }) } @@ -3856,9 +3932,225 @@ if (oinotify == "on") { 7 type - alfred.workflow.action.script + alfred.workflow.action.script + uid + E4ECA02D-673E-4DC4-A33A-A8E524983C6C + version + 2 + + + config + + argument + + passthroughargument + + variables + + date + {date:yyyyMMdd_HHmmss} + + + type + alfred.workflow.utility.argument + uid + AFFCF1F5-F669-4920-A76E-90E812ED8CFC + version + 1 + + + config + + matchmode + 0 + matchstring + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + F4814A0F-C578-420F-A442-A86CF87B7D6A + version + 2 + + + config + + matchmode + 0 + matchstring + + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 + version + 2 + + + config + + action + 0 + argument + 2 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 2FCAB39C-C693-4C37-869B-445FF6C20F9E + version + 2 + + + config + + argumenttype + 0 + keyword + oi + subtext + Append to the end of inbox note: {query} + text + Append text to an inbox note + withspace + + + type + alfred.workflow.input.keyword + uid + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 73853368-ED10-4729-A4D0-E231647C3CF4 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + oinbox + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search + title + Specify inbox markdown + types + + withspace + + + type + alfred.workflow.input.filefilter uid - CDEBE435-E442-4054-80BE-59ADD7EEA597 + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 version 2 @@ -3884,7 +4176,7 @@ function interpolate_homepath(path) { } // get inbox note path -var inbox_md = $.getenv('dailytodaypath'); +var inbox_md = $.getenv('inbox_md'); inbox_md = interpolate_homepath(inbox_md) // where to add timestamp @@ -3893,7 +4185,7 @@ var inbox_timestamp = $.getenv('inbox_timestamp'); // get timestamp var timestamp = $.getenv('date'); -// escape " +// escape " var query = "{query}"; // query = query.replaceAll('"', '\"'); query = query.replace(/\"/g, '\"'); // github #25 @jamiew @@ -3936,12 +4228,12 @@ console.log("CURRENT TEXT (string)"); console.log(filetext) // loop through each paragraph and append as separate bullet point -var formatted_text = ''; +var formatted_text = ''; for (i = 0; i < query.length; i++) { var text2append = query[i]; - - // parse string to remove extra spaces + + // parse string to remove extra spaces text2append = text2append.split(" ") text2append = text2append.filter(i => i.length > 0).join(" ") @@ -3958,10 +4250,10 @@ for (i = 0; i < query.length; i++) { } console.log("TEXT TO APPEND " + (i + 1)); console.log(text2append); - formatted_text += text2append; + formatted_text += text2append; } -var final_text = filetext + formatted_text; +var final_text = filetext + formatted_text; console.log("FINAL TEXT") console.log(final_text) @@ -3971,7 +4263,7 @@ str2write.writeToFileAtomicallyEncodingError(inbox_md, true, $.NSUTF8StringEncod // notification var oinotify = $.getenv('oinotify'); -if (oinotify == "on") { +if (oinotify == "on") { // https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayNotifications.html app.displayNotification("Added text to inbox", { withTitle: 'Obsidian Alfred workfow' }) } @@ -3985,7 +4277,7 @@ if (oinotify == "on") { type alfred.workflow.action.script uid - E4ECA02D-673E-4DC4-A33A-A8E524983C6C + CDEBE435-E442-4054-80BE-59ADD7EEA597 version 2 @@ -4046,63 +4338,6 @@ if (oinotify == "on") { version 1 - - config - - argument - - passthroughargument - - variables - - date - {date:yyyyMMdd_HHmmss} - - - type - alfred.workflow.utility.argument - uid - AFFCF1F5-F669-4920-A76E-90E812ED8CFC - version - 1 - - - config - - matchmode - 0 - matchstring - - - replacestring - @NEWLISTITEM@ - - type - alfred.workflow.utility.replace - uid - F4814A0F-C578-420F-A442-A86CF87B7D6A - version - 2 - - - config - - matchmode - 0 - matchstring - - - - replacestring - @NEWLISTITEM@ - - type - alfred.workflow.utility.replace - uid - 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 - version - 2 - config @@ -4115,42 +4350,9 @@ if (oinotify == "on") { focusedappvariablename hotkey - 34 - hotmod - 1835008 - hotstring - I - leftcursor - - modsmode - 0 - relatedAppsMode - 0 - - type - alfred.workflow.trigger.hotkey - uid - A7CCBBCE-F078-4780-BF5C-42D9CE64D568 - version - 2 - - - config - - action 0 - argument - 2 - focusedappvariable - - focusedappvariablename - - hotkey - 2 hotmod - 1835008 - hotstring - D + 0 leftcursor modsmode @@ -4161,7 +4363,7 @@ if (oinotify == "on") { type alfred.workflow.trigger.hotkey uid - 2FCAB39C-C693-4C37-869B-445FF6C20F9E + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 version 2 @@ -4174,14 +4376,39 @@ if (oinotify == "on") { 68 script ObjC.import('stdlib'); +console.log('Running script - oinotify') -console.log('Running script') -Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { - toValue: "{query}", +// get current setting +var oinotify = $.getenv('oinotify'); +console.log('current value: ' + oinotify) + +var title_text = 'Toggle notification' + +// new value +if (oinotify == 'on') { + oinotify = 'off' + var text = 'Disabled notifications' +} else { + oinotify = 'on' + var text = 'Enabled notifications' +} + +// change value +Application('com.runningwithcrayons.Alfred').setConfiguration("oinotify", { + toValue: oinotify, exportable: false, inWorkflow: $.getenv('alfred_workflow_bundleid'), -}); +}); +console.log('new value: ' + oinotify) + + + + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; +app.displayNotification(text, {withTitle: title_text}) scriptargtype 0 scriptfile @@ -4192,87 +4419,30 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { type alfred.workflow.action.script uid - 73853368-ED10-4729-A4D0-E231647C3CF4 + 6290B8D5-ECEB-4623-848B-E5AB92089E79 version 2 config - anchorfields - - argumenttrimmode - 0 argumenttype - 0 - daterange - 0 - fields - - - field - kMDItemDisplayName - not - - split - - value - {query} - words - - - - field - kMDItemFinderComment - not - - split - - value - {query} - words - - - - field - kMDItemTextContent - not - - split - - value - {query} - words - - - - includesystem - + 2 keyword - oinbox - limit - 0 - runningsubtext - - scopes - - sortmode - 0 + oinotify subtext - Type to search - title - Specify inbox markdown - types - + + text + Toggle notifications when adding text to inbox note. withspace - + type - alfred.workflow.input.filefilter + alfred.workflow.input.keyword uid - 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 version - 2 + 1 config @@ -4289,21 +4459,79 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { 0 hotmod 0 - hotstring + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 3B2DA9A3-761D-467C-BDD7-841584877816 + version + 2 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + keyword + oinboxtime + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script - oinboxtime') + +// options +var options = [] +options.push({title: "Append to end of note", arg: "append", uid: "append"}) +options.push({title: "Prepend to beginning of note", arg: "prepend", uid: "prepend"}) +options.push({title: "Don't add timestamp", arg: "none", uid: "none"}) + + +// list vaults +JSON.stringify({items: options}) + scriptargtype + 1 + scriptfile - leftcursor + subtext + Where to add timestamp? + title + Specify where to insert inbox timestamp + type + 7 + withspace - modsmode - 0 - relatedAppsMode - 0 type - alfred.workflow.trigger.hotkey + alfred.workflow.input.scriptfilter uid - 3B2DA9A3-761D-467C-BDD7-841584877816 + A606B9DB-2246-4459-B325-ED5831996525 version - 2 + 3 config @@ -4314,39 +4542,14 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { 68 script ObjC.import('stdlib'); -console.log('Running script - oinotify') - - -// get current setting -var oinotify = $.getenv('oinotify'); -console.log('current value: ' + oinotify) - -var title_text = 'Toggle notification' -// new value -if (oinotify == 'on') { - oinotify = 'off' - var text = 'Disabled notifications' -} else { - oinotify = 'on' - var text = 'Enabled notifications' -} +console.log('Running script') -// change value -Application('com.runningwithcrayons.Alfred').setConfiguration("oinotify", { - toValue: oinotify, +Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_timestamp", { + toValue: "{query}", exportable: false, inWorkflow: $.getenv('alfred_workflow_bundleid'), -}); -console.log('new value: ' + oinotify) - - - - -// get the current app to access the standard additions -app = Application.currentApplication(); -app.includeStandardAdditions = true; -app.displayNotification(text, {withTitle: title_text}) +}); scriptargtype 0 scriptfile @@ -4357,31 +4560,10 @@ app.displayNotification(text, {withTitle: title_text}) type alfred.workflow.action.script uid - 6290B8D5-ECEB-4623-848B-E5AB92089E79 + 83B53E1F-BC75-4636-8D79-D0229D35477F version 2 - - config - - argumenttype - 2 - keyword - oinotify - subtext - - text - Toggle notifications when adding text to inbox note. - withspace - - - type - alfred.workflow.input.keyword - uid - 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 - version - 1 - config @@ -4451,62 +4633,82 @@ app.openLocation(uri); config - alfredfiltersresults - - alfredfiltersresultsmatchmode - 0 - argumenttreatemptyqueryasnil + anchorfields argumenttrimmode 0 argumenttype - 1 - escaping - 68 + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + keyword - oinboxtime - queuedelaycustom - 3 - queuedelayimmediatelyinitially - - queuedelaymode + oadddefaultvault + limit 0 - queuemode - 1 runningsubtext - script - ObjC.import('stdlib'); -console.log('Running script - oinboxtime') - -// options -var options = [] -options.push({title: "Append to end of note", arg: "append", uid: "append"}) -options.push({title: "Prepend to beginning of note", arg: "prepend", uid: "prepend"}) -options.push({title: "Don't add timestamp", arg: "none", uid: "none"}) - - -// list vaults -JSON.stringify({items: options}) - scriptargtype - 1 - scriptfile - + scopes + + sortmode + 0 subtext - Where to add timestamp? + Type to search title - Specify where to insert inbox timestamp - type - 7 + Add your default Obsidian vault + types + + public.folder + withspace - + type - alfred.workflow.input.scriptfilter + alfred.workflow.input.filefilter uid - A606B9DB-2246-4459-B325-ED5831996525 + C6A6B247-1F7A-4075-A172-1ED04F1F2188 version - 3 + 2 config @@ -4520,10 +4722,23 @@ JSON.stringify({items: options}) console.log('Running script') -Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_timestamp", { - toValue: "{query}", - exportable: false, - inWorkflow: $.getenv('alfred_workflow_bundleid'), +// get vault name from path +var path = '{query}' +var idx = path.lastIndexOf("/") +var vaultname = path.substring(idx+1) + +//store default vault path +Application('com.runningwithcrayons.Alfred').setConfiguration('defaultVaultPath', { + toValue: path, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + +// store default vault name +Application('com.runningwithcrayons.Alfred').setConfiguration("defaultVaultName", { + toValue: vaultname, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), }); scriptargtype 0 @@ -4535,7 +4750,7 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_timestamp", type alfred.workflow.action.script uid - 83B53E1F-BC75-4636-8D79-D0229D35477F + DA9276A8-80E4-45B4-A38A-7B2FB3805943 version 2 @@ -4630,34 +4845,34 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Set up: Specify path to Obsidian app. Open Obsidian app. xpos - 305 + 300 ypos - 80 + 75 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 note Open Obsidian vault. xpos - 305 + 300 ypos - 360 + 355 08189677-1EA8-4DC2-9C09-DC2F2AF0866E note Open inbox note. xpos - 595 + 610 ypos - 2400 + 2565 08A7509B-BDA4-455E-A628-38ABF42C04D7 xpos 765 ypos - 45 + 10 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D @@ -4684,7 +4899,7 @@ If the Obsidian app isn't already opened, this workflow will always open the las xpos 780 ypos - 1595 + 1895 1BD03BB0-06B9-47F5-9346-7A829C38B248 @@ -4700,9 +4915,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Define scope based on vaults. xpos - 840 + 825 ypos - 930 + 1195 2754DF89-417E-46D0-A435-3ED58F2CB8CF @@ -4716,25 +4931,25 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Edit subtext to remind yourself of your vault names. xpos - 115 + 110 ypos - 280 + 275 2C31829D-621E-4707-B16D-5899AE7907FD xpos - 835 + 850 ypos - 2345 + 2510 2CC3DBA2-EDA4-4548-A215-611A436E43DB note os. Change settings here. xpos - 1030 + 1015 ypos - 605 + 870 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 @@ -4752,9 +4967,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Store vault name in variable. Default title can be changed here. xpos - 835 + 820 ypos - 415 + 680 2FCAB39C-C693-4C37-869B-445FF6C20F9E @@ -4790,7 +5005,7 @@ If the Obsidian app isn't already opened, this workflow will always open the las xpos 595 ypos - 95 + 60 360748C4-EF05-4FC2-8AB9-E4A969D2D256 @@ -4804,18 +5019,18 @@ If the Obsidian app isn't already opened, this workflow will always open the las note replace newline xpos - 1010 + 1005 ypos - 1950 + 2175 3B2DA9A3-761D-467C-BDD7-841584877816 note Set up: Specify hotkey to open inbox note. xpos - 595 + 610 ypos - 2225 + 2390 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 @@ -4824,9 +5039,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Store file name/title in variable. xpos - 1095 + 1080 ypos - 415 + 680 3CF13837-2DBB-46AA-93B4-6CA9598A106E @@ -4835,16 +5050,16 @@ If the Obsidian app isn't already opened, this workflow will always open the las xpos 1180 ypos - 385 + 650 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 note Define hotkey to search in vaults. xpos - 635 + 625 ypos - 1350 + 1645 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 @@ -4860,7 +5075,7 @@ If the Obsidian app isn't already opened, this workflow will always open the las xpos 615 ypos - 1560 + 1860 3F7FA866-52E3-46A9-84EE-80A4D3244647 @@ -4876,43 +5091,43 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Search for recent files (default: last 3 days) xpos - 645 + 630 ypos - 860 + 1125 44D69DBA-085D-4208-86A1-CED1CA068AB3 note Search for all files. xpos - 640 + 625 ypos - 570 + 835 46732892-62E0-47CE-B727-EBA967105197 note Define scope based on vaults. xpos - 840 + 825 ypos - 605 + 870 54B8D923-3C08-4CD2-8F05-0AF628F5C029 xpos - 110 + 105 ypos - 440 + 435 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 note or. Change settings here. xpos - 1025 + 1010 ypos - 930 + 1195 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 @@ -4953,9 +5168,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Append text to an inbox note. xpos - 615 + 610 ypos - 1820 + 2045 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 @@ -4973,18 +5188,18 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Define scope based on vaults. xpos - 815 + 800 ypos - 1230 + 1495 70AEEB77-35DB-44B9-B633-BE1D2B43D581 note Open note in Obsidian. xpos - 1275 + 1280 ypos - 925 + 1220 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC @@ -5000,9 +5215,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Set up: Configure timestamp. xpos - 1115 + 1110 ypos - 1955 + 2180 73853368-ED10-4729-A4D0-E231647C3CF4 @@ -5025,9 +5240,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note replace newline xpos - 895 + 890 ypos - 1950 + 2175 834BB1A9-B643-4448-97B4-B6B6582602CB @@ -5050,9 +5265,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Vault to create new note in. xpos - 635 + 615 ypos - 380 + 650 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C @@ -5070,9 +5285,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Title of new note. xpos - 925 + 910 ypos - 385 + 650 8C013085-6514-493F-B7AE-18E02A0961A3 @@ -5092,21 +5307,28 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 1200 + 8DC3F776-5D65-4B13-BC08-55A21B6E662A + + xpos + 820 + ypos + 515 + 9295060C-B513-4806-8F12-52EC6D30C9A3 note Define hotkey to search in vaults. xpos - 640 + 625 ypos - 700 + 965 9F656256-DD01-4508-BF9F-CDB3168DB9B6 xpos 765 ypos - 180 + 145 A606B9DB-2246-4459-B325-ED5831996525 @@ -5118,9 +5340,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las A60FCD19-F3A3-4B26-BDB2-52D548E38686 xpos - 120 + 115 ypos - 140 + 135 A70B656D-CA4C-41F9-99E3-988FB6158F5F @@ -5134,9 +5356,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Set up: Specify hotkey to append clipboard contents to inbox note. xpos - 615 + 610 ypos - 1985 + 2210 ADAB8847-A309-4A02-9D42-E8D30C47BC5D @@ -5177,18 +5399,27 @@ If the Obsidian app isn't already opened, this workflow will always open the las BDE4BB5C-ECD8-439A-B893-A9C70345010D xpos - 120 + 115 ypos - 15 + 10 C016E20E-3F44-4372-90DC-1B00DA8C07F8 note ot. Change settings here. xpos - 1020 + 1005 ypos - 1230 + 1495 + + C6A6B247-1F7A-4075-A172-1ED04F1F2188 + + note + Set up: Add the default vault. + xpos + 135 + ypos + 2625 CD6980A3-E50D-4689-B8D6-1A677CDE1914 @@ -5202,18 +5433,18 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Append text to end of note as list item. xpos - 1235 + 1230 ypos - 1910 + 2135 CEC4065E-BADA-44B7-A255-4A9D613685E2 note Define hotkey to search in vaults. xpos - 645 + 630 ypos - 1010 + 1275 D79944EC-E799-4CC4-9961-A6EBF5D6FBDC @@ -5222,6 +5453,13 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 890 + DA9276A8-80E4-45B4-A38A-7B2FB3805943 + + xpos + 315 + ypos + 2625 + DE762236-EFCC-45D3-85CA-A1B6B191762C note @@ -5254,6 +5492,13 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 735 + EB45D9BC-334F-4A40-A685-39AEE6C06B11 + + xpos + 620 + ypos + 480 + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 note @@ -5293,9 +5538,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Search for files modified today xpos - 640 + 625 ypos - 1185 + 1450 variables @@ -5316,6 +5561,10 @@ If the Obsidian app isn't already opened, this workflow will always open the las dailyvaultname + defaultVaultName + + defaultVaultPath + inbox_md inbox_timestamp @@ -5330,23 +5579,19 @@ If the Obsidian app isn't already opened, this workflow will always open the las vault2name - vault3 - - vault3name - variablesdontexport - vault3name inbox_md - vault3 dailyvaultname - oinotify - vault2 + defaultVaultName dailyabspath + oinotify + defaultVaultPath dailytodo - vault2name + vault2 dailyformat + vault2name dailytodaypath dailytempabspath dailyvault