从Mac上的命令行启用/禁用Fn键

Ran*_*all 18 macos shell defaults

我几乎没有使用我的macbook pro上的功能键.我大多只是将它们用于音量,亮度等.现在我已经开始玩星际争霸2了,我想用它们而不必按下fn键.

我想写一个小的shell脚本,它将翻转"使用所有F1,F2等键作为标准功能键"复选框.我以为我可以使用defaults命令来更改它,但我不确定要使用什么值.这样我每次想玩的时候都不需要改变首选项.我可以运行脚本,即切换键,甚至启动游戏.

有任何想法吗?

use*_*621 8

AppleScript应该做的伎俩 - 取自http://scriptbuilders.net/files/fn1.1.html,略有修改

--Check if GUI Scripting is Enabled
tell application "System Events"
    if not UI elements enabled then
        set UI elements enabled to true
    end if
end tell

--Enable/Disable "Use all F1, F2, etc. keys as standard function keys" option in Keyboard & Mouse Preference pane and close System Preferences
tell application "System Events"
    tell application "System Preferences"
        reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
    end tell
    click checkbox 1 of tab group 1 of window 1 of application process "System Preferences"
end tell
if application "System Preferences" is running then
    tell application "System Preferences" to quit
end if
Run Code Online (Sandbox Code Playgroud)

在MacOS 10.6.4上测试


Rob*_*ert 7

该命令是defaults write -g com.apple.keyboard.fnState,尽管我过去在更改它时遇到了问题。我最终只使用了 AppleScript。试一试。

defaults write -g com.apple.keyboard.fnState -boolean true
Run Code Online (Sandbox Code Playgroud)

编辑
为了详细说明,我遇到的问题是实际值已更改,但它不会主动更改系统偏好设置中的设置,也不会切换 fnState,因为该文件仅在启动/登录等时读取。此外,对另一个任务打开的配置文件进行更改听起来是损坏文件的好方法。

  • 正如广告所添加的注释,我刚刚在 Mavericks 上进行了测试,但没有任何功能结果。 (2认同)