Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 5568755db0
Fetching contributors…

Cannot retrieve contributors at this time

139 lines (112 sloc) 4.19 KB
;; fKeys support for Aquamacs
;; (C) 2006 by David Reitter
;; do not copy / redistribute. All rights reserved.
; to do
; make sure mac-function-modifier is saved by save options
; change paths for fKeysd
; check dialog
; fKeys bugs -> toggle caps lock, and system-wide mod key remapping
(defvar fKeys-program "/opt/kodachi/fKeys/system/fKeysd")
(defun fKeys-version ()
"Return fKeys version, and nil if fKeys isn't running."
(let ((x
(call-process "kextstat" nil t nil
"-k" "-l" "-b" "com.kodachi.driver.fKeys")
(if (search-forward-regexp "(\\([0-9]\\.[0-9]\\)" nil t)
(match-string 1)
(condition-case nil
(if x
(string-to-number x)
(error nil))))
;; needs to be run as root
;; (call-process "kextload" nil t nil "/opt/kodachi/fKeys/system/fKeys.kext")
;; (fKeys-version)
(defun fKeys-initialize ()
"Loads the aquamacs.plist supplied with fKeys.
Return t if successful."
(condition-case nil
(eq 0 (call-process "/opt/kodachi/fKeys/system/fKeysd" nil nil nil
(error nil)))
(defvar fKeys-initialized nil)
(defun fKeys-handle-focus-gained (event)
(interactive "e")
(when mac-capslock-modifier
(unless fKeys-initialized
(if (fKeys-initialize)
(setq fKeys-initialized t)))
(condition-case nil
(call-process "/opt/kodachi/fKeys/system/fKeysd" nil nil nil
"-s" "1" "1")
(error nil))))
(defun fKeys-handle-focus-lost (event)
(interactive "e")
(when mac-capslock-modifier
(unless fKeys-initialized
(if (fKeys-initialize)
(setq fKeys-initialized t)))
(condition-case nil
(call-process "/opt/kodachi/fKeys/system/fKeysd" nil nil nil
"-s" "1" "0")
(error nil))))
;; define the event class
(put 'application-event 'mac-apple-event-class "appl") ; kEventClassApplication
(put 'app-front-activated 'mac-apple-event-id "APAC") ;
(put 'app-front-deactivated 'mac-apple-event-id "APDA") ;
(define-key mac-apple-event-map [application-event app-front-activated ]
(define-key mac-apple-event-map [application-event app-front-deactivated ]
(require 'emulate-mac-keyboard-mode)
(defvar mac-capslock-modifier-enabled-value 'meta)
(defun toggle-mac-capslock-modifier (&optional interactively)
(interactive "p")
(unless mac-capslock-modifier-enabled-value
(setq mac-capslock-modifier-enabled-value 'meta))
(setq mac-capslock-modifier
(if mac-capslock-modifier
(setq mac-capslock-modifier-enabled-value mac-capslock-modifier)
(when interactively
(customize-mark-as-set 'mac-capslock-modifier)
(let ((v (fKeys-version)))
(if (and v (>= 0.2 v))
(unless fKeys-initialized
(if (fKeys-initialize)
(setq fKeys-initialized t)))
(if (mac-dialog-y-or-n-p
"fKeys installation is needed."
"To use Caps Lock as Meta key, you need to install Kodachi fKeys (0.2.0 or newer). Would you like to download this software now?")
(browse-url "")))))
(format "Caps Lock key is %s%s"
(if mac-capslock-modifier
"" "not ")
(symbol-name (or mac-capslock-modifier
(define-key menu-bar-option-key-menu [capslock-modifier]
,(format "%s Caps Lock Key for %s (not extra characters) "
(string (decode-char 'ucs #X21EA))
(upcase-initials (symbol-name
(or mac-capslock-modifier
:key-sequence nil
:visible (boundp 'mac-capslock-modifier)
:help "Toggle whether to let Caps Lock key behave as Emacs key,
do not let it produce shifted characters (passing the key to the system)."
:button (:toggle . mac-capslock-modifier)))
(define-key-after menu-bar-options-menu [option-key-menu]
`(menu-item (format "%s%s Modifier Keys" (string (decode-char 'ucs #X2325))
(string (decode-char 'ucs #X21EA)))
; (aq-describe-modifier mac-option-modifier)
Jump to Line
Something went wrong with that request. Please try again.