Search code examples
shellterminalapplescriptbrightness

applescript do shell command "command not found"


I am new to applescript and command line tools. I installed a command line tool to control the brightness of the iMac in Terminal. I installed the following: https://github.com/nriley/brightness

After installing, I noticed a new exec file in /usr/local/bin/ called "brightness".

The Internet told me, that applescript only knows the command lines found in /bin/sh. "brightness" is not found there, and I can't copy the exec file to this directory. So it makes sense, that I get the error "sh: brightness: command not found", when executing the following applescript:

do shell script "brightness 0.7"

Now the big question, what do I have to do in order to get the shell command working? In Terminal, the command works fine. I know I could do the following:

tell application "Terminal"
activate
end tell
tell application "System Events"
    keystroke "brightness 0.7"
    keystroke return
end tell

But this always makes the terminal window active, and I want to run the command silently.

I am glad for detailed instructions. I searched the internet for days, but hey, I am a beginner.


Solution

  • Provide the full path

    do shell script "/usr/local/bin/brightness 0.7"