Home Forums OS X Server and Client Discussion Questions and Answers launchd & plist problem…

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #378345
    nemonada
    Participant

    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?

    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…

    #378348
    Greg 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

    #378355
    bschappel
    Participant

    It’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.

    #378356
    nemonada
    Participant

    Thank 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?

    #378358
    bschappel
    Participant

    Apple 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.

    #378359
    nemonada
    Participant

    That’s great info! Thank you very much.

    #378377
    khiltd
    Participant

    Don’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.

    #378395
    cpakhale
    Participant

    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.

    [url=http://www.y3.com/search-results/10582/racing-gams]racing gams[/url]
    [url=http://pro.yudu.com/catalogs/index.php]digital catalogs[/url]

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Comments are closed