After creating the keychain item, I pasted your script into an AppleScript Editor window, modified the three fields with the correct info for my system, compiled it, and then saved it as an app. Can't figure out why it's not working.
set py to "path/to/PlexConnect.py" set un to "username" set pw to "password"
Hi, Here's how i do it using launchctl on OSX. Works a treat, no ugly icons or anything. It launches on startup, and keeps re-trying to launch until it succeeds in connecting to PMS, so it doesn't matter if it manages to start before PMS.
First, we need to make it quit if it manages to start before PMS, so launchctl can retry in 10s. Open up PlexGDM.py and search for the line 'No servers discovered'. Insert a line below this, at the same indentation, and add: sys.exit(1)
Next, we need to make it work without any access to the keyboard. Open up PlexConnect.py, look for the line that says 'try:', and delete this line *and every other line after it*. Don't worry, all you're removing is the ability for it to cleanly shut down if the user presses a key.
I was wondering, will your solution allow the mac to sleep? I was going to follow your instructions and couldn't find the exact string "No servers discovered, shutting down". I have the latest version of plexconnect, I think. It made me realise i'd probably have to do this for every new version. So I'll start manually for a while till there are less new versions
Anyway, I really want the Mac to sleep when idle. I only use it as media centre and leaving terminal open keeps the Mac awake.
So wouldn't it be a good idea to merge all this into one piece of code? Would be great to run this and plexconnect "as a service" in windows terms (As it would for PMS as well) So that brings me to the next question, does it require logon for the script to run? (i am not an osx expert, just use it as a media server.)
Patience. The developers will be turning Plexconnect into an app or something when they have finished the early development work. The Applescript can be used till then.
Also, follow the instructions on page one. It tells you how to deal with login.
Yes that is what I said in my post before my last one. I'll just wait for a while. Things are going fast and I hope all good ideas will be consolidated. (like ensuring this loophole won't be closed. I don't know if it could because of the nature of it, but that'd be a shame)
Hi, Here's how i do it using launchctl on OSX. Works a treat, no ugly icons or anything. It launches on startup, and keeps re-trying to launch until it succeeds in connecting to PMS, so it doesn't matter if it manages to start before PMS.
First, we need to make it quit if it manages to start before PMS, so launchctl can retry in 10s. Open up PlexGDM.py and search for the line 'No servers discovered, shutting down'. Insert a line below this, at the same indentation, and add: sys.exit(1)
Next, we need to make it work without any access to the keyboard. Open up PlexConnect.py, look for the line that says 'try:', and delete this line *and every other line after it*. Don't worry, all you're removing is the ability for it to cleanly shut down if the user presses a key.
Next, create com.plex.plexconnect.plist with the following contents: https://gist.github.com/chrishulbert/5772931
Edit this file, changing the *two* instances of 'Users/chris/PlexConnect' to the correct folder that you've installed PlexConnect in.
Finally, go into the terminal, change into your plex connect folder, and do the following:
Chris I am guessing the benefit of this is that, because you are launching the script as root, you are removing the need for any interaction at all and yet do not open up any potential security holes like the AppleScript.
What about if it crashes, will it try and automatically relaunch the script?
Chris I am guessing the benefit of this is that, because you are launching the script as root, you are removing the need for any interaction at all and yet do not open up any potential security holes like the AppleScript.
What about if it crashes, will it try and automatically relaunch the script?
Hi, firstly - thanks for making PlexConnect so awesome. Where do i send the beer money?
Yes, when it crashes LaunchCtl automatically restarts it in 10 seconds. I take advantage of that fact by making it crash (sys.exit) if it cannot connect to a PMS server. This gets around the problem of PC trying to start before PMS has a chance to start - PC simply crashes out and retries every 10s until it can connect.
@robertz - sorry, was a typo. Search for 'No servers discovered'. I added the 'shutting down' myself and forgot it's not in the original source.
Also i'm not sure if this will prevent the mac from sleeping. I'm pretty sure it won't - i've made plenty of launchctl scripts in the past and my mac always sleeps happily.
Finally, this won't need a logon to run, because it's a LaunchDaemon - these run without login.
If the developers are happy, i'd be able to do a github pull request with this plist included, along with a script to install and launch it, would you guys be interested? Then it'd just be a matter of changing to the PlexConnect folder, and doing something along the lines of sudo ./install.py or something.
If the developers are happy, i'd be able to do a github pull request with this plist included, along with a script to install and launch it, would you guys be interested? Then it'd just be a matter of changing to the PlexConnect folder, and doing something along the lines of sudo ./install.py or something.
Let me speak with Baa and Roidy but personally I see this as a good approach for OSX (it removes the sudo issue without storing the password, gets rid of the launching to early after boot issue, relaunches if it crashes and will shut down when the device does.
In terms of beer money we are sorting something out but it was'nt really the motivation.
Your pull request with an install script/first run app does sound good though :)
I followed your instructions to the letter. However with the command: sudo launchctl start com.plex.plexconnect.plist I get an error that says: "launchctl start error: No such process". I rechecked everything, but no luck. Any thoughts?
I followed your instructions to the letter. However with the command: sudo launchctl start com.plex.plexconnect.plist I get an error that says: "launchctl start error: No such process". I rechecked everything, but no luck. Any thoughts?
Hi
I had the same error and found that when i ran the following command it worked.
I would also like to confirm that this solution allows the mac mini to sleep. So that is an important difference compared to leaving a terminal windows open. Now let's do this for PMS as well, so we don't have to login.
I couldn't get it to work with the installer script running the launchctl load and launchctl start steps, python isn't my thing, so i just print those steps to output for the user to perform for now, feel free to improve it.