Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

Download or installation problems? Try these steps
Problems after upgrading to NeoOffice 2017? Try these steps


Support
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


RSS Feeds
· Announcements Only
· All Posts


  
NeoOffice :: View topic - Random brain-picking attempt
Random brain-picking attempt
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    NeoOffice Forum Index -> Random Whatnot
View previous topic :: View next topic  
Author Message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Tue Jun 01, 2010 10:05 am    Post subject: Random brain-picking attempt Reply with quote

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.).
Back to top
View user's profile Send private message
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Tue Jun 01, 2010 11:26 am    Post subject: Reply with quote

I have some good news and some bad news.

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
Back to top
View user's profile Send private message Visit poster's website
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Wed Jun 02, 2010 3:59 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Thu Jun 03, 2010 12:08 am    Post subject: Reply with quote

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)?"

display dialog dialogString buttons {"F1, F2...", "Media controls", "Cancel"} default button 3 with icon note

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:

Back to top
View user's profile Send private message
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Thu Jun 03, 2010 10:00 am    Post subject: Reply with quote

yoxi wrote:
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. Mad 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
Back to top
View user's profile Send private message Visit poster's website
yoxi
Cipher


Joined: Sep 07, 2004
Posts: 1799
Location: Dawlish, Devon

PostPosted: Thu Jun 03, 2010 3:09 pm    Post subject: Reply with quote

sardisson wrote:
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

Sure - anything to rattle the cage.
Back to top
View user's profile Send private message
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Thu Jun 03, 2010 11:41 pm    Post subject: Reply with quote

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 Wink

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    NeoOffice Forum Index -> Random Whatnot All times are GMT - 7 Hours
Page 1 of 1

 
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

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Page Generation: 0.03 Seconds