Home › Forums › OS X Server and Client Discussion › Questions and Answers › launchd & plist problem…
- This topic has 7 replies, 5 voices, and was last updated 15 years ago by
cpakhale.
-
AuthorPosts
-
April 5, 2010 at 7:23 am #378345
nemonada
ParticipantGreetings;
I have a plist setup with ‘WatchPaths’ set to ~/Library/Preferences. When it runs, I get the message “~/Library/Preferences” cannot be found. If I put the WatchPaths to (for example) “/Users/administrator/Library/Preferences” then everything works fine.
How can I get the plist to recoginize the ‘~’ for currently logged on user? Or is there another way to designate the logged on user’s directory w/o spelling it out for each users?
I’ve tried setting ‘WorkingDirectory’ to $HOME but that generates the following: “Bug: launchd_core_logic.c:3119 (23923):2: chdir(j->workingdir) != -1”
Also tried using the ‘EnvironmentVariables’ key but couldn’t come up w/a way that that would work either?
The goal here is to monitor the screensaver settings and set the idleTime to a certain value, even if the user changes it. I can use WGM to lock the askForPassword value but there doesn’t seem to be anyway to lock the idleTime (which would solve the whole problem).
Suggestions???? Please…
April 5, 2010 at 5:44 pm #378348Greg Neagle
Participant[QUOTE][u]Quote by: nemonada[/u][p]Greetings;
I have a plist setup with ‘WatchPaths’ set to ~/Library/Preferences. When it runs, I get the message “~/Library/Preferences” cannot be found. If I put the WatchPaths to (for example) “/Users/administrator/Library/Preferences” then everything works fine.
How can I get the plist to recoginize the ‘~’ for currently logged on user? Or is there another way to designate the logged on user’s directory w/o spelling it out for each users?[/QUOTE]
Nope. File an enhancement request with Apple.
[QUOTE][
The goal here is to monitor the screensaver settings and set the idleTime to a certain value, even if the user changes it. I can use WGM to lock the askForPassword value but there doesn’t seem to be anyway to lock the idleTime (which would solve the whole problem).Suggestions???? Please…[/p][/QUOTE]
Best you can do currently is run on a set schedule (every 5 mins, every 15 mins, whatever, check the value, and reset it if needed.) Or manage it ‘often’, realizing that if the user changes it, it won’t be reset until the next login.
-Greg
April 7, 2010 at 2:07 am #378355bschappel
ParticipantIt’s not a super elegant solution but you could write a loginhook that unloads the daemon, rewrites the plist, and then reloads the daemon. This would be pretty easy since a loginhook runs as root and the $1 parameter is the username.
April 7, 2010 at 3:00 am #378356nemonada
ParticipantThank you!
I’ve not done anything w/logonhooks before. I’ll look them up and give it a shot but can you provide a minimal outline of one if you have the time?
April 7, 2010 at 3:35 pm #378358bschappel
ParticipantApple has a technote for creating a loginhook here: [url]http://support.apple.com/kb/HT2420[/url].
Another great resource is located here: [url]http://www.jochsner.dyndns.org/scripts/Scripts.html[/url]. Checkout the NHR package. It installs a nice loginhook system. One master script that runs all scripts in a folder. It also shows you how to get the user name and find the users home directory using dscl. Very nicely done.
April 7, 2010 at 6:24 pm #378359nemonada
ParticipantThat’s great info! Thank you very much.
April 11, 2010 at 7:25 am #378377khiltd
ParticipantDon’t write a login hook if you actually want your code to work in the future, and don’t expect launchd to expand tildes or provide a full login shell environment anytime soon. There are plenty of ways to determine the user’s name and build the correct path yourself.
April 15, 2010 at 2:08 pm #378395cpakhale
Participantdon’t expect launchd to expand tildes or provide a full login shell environment anytime soon. There are plenty of ways to determine the user’s name and build the correct path yourself.
[url=http://www.y3.com/search-results/10582/racing-gams]racing gams[/url]
[url=http://pro.yudu.com/catalogs/index.php]digital catalogs[/url] -
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed