Saturday, June 2, 2012

Natural Scrolling in Fedora

My office Macbook got upgraded to "Lion" recently, default vertical scrolling behaviour in lion os is to follow natural way scrolling. so if i move my fingers on track pad from bottom to up, page will also move to show bottom part on the screen. Mac terms it as natural way scrolling, behaviour is same if a have a touch screen device where i feel as if i hold the page on the screen and move it up and down. this was not default earlier not even in windows and in linux, atleast not in fedora.

Of course Macbook has option to disable this natural way scrolling but i opted to keep it like that for trial, and later i started liking this way of scrolling. now problem comes when i use my fedora laptop, it doesn't scroll in that way. i checked but couldn't find any option to reverse scrolling behaviour in fedora (I use gnome and recently upgraded to fedora 17).

Exploring some more i found that xmodmap is the thing i have to play around  to fix this. Before i start writing more details about xmodmap. let me go with the title of blog and fix the scrolling part. there are two things in xmodmap key mapping and pointer mapping. execute following commands on your terminal to see the current mappings 

bash-4.2$ xmodmap -pk (this is to show all key mappings)
bash-4.2$ xmodmap -pp (this is to show all pointer mappings)

bash-4.2$ xmodmap -pp
There are 12 pointer buttons defined.

    Physical        Button
     Button          Code
        1              1
        2              2
        3              3
        4              5
        5              4
        6              6
        7              7
        8              8
        9              9
       10             10
       11             11
       12             12

Following 12 pointer are defined for various events. scrolling depends on pointer number 6 and 7.  All we have to do is swap the values of pointer number 6 and 7. and for that you have to execute following command 

bash-4.2$ xmodmap -e "pointer = 1 2 3 4 7 6 8 9 10 11 12"

and your scrolling will be reversed. Just for verification you can run xmodmap -pp again

bash-4.2$ xmodmap -pp
There are 12 pointer buttons defined.

    Physical        Button
     Button          Code
        1              1
        2              2
        3              3
        4              5
        5              4
        6              7
        7              6
        8              8
        9              9
       10             10
       11             11
       12             12

if you want to keep this permanent, all you have to do is save this mapping in startup scripts so that it gets executed when you boot up your fedora.


[I will find more time to write some more about xmodmap and update link  here, idea behind new blog will be something like changing additional multimedia keys to change them to work in your way or changing some key mappings for fooling around your friends. so keep watching for new blog post]