├── 1FF4A0D8-A064-4004-B733-48DD05D3FD1C.png ├── README.md ├── devonsearch.js ├── icon.png ├── info.plist ├── ss1.png └── ss2.png /1FF4A0D8-A064-4004-B733-48DD05D3FD1C.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dvcrn/alfred-devonthink/d55e66c52fdcab89eca84d2238156f52362536b5/1FF4A0D8-A064-4004-B733-48DD05D3FD1C.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alfred-devonthink 2 | 3 | Simple Alfred workflow for interacting with DEVONthink 4 | 5 | ![screenshot1](ss1.png) 6 | ![screenshot2](ss2.png) 7 | 8 | 9 | ## Usage 10 | 11 | - `ds` to search DEVONthink 12 | - `dn` to create a new DEVONthink note 13 | 14 | This workflow also provides a 'Import to DEVONthink' file action for quickly adding files to the DEVONthink inbox 15 | 16 | ## Installing 17 | 18 | Download the latest release [here](https://github.com/dvcrn/alfred-devonthink/releases). 19 | 20 | The workflow will auto-update itself if a new version becomes available. (You can disable this by deleting the 'Auto Update' node) 21 | -------------------------------------------------------------------------------- /devonsearch.js: -------------------------------------------------------------------------------- 1 | const devonthink = Application('DEVONthink 3'); 2 | 3 | const MAX_RESULTS_PER_DB = 5; 4 | 5 | function doSearch(db, query) { 6 | results = devonthink.search(query, { 7 | in: db.root(), 8 | }); 9 | 10 | if (results.length == 0) { 11 | return []; 12 | } 13 | 14 | const parsed = []; 15 | for (var result in results) { 16 | const current = results[result]; 17 | parsed.push({ 18 | name: current.name(), 19 | id: current.uuid(), 20 | databaseName: current.database().name(), 21 | url: current.referenceURL(), 22 | path: current.path(), 23 | location: current.location(), 24 | score: current.score(), 25 | }); 26 | 27 | if (parsed.length >= MAX_RESULTS_PER_DB) { 28 | break; 29 | } 30 | } 31 | 32 | 33 | return parsed; 34 | } 35 | 36 | 37 | function run(argv) { 38 | const query = argv[0]; 39 | const dbs = devonthink.databases(); 40 | let results = []; 41 | for (const db of dbs) { 42 | results = results.concat(doSearch(db, query)); 43 | } 44 | 45 | results.sort(function(a, b) { 46 | return b.score - a.score; 47 | }) 48 | 49 | const items = results.map(function(element) { 50 | return { 51 | title: element.name, 52 | subtitle: `Found in ${element.databaseName}${element.location}, score ${element.score}`, 53 | arg: element.url, 54 | icon: { 55 | type: "fileicon", 56 | path: element.path, 57 | } 58 | } 59 | }); 60 | 61 | if (items.length === 0) { 62 | items.push({ 63 | title: "No Results", 64 | uid: "no-results", 65 | }); 66 | } 67 | 68 | return JSON.stringify({ 69 | "items": items, 70 | }) 71 | } 72 | 73 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dvcrn/alfred-devonthink/d55e66c52fdcab89eca84d2238156f52362536b5/icon.png -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bundleid 6 | com.davidmohl.alfred-devonthink 7 | category 8 | Productivity 9 | connections 10 | 11 | 07E9E886-9639-45F6-89D0-B1698867A56B 12 | 13 | 14 | destinationuid 15 | FDB1AD51-2E3D-4BB2-9243-505A18B14669 16 | modifiers 17 | 0 18 | modifiersubtext 19 | 20 | vitoclose 21 | 22 | 23 | 24 | 1FF4A0D8-A064-4004-B733-48DD05D3FD1C 25 | 26 | 27 | destinationuid 28 | 530F6D0F-EA3D-43E8-ADCA-402884078611 29 | modifiers 30 | 0 31 | modifiersubtext 32 | 33 | vitoclose 34 | 35 | 36 | 37 | 530F6D0F-EA3D-43E8-ADCA-402884078611 38 | 39 | 40 | destinationuid 41 | A7792F33-F7F4-4115-A21E-9AB958781F3E 42 | modifiers 43 | 0 44 | modifiersubtext 45 | 46 | vitoclose 47 | 48 | 49 | 50 | 850FB534-05A4-4F83-ABBE-88EF4C096611 51 | 52 | 53 | destinationuid 54 | 703C7AAB-A520-4AAB-9851-E4C55003D55A 55 | modifiers 56 | 0 57 | modifiersubtext 58 | 59 | vitoclose 60 | 61 | 62 | 63 | 97645B64-B4E8-49C3-9E6B-21A8864FA677 64 | 65 | 66 | destinationuid 67 | CE762379-94F7-4E23-A945-478CA2F1863B 68 | modifiers 69 | 0 70 | modifiersubtext 71 | 72 | vitoclose 73 | 74 | 75 | 76 | 99937B9B-A22A-4C33-A568-B8991CA29CC3 77 | 78 | 79 | destinationuid 80 | 703C7AAB-A520-4AAB-9851-E4C55003D55A 81 | modifiers 82 | 0 83 | modifiersubtext 84 | 85 | vitoclose 86 | 87 | 88 | 89 | A7792F33-F7F4-4115-A21E-9AB958781F3E 90 | 91 | 92 | destinationuid 93 | 99937B9B-A22A-4C33-A568-B8991CA29CC3 94 | modifiers 95 | 0 96 | modifiersubtext 97 | 98 | vitoclose 99 | 100 | 101 | 102 | C0E15750-B925-43DB-AAA4-B92841B228C6 103 | 104 | 105 | destinationuid 106 | 07E9E886-9639-45F6-89D0-B1698867A56B 107 | modifiers 108 | 0 109 | modifiersubtext 110 | 111 | vitoclose 112 | 113 | 114 | 115 | CE762379-94F7-4E23-A945-478CA2F1863B 116 | 117 | 118 | destinationuid 119 | 850FB534-05A4-4F83-ABBE-88EF4C096611 120 | modifiers 121 | 0 122 | modifiersubtext 123 | 124 | vitoclose 125 | 126 | 127 | 128 | DE0ECC8F-C656-43CB-BC23-C7E859B2BFD1 129 | 130 | 131 | destinationuid 132 | 703C7AAB-A520-4AAB-9851-E4C55003D55A 133 | modifiers 134 | 0 135 | modifiersubtext 136 | 137 | vitoclose 138 | 139 | 140 | 141 | FDB1AD51-2E3D-4BB2-9243-505A18B14669 142 | 143 | 144 | destinationuid 145 | DE0ECC8F-C656-43CB-BC23-C7E859B2BFD1 146 | modifiers 147 | 0 148 | modifiersubtext 149 | 150 | vitoclose 151 | 152 | 153 | 154 | 155 | createdby 156 | David Mohl 157 | description 158 | Create a note in DEVONthink 159 | disabled 160 | 161 | name 162 | DEVONthink 163 | objects 164 | 165 | 166 | config 167 | 168 | concurrently 169 | 170 | escaping 171 | 68 172 | script 173 | on run argv set theQuery to item 1 of argv tell application id "DNtp" create record with {name:theQuery, type:text, content:theQuery} in inbox end tell end run 174 | scriptargtype 175 | 1 176 | scriptfile 177 | 178 | type 179 | 6 180 | 181 | type 182 | alfred.workflow.action.script 183 | uid 184 | A7792F33-F7F4-4115-A21E-9AB958781F3E 185 | version 186 | 2 187 | 188 | 189 | config 190 | 191 | lastpathcomponent 192 | 193 | onlyshowifquerypopulated 194 | 195 | removeextension 196 | 197 | text 198 | > {var:input} 199 | title 200 | New DEVONthink Note 201 | 202 | type 203 | alfred.workflow.output.notification 204 | uid 205 | 99937B9B-A22A-4C33-A568-B8991CA29CC3 206 | version 207 | 1 208 | 209 | 210 | config 211 | 212 | argumenttype 213 | 0 214 | keyword 215 | dn 216 | subtext 217 | > {query} 218 | text 219 | Create DEVONthink Note 220 | withspace 221 | 222 | 223 | type 224 | alfred.workflow.input.keyword 225 | uid 226 | 1FF4A0D8-A064-4004-B733-48DD05D3FD1C 227 | version 228 | 1 229 | 230 | 231 | config 232 | 233 | argument 234 | {query} 235 | passthroughargument 236 | 237 | variables 238 | 239 | input 240 | {query} 241 | 242 | 243 | type 244 | alfred.workflow.utility.argument 245 | uid 246 | 530F6D0F-EA3D-43E8-ADCA-402884078611 247 | version 248 | 1 249 | 250 | 251 | config 252 | 253 | acceptsmulti 254 | 255 | filetypes 256 | 257 | name 258 | Import to DEVONthink 259 | 260 | type 261 | alfred.workflow.trigger.action 262 | uid 263 | C0E15750-B925-43DB-AAA4-B92841B228C6 264 | version 265 | 1 266 | 267 | 268 | config 269 | 270 | concurrently 271 | 272 | escaping 273 | 68 274 | script 275 | on run argv set theQuery to item 1 of argv tell application id "DNtp" import theQuery to inbox end tell end run 276 | scriptargtype 277 | 1 278 | scriptfile 279 | 280 | type 281 | 6 282 | 283 | type 284 | alfred.workflow.action.script 285 | uid 286 | FDB1AD51-2E3D-4BB2-9243-505A18B14669 287 | version 288 | 2 289 | 290 | 291 | config 292 | 293 | concurrently 294 | 295 | escaping 296 | 102 297 | script 298 | # Based On The OneUpdater workflow, but heavily simplified for github releases 299 | # https://github.com/vitorgalvao/alfred-workflows/tree/master/OneUpdater 300 | 301 | # THESE VARIABLES MUST BE SET. 302 | readonly github_repo='dvcrn/alfred-devonthink' 303 | readonly frequency_check='1' # days 304 | 305 | # FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED! 306 | readonly info_plist='info.plist' 307 | 308 | function abort { 309 | echo "${1}" >&2 310 | exit 1 311 | } 312 | 313 | function notification { 314 | osascript -e "display notification \"${1}\" with title \"${alfred_workflow_name}\" subtitle \"A new version is available\"" 315 | } 316 | 317 | function fetch_remote_version { 318 | curl --silent "https://api.github.com/repos/${github_repo}/releases/latest" | grep 'tag_name' | head -1 | sed -E 's/.*tag_name": "v?(.*)".*/\1/' 319 | } 320 | 321 | function fetch_download_url { 322 | curl --silent "https://api.github.com/repos/${github_repo}/releases/latest" | grep 'browser_download_url.*\.alfredworkflow"' | head -1 | sed -E 's/.*browser_download_url": "(.*)".*/\1/' 323 | } 324 | 325 | function download_and_install { 326 | readonly tmpfile="$(mktemp).alfredworkflow" 327 | notification 'Downloading and installing…' 328 | curl --silent --location --output "${tmpfile}" "${1}" 329 | open "${tmpfile}" 330 | } 331 | 332 | # Local sanity checks 333 | [[ -n "${alfred_workflow_version}" ]] || abort "'alfred_workflow_version' must be set." 334 | [[ -n "${alfred_workflow_name}" ]] || abort "'alfred_workflow_name' must be set." 335 | [[ "${github_repo}" =~ ^.+\/.+$ ]] || abort "'github_repo' (${github_repo}) must be in the format 'username/repo'." 336 | [[ "${frequency_check}" =~ ^[0-9]+$ ]] || abort "'frequency_check' (${frequency_check}) must be a number." 337 | 338 | # Check for updates 339 | if [[ $(find "${info_plist}" -mtime +"${frequency_check}"d) ]]; then 340 | if [[ "${alfred_workflow_version}" == "$(fetch_remote_version)" ]]; then 341 | touch "${info_plist}" # Reset timer by touching local file 342 | exit 0 343 | fi 344 | 345 | download_and_install "$(fetch_download_url)" 346 | fi 347 | scriptargtype 348 | 1 349 | scriptfile 350 | 351 | type 352 | 0 353 | 354 | type 355 | alfred.workflow.action.script 356 | uid 357 | 703C7AAB-A520-4AAB-9851-E4C55003D55A 358 | version 359 | 2 360 | 361 | 362 | config 363 | 364 | lastpathcomponent 365 | 366 | onlyshowifquerypopulated 367 | 368 | removeextension 369 | 370 | text 371 | > {var:input} 372 | title 373 | Copied To DEVONthink 374 | 375 | type 376 | alfred.workflow.output.notification 377 | uid 378 | DE0ECC8F-C656-43CB-BC23-C7E859B2BFD1 379 | version 380 | 1 381 | 382 | 383 | config 384 | 385 | argument 386 | {query} 387 | passthroughargument 388 | 389 | variables 390 | 391 | input 392 | {query} 393 | 394 | 395 | type 396 | alfred.workflow.utility.argument 397 | uid 398 | 07E9E886-9639-45F6-89D0-B1698867A56B 399 | version 400 | 1 401 | 402 | 403 | config 404 | 405 | action 406 | 0 407 | argument 408 | 0 409 | focusedappvariable 410 | 411 | focusedappvariablename 412 | 413 | hotkey 414 | 44 415 | hotmod 416 | 1835008 417 | hotstring 418 | / 419 | leftcursor 420 | 421 | modsmode 422 | 0 423 | relatedAppsMode 424 | 0 425 | 426 | type 427 | alfred.workflow.trigger.hotkey 428 | uid 429 | 97645B64-B4E8-49C3-9E6B-21A8864FA677 430 | version 431 | 2 432 | 433 | 434 | config 435 | 436 | browser 437 | 438 | spaces 439 | 440 | url 441 | {query} 442 | utf8 443 | 444 | 445 | type 446 | alfred.workflow.action.openurl 447 | uid 448 | 850FB534-05A4-4F83-ABBE-88EF4C096611 449 | version 450 | 1 451 | 452 | 453 | config 454 | 455 | alfredfiltersresults 456 | 457 | alfredfiltersresultsmatchmode 458 | 0 459 | argumenttreatemptyqueryasnil 460 | 461 | argumenttrimmode 462 | 0 463 | argumenttype 464 | 0 465 | escaping 466 | 68 467 | keyword 468 | ds 469 | queuedelaycustom 470 | 3 471 | queuedelayimmediatelyinitially 472 | 473 | queuedelaymode 474 | 1 475 | queuemode 476 | 2 477 | runningsubtext 478 | Searching DEVONthink for '{query}'... 479 | script 480 | osascript ./devonsearch.js "{query}" 481 | 482 | 483 | scriptargtype 484 | 0 485 | scriptfile 486 | ./devonsearch.sh 487 | subtext 488 | Search DEVONthink databases 489 | title 490 | DEVONthink Search 491 | type 492 | 0 493 | withspace 494 | 495 | 496 | type 497 | alfred.workflow.input.scriptfilter 498 | uid 499 | CE762379-94F7-4E23-A945-478CA2F1863B 500 | version 501 | 3 502 | 503 | 504 | readme 505 | # alfred-devonthink 506 | 507 | Simple Alfred workflow for interacting with DEVONthink 508 | 509 | 510 | ## Usage 511 | 512 | - `ds` to search DEVONthink 513 | - `dn` to create a new DEVONthink note 514 | 515 | This workflow also provides a 'Import to DEVONthink' file action for quickly adding files to the DEVONthink inbox 516 | 517 | ## Installing 518 | 519 | Download the latest release [here](https://github.com/dvcrn/alfred-devonthink/releases). 520 | 521 | The workflow will auto-update itself if a new version becomes available. (You can disable this by deleting the 'Auto Update' node) 522 | uidata 523 | 524 | 07E9E886-9639-45F6-89D0-B1698867A56B 525 | 526 | xpos 527 | 340 528 | ypos 529 | 390 530 | 531 | 1FF4A0D8-A064-4004-B733-48DD05D3FD1C 532 | 533 | xpos 534 | 140 535 | ypos 536 | 210 537 | 538 | 530F6D0F-EA3D-43E8-ADCA-402884078611 539 | 540 | xpos 541 | 340 542 | ypos 543 | 240 544 | 545 | 703C7AAB-A520-4AAB-9851-E4C55003D55A 546 | 547 | note 548 | Auto Update - remove to disable 549 | xpos 550 | 920 551 | ypos 552 | 360 553 | 554 | 850FB534-05A4-4F83-ABBE-88EF4C096611 555 | 556 | xpos 557 | 430 558 | ypos 559 | 500 560 | 561 | 97645B64-B4E8-49C3-9E6B-21A8864FA677 562 | 563 | xpos 564 | 10 565 | ypos 566 | 390 567 | 568 | 99937B9B-A22A-4C33-A568-B8991CA29CC3 569 | 570 | xpos 571 | 600 572 | ypos 573 | 210 574 | 575 | A7792F33-F7F4-4115-A21E-9AB958781F3E 576 | 577 | xpos 578 | 430 579 | ypos 580 | 210 581 | 582 | C0E15750-B925-43DB-AAA4-B92841B228C6 583 | 584 | xpos 585 | 140 586 | ypos 587 | 360 588 | 589 | CE762379-94F7-4E23-A945-478CA2F1863B 590 | 591 | note 592 | Search 593 | xpos 594 | 140 595 | ypos 596 | 500 597 | 598 | DE0ECC8F-C656-43CB-BC23-C7E859B2BFD1 599 | 600 | xpos 601 | 600 602 | ypos 603 | 360 604 | 605 | FDB1AD51-2E3D-4BB2-9243-505A18B14669 606 | 607 | xpos 608 | 430 609 | ypos 610 | 360 611 | 612 | 613 | variablesdontexport 614 | 615 | version 616 | 1.4.3 617 | webaddress 618 | https://twitter.com/davicorn 619 | 620 | 621 | -------------------------------------------------------------------------------- /ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dvcrn/alfred-devonthink/d55e66c52fdcab89eca84d2238156f52362536b5/ss1.png -------------------------------------------------------------------------------- /ss2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dvcrn/alfred-devonthink/d55e66c52fdcab89eca84d2238156f52362536b5/ss2.png --------------------------------------------------------------------------------