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
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]
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:
- specify the full path to the mpc executable, or
- export the path to the folder containing the executable – see the last couple of posts in this thread, for example: Path to excutables in shell scripts
Another possibility – which is only mentioned very briefly in this Wiki article – is to set the
You can do this in KM Editor > Preferences > Variables. For example:
Since all KM variables are global, this will affect every shell script action.
- 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
- 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”).
Excellent points, @Tom. I will update the Wiki later today to add your discussion, and to correct the spelling error.