Re: Scripting the mouse acceleration setting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yannick Gingras wrote, On 06/29/08 12:43:
> Hi, 
>   I use KDE on my laptop which features an integrated trackpoint and
> depending on where I work, I also plug-in a USB mouse or a Unicomp
> keyboard with another integrated pointer.  All those pointing devices
> have different sensitivities so I constantly need to adjust my mouse
> acceleration setting.
> 
> Is there a way to automate that?  I could write a script that changes
> the value in ~/.kde/share/config/kcminputrc but how would I tell KDE
> to reload its config?

Yannick,

(this got long, but i think if you read all the way through you'll have a solution that works for you)

While i'm not entirely sure how to get all the KDE components to reload, i have some tips (hopefully) on how to do this type of thing, and answers that might solve your specific problem, even if it doesn't answer your question in a general way.

To figure out which KDE configuration files are used for various setting changes, you can...

Using KDE's Control Center, make a change to something, then you can find which files controlled that change by using 'find'...

(What's changed in the past 5 minutes?)
debian% find ~/.kde -mmin -5 -print
/home/dowdy/.kde/share/config
/home/dowdy/.kde/share/config/kwinrc
/home/dowdy/.kde/share/config/kdeglobals
/home/dowdy/.kde/share/config/kickerrc
/home/dowdy/.kde/share/config/kwinrulesrc
/home/dowdy/.kde/share/config/kcminputrc
/home/dowdy/.kde/share/config/kaccessrc

As you already know, kcminputrc handles the mouse bits..

debian# cat ~/.kde/share/config/kcminputrc ]

[$Version]
update_info=mouse_cursor_theme.upd:kde3.4.99

[Mouse]
Acceleration=2.5
MouseButtonMapping=RightHanded
ReverseScrollPolarity=false
Threshold=4
cursorTheme=

You can script the modification of this file easily using KDE's k{read,write}config executables. (which, btw, are great for editing any other MS-Windows-like .INI files, too ;)
if you don't specify a fully-qualified file path, k{read,write}config use the "config" path KDE elements as seen via:

debian# kde-config --path config
/home/dowdy/.kde/share/config/:/etc/kde3/:/usr/share/config/

e.g. scripting examples:

old_accel=$(kreadconfig --file  kcminputrc --group Mouse --key Acceleration)
kwriteconfig --file kcminputrc --group Mouse --key Acceleration 2.5

Note that the Acceleration and Threshhold are directly related to the X server's
"Pointer Control" parameters:

debian# xset q | grep -A1 'Pointer Control'
Pointer Control:
  acceleration:  25/10    threshold:  4
(note that acceleration is in Integer units, where 2.5 = 25/10)

So, you *could* bypass KDE's configuration files, and use 'xset m' directly.  E.G. to set the above values, just run:

debian# xset m 25/10 4

How that interplays with KDE, especially across KDE restarts is something i can't answer.  (KDE may save your current settings on shutdown, or won't and will reload the saved values from kcminputrc)

----------------
There MIGHT be a way using 'kwriteconfig' and 'kcmshell' to script a change to do what you need, but i'm not finding it offhand.

Take a look at:

debian# kcmshell mouse   (the Kcontrol Mouse tool pops up, go to Advanced Tab)
debian# kwriteconfig --file kcminputrc --group Mouse --key Acceleration 4.1
debian% dcop kcmshell_mouse KCModuleProxy-mouse load
*** You can see that the mouse tool acquires the new Acceleration value.
debian# dcop kcmshell_mouse KCModuleProxy-mouse changed
false
*** but it doesn't think anything's changed, so
debian# dcop kcmshell_mouse KCModuleProxy-mouse save
*** doesn't initiate the actions that normally occur when you hit APPLY.


AHA, but *this* does work to activate the changes you make with 'kwriteconfig'...

debian# xset q | grep -A1 Pointer
Pointer Control:
  acceleration:  31/10    threshold:  4

debian# kcminit mouse

debian# xset q | grep -A1 Pointer
Pointer Control:
  acceleration:  41/10    threshold:  4


I didn't try kcminit at first, as i figured it might have some major side-effects once the system was initialized and running, but i'm not seeing anything... yet ;)

--stephen
___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.

[Index of Archives]     [Trinity (TDE) Desktop Users]     [Fedora KDE]     [Fedora Desktop]     [Linux Kernel]     [Gimp]     [GIMP for Windows]     [Gnome]     [Yosemite Hiking]
  Powered by Linux