Posts Tagged 'mac'

Swap Modifier Keys Between Macbook and External Windows Keyboard Modes

A problem with PC keyboards on the Mac is that your Option and Command keys get mapped to the Windows and Alt keys, respectively (this swaps their placement).  This makes it confusing when you are switching between a Macbook’s onboard keyboard and USB PC keyboard.

Well, in Keyboard & Mouse preferences you can swap the modifier keys (Option, Command, Control, and Caps Lock) to remedy this.  In Tiger, you could only change this globally for all keyboards, meaning that when you switched between external and internal keyboards, you’d have to keep switching the settings if you wanted to keep the right key orientation.  This gave rise to the Applescript below, from Lance Ball.

Keyboard Prefs ScreenshotIn Leopard, however, they added the ability to configure keyboards independently. You could, theoretically, leave your internal keyboard with the default setting, and only have them swapped for the external.  Oh, if only this were the case.  I run a Logitech Cordless Desktop MX3000, and used to, for a brief moment, have the option to do this.  It was listed as “USB Reciever”.  However, the Logitech Control Center driver removed  this.  That’s what brought me to the following script.  This will automatically swap the Option and Command key mappings, toggling between them each time it is run.  The original Lance Ball script was for Tiger, but has been adapted for Leopard.  You can use this with MarcoPolo to run automatically when you add/remove your keyboard.

Update (9/29/08): I gave up using my MX3000 mouse, and went to a more ergonomic MS Natural Mouse.  Since the MX3000 keyboard never worked with Logitech Control Center anyway, I just removed the driver. I’ve now reclaimed the ability to independently map my Logitech keyboard.  Huzzah.

If you still need the Leopard script for some reason, here it is.  I added code to swap the MBP’s keyboard illumination on/off (off for ‘docked’ mode. You can enable this feature as per the script comments since it’s disabled by default.

Paste and save the following in Script Editor.

-- **********************************************************************************
-- Utility script to switch keyboard mapping for Command and Option keys.
-- Useful when you have a PC external keyboard that you use in one location, but
-- at other times you are using the builtin laptop keyboard or an Apple keyboard.
-- Author:  Lance Ball (lanceball - at - mac - dot - com)
-- Modified by: Joe Chan
-- Modified attributes: Script will change Internal Keyboard to have default behavior when
-- changing keyboards
--
-- Leopard 10.5.5 version by netgarou.  Also added feature to toggle Macbook Pro keyboard illumination.
-- (Remove the appropriate remark lines that start with "--**" to enable this if your system supports it).
-- Also disabled Growl notifications by default.
--
-- **********************************************************************************
-- Set up growl notifications
tell application "GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"External Keyboard Mode Notification", "Default Keyboard Mode Notification"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to ¬
{"External Keyboard Mode Notification", "Default Keyboard Mode Notification"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Change Keyboard AppleScript" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Script Editor"
end tell
-- Open System Preferences
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
-- If we don't have UI Elements enabled, then nothing is really going to work.
if UI elements enabled then
tell application process "System Preferences"
get properties
--If keyboard illumination is on, disable it when the external keyboard is connected.
--**if value of checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse" is 1 then
--**    click checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse"
--**end if
-- Open up the Modifier Keys sheet
click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
tell sheet 1 of window "Keyboard & Mouse"
-- get the text of the 3rd pop up button
set areweDefault to "0"
set commandKey to value of pop up button 2
-- If we're in default mode, swap the keys
if commandKey ends with "Option" then
-- Change "All" keyboards
click pop up button 2
click menu item 4 of menu 1 of pop up button 2
delay 0.1
click pop up button 1
click menu item 3 of menu 1 of pop up button 1
delay 0.1
-- Send growl notification
--** tell application "GrowlHelperApp"
--notify with name ¬
--** "External Keyboard Mode Notification" title ¬
--** "External Keyboard Mode" description ¬
--** "Settings have been optimized for external keyboards" application name "Change Keyboard AppleScript"
--** end tell
--** delay 0.1
click button "OK"
else
-- We're in PC keyboard mode.  Swap back to the defaults
click button "Restore Defaults"
--** set areweDefault to "1"
-- Send growl notification
--** tell application "GrowlHelperApp"
--notify with name ¬
--** "Default Keyboard Mode Notification" title ¬
--**    "Default Keyboard Mode" description ¬
--**    "Reverted to default keyboard settings" application name "Change Keyboard AppleScript"
--**end tell
click button "OK"
end if
-- close the sheet
end tell
--** If switching back into laptop keyboard mode, then reenable the keyboard illumination if it was disabled
--** if areweDefault is "1" then
--**    if value of checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse" is 0 then
--**        click checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse"
--**    end if
--**end if
end tell
tell application "System Preferences" to quit
else
-- UI elements not enabled.  Display an alert
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

OSX 10.6 Snow Leopard: Fix the Finder!

With OS X 10.6 “Snow Leopard”, Apple’s Goal is to “Enhance the performance of OS X, set a new standard for quality and lay the foundation for future OS X innovation.”  They are promising that, although there will be no huge feature additions, 10.6 will be worth our while since it will give Apple the opportunity to clean up their code and make a cleaner, leaner, meaner OS X.

Yet, missing from the feature list which includes things like Grand Central, is something that Mac users have been clamoring for for a while:  An overhaul of the Finder.

I will totally get this upgrade if, on their list of fixes they fix the #%@#% Finder. Seriously, it’s the most used, most prominent element of OS X in need of an update. Most people will get way more mileage out of an overhaul of the Finder than any of the other things I’ve seen listed.

For instance, fix the crashes, have Trash remember the origin of deleted files so you can actually recover them, and have enable Undo/Trash support for files that are erased by the “copy and replace” Finder operation. For that matter, how about a “copy and merge” function instead of (or in addition to) the aforementioned?

The Mac Trash Bin

I hate to admit it, but Windows actually has one advantage over OS X, and that’s the handling ofdeleted files.  Sure, on both systems you can always undo the last operation (well, not always… I’m not going to make that blanket statement).  However, Windows Recycle Bin has a few big advantages:

images.jpg

Windows Recycle Bin remembers where each file came from.
Just right click an item and choose restore, and it will go back to the right place.  Very important for those deleted preference files that need to end up in some arcane location in your Documents and Settings. In OS X, good luck placing stuff back in to the right folder. Strange that OS X is all about metadata but doesn’t keep track of this.

You can selectively remove items from the trash
As opposed to OS X’s all-or-nothing “Empty Trash” option.

When you’re copying a folder and another of that same name already exists in the destination, Mac only gives you an option to Replace.
This deletes the existing folder then copies the new one in it’s place (see common Finder gripes: “Replace vs Merge“).  Something deleted in this way doesn’t go to the Trash. This is insult to injury: Not only are you surprised to find that you just accidently did a delete and replace instead of the far more common and expected merge, but then you’re double-screwed because Apple decided to disable Undo for this most destructive of actions.  It’s pretty evil.

And to all the Mac users out there: all the other OS’s do merge, or will at least give the option for it.  I’d at *least* like Finder to present this choice, especially since the Merge operation is a lot harder for a user to replicate on their own, than a Replace.  By the way, it’s not perfect, but you can reclaim some of your lost Merge with MergetoFinder applescript


Categories

 

December 2009
M T W T F S S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28293031  

del.icio.us

Watch videos at Vodpod and other videos from this collection.