Posted: Tue Jun 01, 2010 10:05 am Post subject: Random brain-picking attempt
I've been looking all through the internet (well, that's a bloody exaggeration for a start, but I've tried my level best) and I can't find a command-line equivalent for setting the first checkbox switch in System Preferences::Keyboard that decides whether you need to hit Fxx or Fn-Fxx to get the F-keys:
I assume that somewhere there's a defaults write.com.apple.[something-or-other] yes/no switch, but I can't find the pref in the System Preferences plist file.
Any of you mavins know what it is? Or how to otherwise switch this switch from the command-line? I want to set up a keyboard shortcut (using iKeys) to switch between F-keys default and special keys (brightness, volume, iTunes controls etc.) default. I use the latter more than half of the time, but I also often need the F-keys (in Photoshop, Sibelius, etc.).
The good news is that the pref is stored in the .GlobalPreferences.plist (-g, NSGlobalDomain), as "com.apple.keyboard.fnState", with type bool.
The bad news is that, although you can toggle it from the command line, the OS (and System Prefs) only picks up changes if you toggle it from the UI.
My guess is that your best bet here is to enable "Enable Access for Assistive Devices" in Universal Access System Prefs and then write an AppleScript that uses GUI scripting to toggle the checkbox; you can then run the script from the command-line with osascript (or whatever means you need for iKey integration).
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Thanks for finding this, bootless though it be. Well, maybe there's some arcane way to trigger a re-read of the .plist. But damned if I know how to go about looking for it, so until I find something, I'll stick with my clumsy-but-effective iKeys solution, which opens the prefpane, switches the checkbox, and quits the prefpane again.
I hope I turn something up at some point, because I plan to put together a simple menubar app to show the state, but I'd really like to be able to change it from there too via click or key combo.
In the meantime, with some help from MacOSXHints, I've put together an AppleScript to do this, which seems quick and small (re-edited and much improved version, lets you choose which state you want first! then pops up a dialogue at the end to show what the resultant state is):
Code:
(* script to switch on/off "Use all F1, F2, etc. keys as standard function keys" *)
set resultString to ""
set dialogString to "What do you want your function keys to be (without the Fn key)?"
set choiceFlag to button returned of result
if choiceFlag = "Cancel" then return ""
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
if UI elements enabled then
tell tab group 1 of window ¬
"Keyboard" of process "System Preferences"
if choiceFlag is "F1, F2..." then
if value of checkbox 1 is 0 then click checkbox 1
set resultString to "F1, F2, etc. set as function keys"
else
if value of checkbox 1 is 1 then click checkbox 1
set resultString to "F1, F2 etc. set as media controllers"
end if
end tell
else
tell application "System Preferences"
activate
set current pane ¬
to pane "com.apple.preference.universalaccess"
display dialog ¬
"UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell
delay 0.5
tell application "System Preferences"
quit
end tell
if resultString is not "" then display dialog resultString buttons {"•"} with icon note giving up after 2
This is as close as I can get to what I wanted without finding the variable and therefore not having to go through the GUI.
As a side issue, if you use iKey (or FastScripts or whatever) to trigger applescripts on a mac using a key combo, avoid any combos that include the ctrl key - or you're stuck with the applescript opening dialogue first, regardless of how you saved the script:
As a side issue, if you use iKey (or FastScripts or whatever) to trigger applescripts on a mac using a key combo, avoid any combos that include the ctrl key - or you're stuck with the applescript opening dialogue first, regardless of how you saved the script:
I hate that bug. It's even worse when your AppleScript is a faceless background app, and you happen to be holding down Ctrl in some other app at the same time your app is being launched by some other process. I've rdar://ed it (several years ago, even), and I had a friend at WWDC try to talk to the AppleScript team about it. But it's still there, and it's the most useless "feature" ever :/
If you have an ADC account and want to file a duplicate, I'll look up the number so that you can tell them it's a duplicate of mine (Apple works in weird ways; it's the only place I know that encourages the filing of duplicate bugs; it's how they measure how painful a bug is).
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
If you have an ADC account and want to file a duplicate, I'll look up the number so that you can tell them it's a duplicate of mine (Apple works in weird ways; it's the only place I know that encourages the filing of duplicate bugs; it's how they measure how painful a bug is).
Smokey
So, it looks like I specifically complained about the fact the unwanted startup screen gets "stuck" (unclickable) when your app is a faceless bg app (LSBackgroundOnly), and you've just got the basic "shows an unwanted startup screen" part.
I guess maybe you can say "it's similar to Problem ID 5962612" (rather than "duplicate of"); that way both parts of the screwy behavior are filed, and Apple has at two bugs on file about the general issue, which they can dupe at their leisure
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum