So I am trying to add a login item from the terminal and I am using this line:
osascript -e 'tell application "System Events" to make login item at end with properties {path:/Users/me/Desktop/main, hidden:true}'
But the thing is I want the main
file to add itself to the login items meaning that the path of main
may change so I want the path to be a variable like this:
cd "$(dirname "$0")"
STR="$(dirname "$0")"
osascript -e 'tell application "System Events" to make login item at end with properties {path:$STR, hidden:true}'
sudo python3 main.py
But this gives me a bunch of syntax errors, is there another way to use a variable for the path?
Thanks