Alfred - Obsidian Utilities

Thank you for the kind words. That was actually the first action I created, the first that I felt a real need for.

2 Likes

Hi @macedotavares, I keep running into this error when I hit enter on Alfred

image
image

Any idea where am I going wrong? Here are how my variables look.

image

Would appreciate any help. Thank you for your time.

Hi, @pralayb. Which version of the workflow are you using? I don’t know what’s causing that, but from v2.0.0, an absolute path is required. In your case, that would be /Users/pralaybiswas/Documents/pralayb (or ~/Documents/pralayb).

Hello @macedotavares, thank you for your response - installation of the newest version allows me to create a journal entry and everything else, but it does not allow me to search, The Alfred debugger logs show this, when I try to search something (I searched for a text “Rally”).

indent preformatted text by 4 spaces 

[09:36:31.502] ERROR: Obsidian Utilities[Script Filter] Code 1: Traceback (most recent call last):
File “/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind.py”, line 4, in
import os, json, sys, mdfind
File “/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind/init.py”, line 4, in
import runcmd
File “/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/runcmd/init.py”, line 6, in
import psutil
File “/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/init.py”, line 121, in
from . import _psosx as _psplatform
File “/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/_psosx.py”, line 15, in
from . import _psutil_osx as cext
ImportError: cannot import name ‘_psutil_osx’ from partially initialized module ‘psutil’ (most likely due to a circular import) (/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/init.py)

Would really appreciate some help (and am sorry for bothering you again).

You’re not bothering me at all. You’re helping me debug. :smiley:
There’s already an open issue on Github regarding this, but maybe you could help me out:

  1. If you double-click the script filter module in that action, you’ll see a reference to mdfind.py. That’s the Python script doing all the work.

  2. Click on the Open File button next to it. The very first line reads #!/usr/bin/python3. Please replace that line with #!/usr/bin/env python3 and save the changes.

  3. Try running the action. Does it work? If it still doesn’t, please send me the logs again.

Cheers!

I genuinely appreciate your help with this.

Here are the code changes as you suggested:

Here are my env vars (in case they are of interest, and if I am just making a blunder somewhere)

image

And here is the log which seems to indicate that I am still running into the same issue:

[10:52:07.490] Obsidian Utilities[Script Filter] Queuing argument 'rall'
[10:52:07.537] Obsidian Utilities[Script Filter] Script with argv 'ral' finished
[10:52:07.542] ERROR: Obsidian Utilities[Script Filter] Code 1: Traceback (most recent call last):
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind.py", line 5, in <module>
    import os, json, sys, mdfind
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind/__init__.py", line 4, in <module>
    import runcmd
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/runcmd/__init__.py", line 6, in <module>
    import psutil
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/__init__.py", line 121, in <module>
    from . import _psosx as _psplatform
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/_psosx.py", line 15, in <module>
    from . import _psutil_osx as cext
ImportError: cannot import name '_psutil_osx' from partially initialized module 'psutil' (most likely due to a circular import) (/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/__init__.py)
[10:52:07.713] Obsidian Utilities[Script Filter] Script with argv 'rall' finished
[10:52:07.722] ERROR: Obsidian Utilities[Script Filter] Code 1: Traceback (most recent call last):
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind.py", line 5, in <module>
    import os, json, sys, mdfind
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind/__init__.py", line 4, in <module>
    import runcmd
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/runcmd/__init__.py", line 6, in <module>
    import psutil
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/__init__.py", line 121, in <module>
    from . import _psosx as _psplatform
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/_psosx.py", line 15, in <module>
    from . import _psutil_osx as cext
ImportError: cannot import name '_psutil_osx' from partially initialized module 'psutil' (most likely due to a circular import) (/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/__init__.py)
[10:52:07.727] Obsidian Utilities[Script Filter] Queuing argument 'rally'
[10:52:07.834] Obsidian Utilities[Script Filter] Script with argv 'rally' finished
[10:52:07.843] ERROR: Obsidian Utilities[Script Filter] Code 1: Traceback (most recent call last):
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind.py", line 5, in <module>
    import os, json, sys, mdfind
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/mdfind/__init__.py", line 4, in <module>
    import runcmd
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/runcmd/__init__.py", line 6, in <module>
    import psutil
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/__init__.py", line 121, in <module>
    from . import _psosx as _psplatform
  File "/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/_psosx.py", line 15, in <module>
    from . import _psutil_osx as cext
