![]() |
Quote:
Quote:
Why does everybody keep saying this? I don't know but I'm prepared to bet Automator is just a more GUIfied version for the much vaunted 'recordable' scripting mechanism that came out with 10.1. It will rely on 3rd party developers (and Apple) putting in as much effort in getting their products to 'automate' as they already have with recordable scripting support - in other words, none at all. [/mock rant] You could avoid using sudoers or opening Terminal at all with an Applescript and 'do shell script.' Yes, you still need your password, but you can script KeyChain Access to give this out. I'm trying to write an example to show what I mean but I'll have to post it sometime over the weekend. [EDIT Ummm - I have managed to get this to work but have noticed a problem with KeyChain Access so probably better if I keep quiet for now] |
found it
That friend of mine replied.
Here is the applescript I made for him to put in his scripts menu and change his display sleep time. Replace $MYADMINPASS with your admin password. Code:
do shell script "sudo pmset dim 1" password "$MYADMINPASS" with administrator privileges |
Quote:
Reading up on pmset, I found an interesting [optional] argument called force. In tests I ran, it seems that we can totally avoid the whole sudo mess... because --when "force" is deployed -- pmset doesn't write to the plist, but rather directly to some location (RAM, VM, register, whatever) where those variables are actively used. From the man page: Quote:
Code:
#!/bin/bashFWIW, -HI- |
Quote:
However, what if there where more nested dicts in the level 2 dict that we are editing. I have seen that even using '-dict-add' will wipe out any dict at level 3 branching from the level 2 dict we are editing. In other words, how do you edit the value of the key 'Date' of dictionary 'Level3A' from '2005-07-18T21:53:04Z' to '2005-08-3T23:50:04Z' in: Code:
<?xml version="1.0" encoding="UTF-8"?> |
I don't think deeply nested values can be edited using 'defaults' alone (I would be interested if there is a way), so workarounds will vary from situation to situation...
The example in your post is fairly straightforward, since there is only one 'Level2' entry, and all of the entries are of the string "type". There are probably easier ways, but you could for example, take the ascii formatted output of the 'defaults read' command (in which key-value pairs are conveniently placed together into lines), and process it with 'sed' or something. eg. Code:
newdate="2005-08-3T23:50:04Z"Anyway, at this point, it becomes more of a question about "how to parse text" rather than use of the 'defaults' command... |
The man page for defaults seems to explain how to set the value types of new values, choosing from string, data, int, float, bool, date…
I can see that there are sideways like editing ASCII plist, but my intention was to edit a plist from a shell script, and Tiger seems to be full of binary plists. The command plutil seems to be able to convert from binary to xml, but not to ASCII. Maybe I can use sed, too, or other command to go through an ASCII file with line breaks, but I will have to look into that, and my shell skills are limted… |
| All times are GMT -5. The time now is 06:22 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.