Tuesday, January 11, 2011

Global shortucut for opening new Finder window

A shortcut I always used heavily in windows was the win-e to open a explorer windows.
In Mac OS this shortcut does not exist globally.
Searching on google you get many suggestions, but all of them are in the form:
Select Finder and choose "New window". DUHHH!!
I don't like this solution because is a 2 step thing that is something I want to avoid.
Finnaly I found in this this site http://contented.qolc.net/articles/osx-global-shortcut-key-new-finder-window a good solution using the services that will allow for a global, single shortcut to open a new finder window (plus: you can tune the script to open the window in a selected location)

The service I created can be found here.

Some of the 2 step solution are interesting, so I leave here some notable solutions:
  1. Use of option-command-space that will open a search window, that is, in itself a finder window.
  2. Use ctrl-f3, this will move the focus to the Dock, pressing return will sellect the finder, because this is always the first application in the Dock.

Saturday, January 08, 2011

Remapping keys in linux

My problem:

I got a very crappy PS2 to USB cable, and when I use the mouse scroll, from time to time a extra mouse key press was sent (key 9). This was not a problem in most of the places, except in firefox where it would trigger a back in history when I scrolled up (very annoying).
I've changed all the firefox preferences in about:config in mousewheel.* to only scroll (action=0), but I was always getting the back in scroll up. (about:config information here.)

Diagnosis:

To figure out what was the problem I used xev That will print to the terminal the events occurred in the small x window created by the program. Here is the problem I was having, the log is from me scrolling down, you can see at some point the keys sent are 9 and 8:
ButtonPress event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747353, (40,101), root:(1358,514),
    state 0x10, button 4, same_screen YES
ButtonRelease event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747353, (40,101), root:(1358,514),
    state 0x810, button 4, same_screen YES
MotionNotify event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747449, (40,102), root:(1358,515),
    state 0x10, is_hint 0, same_screen YES
ButtonRelease event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747449, (40,102), root:(1358,515),
    state 0x10, button 8, same_screen YES
ButtonRelease event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747449, (40,102), root:(1358,515),
    state 0x10, button 9, same_screen YES
MotionNotify event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747553, (40,102), root:(1358,515),
    state 0x10, is_hint 0, same_screen YES
ButtonPress event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747553, (40,102), root:(1358,515),
    state 0x10, button 8, same_screen YES
ButtonPress event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747553, (40,102), root:(1358,515),
    state 0x10, button 9, same_screen YES
ButtonPress event, serial 40, synthetic NO, window 0x3800001,
    root 0xb6, subw 0x0, time 747553, (40,102), root:(1358,515),
    state 0x10, button 4, same_screen YES
As my mouse only has 2 buttons and a scroll wheel, I changed the mouse mapping to disable all the other buttons (buttons above 5 are set to button 0). The command is:
xmodmap -e "pointer = 1 2 3 4 5 0 0 0 0 0 0 0 0 0 "
You can check what mapping you are using by doing: xmodmap -pp In my case, after changing the mapping I get:
# xmodmap -pp
There are 14 pointer buttons defined.

Physical        Button
 Button          Code
    1              1
    2              2
    3              3
    4              4
    5              5
    6              0
    7              0
    8              0
    9              0
   10              0
   11              0
   12              0
   13              0
   14              0
To return to the default mapping you can do : # xmodmap -e "pointer = default" And check:
# xmodmap -pp
There are 14 pointer buttons defined.

Physical        Button
 Button          Code
    1              1
    2              2
    3              3
    4              4
    5              5
    6              6
    7              7
    8              8
    9              9
   10             10
   11             11
   12             12
   13             13
   14             14
To make this change permanent you just need to create a file ~/.Xmodmap with the content:
pointer = 1 2 3 4 5 0 0 0 0 0 0 0 0 0
You can check the correctness of your file by doing xmodmap ~/.Xmodmap and check if the mapping was changed correctly.