ImportError: cannot import name '_psutil_osx' from partially initialized module 'psutil' (most likely due to a circular import) (/Users/pralayb/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2D451AF0-B5D7-4758-91D6-B76D1F916624/psutil/__init__.py)

Here is my python version (seems to be on PATH):

image

You’re doing nothing wrong. There’s something going on with a dependency, probably mdfind, and I’ll have to figure it out.
Just to be clear:

  1. Your macOS is a recent version, with Python 3 installed, right? That’s the version needed for the workflow.
  2. The other actions work, namely Cmd+Shift+L?
  1. Cmd+Shift+ L when the editor is active seems to work as expected

  1. Python versions

image

  1. MacOSX version

image
image

:slightly_frowning_face:

Awesome feedback. Thank you very much for all the work and patience. The ball is on my court, now. I’ll do my best to fix this quickly and I’ll let you now as soon as I push a new release. Cheers!

Hi there, first I have to thank you really for this Workflow.

I am relative new to Alfred (and Obsidian), so I hope, this is a really simple question.

I love the “clip” function, but I use Firefox instead of Safari. I tried to change the Apple Script in the Workflow from Safari to Firefox (simple replace the words), but this does not work as expected. The clip command still takes the safari page, and not the firefox page. I have no idea of apple scripting, so this was a naiv try :wink:

Maybe someone can help me, to switch the clip Function to Firefox (I’m working with severel different Computers and OS, and I am used to Firefox, so I do not want to migrate to safari.).

Thx for your help.

Greetings from Germany.

Hi!

Currently, the workflow only supports Safari or Chrome, and that choice is made in the workflow Environment Variables pane (the [x] on the top right corner).

Each browser has its own way of exposing its API to AppleScript. Some may not do it at all. I’ll look into it and if I find a solution I’ll include it in the next release. I’ll keep you posted.

Cheers!

Wow thank you @macedotavares

It’s now available in the latest release. It’s flaky at best, because Firefox doesn’t support AppleScript, but it’s the best I can do. It relies on simulated keystrokes and delays :expressionless:.
Let me know how it goes.

1 Like

Hi @macedotavares,

First of all, thanks for this amazing connection between Alfred and Obsidian. It really helps me to decrease the friction to add notes to my journal and quickly add tasks. About the tasks, I just want to mention I had to update my XCode commandline utils for the Python script to work correctly.
When I added a task, it never got into my todo-file. So I examined the Python file to figure what should be happening.
In the debug screen I saw a mention of xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) what got me on the trail of XCode. All I had to do was reset Xcode in terminal with the command sudo xcode-select --reset so the correct version of XCode would be uses. I assume.
Anyhow, everything works fine now. I hope this helps other users in the future who get similar errors in the debug screen.

1 Like

I just tested the clip-action on Firefox. It does work but yes, to be honest, it is a bit flaky. One other thing in the latest release is it overwrites my small tweaks I did in your scripts. For instance, I don’t like the horizontal lines in the snippets for my daily notes. I’d rather have a list. I know these could be configurable in a future version. I might take a shot at it someday to make a branch of your Github and see if I can help out here if you want?

Oh yes, by all means — please do!

I knew that people were making changes to the way the entries are composed, and I knew that these tweaks would be overwritten by any update, but I never thought of making them persistent.

See you on GitHub :smiley:

This is very good to know. Thanks!

How might I modify the daily note name to my system Medium date format?

My osx system date format is y-MM-dd_EEE. I use that to create my daily note filenames. Your amazing utility wants to use y-MM-dd to create or update daily note. How might I change the script to add the _EEE so that my daily note files are daily_notes/2020-01-21_Thu, for example?

thanks in advance!

Alfred allows you to customize the {date} placeholder with Unicode formats.

Those placeholders are present in a lot of actions throughout the workflow. I can’t be sure right now, but I believe that all of them are exposed (i.e. outside of any script), so they’ll be relatively easy to find and tweak.

Anyway, I’m telling you this so that you can get to work immediately, but I’ll be able to assist you further, tomorrow, if you need.

Cheers!

I’m trying to get the new 2.2.1 “related” workflow to work, but it’s unclear to me how to launch the workflow, after I’ve inserted /related into a note. The instructions are a bit cryptic. Simply typing this phrase in a note and then waiting doesn’t seem to do anything.

  • Type /related anywere on your note and the workflow will insert a list of related notes, based on content similarity.