mpc pause
is a command I can use to pause music playing through mpd. I installed mpc with homebrew.
I’m trying to make a hotkey execute it.
/var/folders/gq/6w_g87qd7b14pk6bx8mr41xw0000gn/T/Keyboard-Maestro-Script-3D1C27A2-713E-4503-9DA6-8FB277A92673: line 1: mpc: command not found
is the output I get. If I make a .sh file with mpc pause it gives me this:
/Users/Jnny/Desktop/pause.sh: line 3: mpc: command not found
Why?
1 Like
The environment provided by the KM "Execute Shell Script" is quite different from the Terminal app.
See action:Execute a Shell Script [Keyboard Maestro Wiki]
Gorilla_Dunk:
Why?
As the search paths in your Terminal environment are not automatically exported to the shell environment created for an KM Execute Shell Script action, you need to either:
Tom
November 7, 2016, 1:58pm
4
Another possibility – which is only mentioned very briefly in this Wiki article – is to set the ENV_PATH
variable.
You can do this in KM Editor > Preferences > Variables . For example:
Since all KM variables are global, this will affect every shell script action.
Advantages:
Reduces clutter in the shell script actions
While still being separated from your Terminal environment, it’s easy to keep the paths in sync with it
If you add a new preferred path (or change the order), all script actions adopt it automatically
You can always override it by specifying a full path in an action
Disadvantages:
Less portable when distributing macros (but portability is always limited when command line tools are involved)
--> Concerning the Wiki:
I found it mentioned also in the Troubleshooting article , but the variable name is not spelled correctly there (“ENVPATH” instead of “ENV_PATH”).
6 Likes
Excellent points, @Tom . I will update the Wiki later today to add your discussion, and to correct the spelling error.
2 Likes
Still works in 2024! I tried sourcing my shell's env file and it still had problems. ENV_PATH works, though.
I didn't know about this one. Will try it. it might help me a lot .