2

I have a trackball and it takes me 4 strokes of my thumb to go from one side of the screen to the other even though the speed setting is at max. I added xset m 200 1 to my startup apps, but recently it stopped auto-starting. I have to manually enter this command in Terminal Is the a way to set this speed without this workaround?

Thank you for the help

2

2 Answers 2

3

Not a "Is there a way to set this speed without this workaround?" – answer. But perhaps some help. You might found a solution by @RickGreen-Turbo 's comment-link, but add some.

To identify mouse use:

$ xinput list
# or
$ xinput --list --short
    # Should give you something like:
    ⎡ Virtual core pointer                      id=2    [master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer            id=4    [slave  pointer  (2)]
    ⎜   ↳ Logitech USB-PS/2 Optical Mouse       id=8    [slave  pointer  (2)]
    ⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
        ↳ Virtual core XTEST keyboard           id=5    [slave  keyboard (3)]
        ↳ Power Button                          id=6    [slave  keyboard (3)]
        ↳ Power Button                          id=7    [slave  keyboard (3)]
        ↳ AT Translated Set 2 keyboard          id=9    [slave  keyboard (3)]
        ↳ HP WMI hotkeys                        id=10   [slave  keyboard (3)]

In your case it might be something like Logitech USB Trackball.

To list current settings say:

xinput --list-props [<id_number> | "String Identifier"]

E.g. (in my case):

$ xinput --list-props 8
Or
$ xinput --list-props "Logitech USB-PS/2 Optical Mouse"

Not sure about this, but my guess is, that id could change between boots. As stated here:

"The id is a number in the range 0-128 that uniquely identifies the device. It is assigned to the device when it is initialized by the server."

So in a script, when modifying, use the string variant. (Perhaps this is what is wrong with your old configuration?)

It yields (for me):


    Device 'Logitech USB-PS/2 Optical Mouse':
        Device Enabled (132):   1
        Coordinate Transformation Matrix (134): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (261): 0
        Device Accel Constant Deceleration (262):   1.000000
        Device Accel Adaptive Deceleration (263):   1.000000
        Device Accel Velocity Scaling (264):    10.000000
        Device Product ID (251):    1133, 49181
        Device Node (252):  "/dev/input/event3"
        Evdev Axis Inversion (265): 0, 0
        Evdev Axes Swap (267):  0
        Axis Labels (268):  "Rel X" (142), "Rel Y" (143), "Rel Vert Wheel" (260)
        Button Labels (269):    "Button Left" (135), "Button Middle" (136), "Button Right" (137), "Button Wheel Up" (138), "Button Wheel Down" (139), "Button Horiz Wheel Left" (140), "Button Horiz Wheel Right" (141), "Button Side" (255), "Button Extra" (256), "Button Forward" (257), "Button Back" (258), "Button Task" (259), "Button Unknown" (254), "Button Unknown" (254), "Button Unknown" (254), "Button Unknown" (254)
        Evdev Middle Button Emulation (270):    0
        Evdev Middle Button Timeout (271):  50
        Evdev Third Button Emulation (272): 0
        Evdev Third Button Emulation Timeout (273): 1000
        Evdev Third Button Emulation Button (274):  3
        Evdev Third Button Emulation Threshold (275):   20
        Evdev Wheel Emulation (276):    0
        Evdev Wheel Emulation Axes (277):   0, 0, 4, 5
        Evdev Wheel Emulation Inertia (278):    10
        Evdev Wheel Emulation Timeout (279):    200
        Evdev Wheel Emulation Button (280): 4
        Evdev Drag Lock Buttons (281):  0

Find the values you want to change and add them to start-up script.

For testing e.g.:

$ xinput --set-prop 8 "Device Accel Velocity Scaling" 50
$ xinput --set-prop 8 "Device Accel Constant Deceleration" 1.5

The (related) properties:

  • Device Accel Adaptive Deceleration
  • Device Accel Constant Deceleration
  • Device Accel Profile
  • Device Accel Velocity Scaling

are documented here. (Look around the same page for more information if you want.)

Add hack that works for your mouse in a file and save it to e.g. ~/.bin/my_mouse_hack

e.g:

#!/bin/bash
xinput --set-prop "Logitech USB Trackball" "Device Accel Velocity Scaling" 75
xinput --set-prop "Logitech USB Trackball" "Device Accel Constant Deceleration" 1.5

Make it executable:

$ chmod 700 ~/.bin/my_mouse_hack

Now: To set this to run at start-up. Add this to .bash_profile as stated here. (I'm in the middle of a load of work, coding, compiling etc. so I won't test this now. But I'll do later and update answer.)

Or add it to by choosing "Add" in (If you use GNOME):

Alt+F2 gnome-session-properties Enter.

Or by X11 config or similar.


EDIT 1: suspend quirk

See you have some problems with resume after suspend.

When the computer goes into or resumes suspend/hibernate mode it runs scripts located in /etc/pm/sleep.d and /usr/lib/pm-utils/sleep.d. man pm-action.

When going down scripts are run with argument suspend or hibernate, when resuming the argument is resume and thaw respectively – that is: in your script $1 is either of the four.

Scripts, aka "hooks", in these directories are, AFAIK, categorized in two blocks.

/usr/lib/pm-utils/sleep.d  Distribution / package provided hooks 
/etc/pm/sleep.d            Administrator provided hooks

Also; if you want to disable a script that reside in /usr/lib/pm-utils/sleep.d create an empty file in /etc/pm/sleep.d with the same name and don't make it executable.

A last file to mention is /var/log/pm-suspend.log. This file has information about last suspend/hibernate and resume/thaw – and by convention is a good place to add your own logging. It also is a good place to look for errors. If a script fails, it should be logged here.

A simple script 01_test:

#!/bin/bash

ts=$(date)

case "$1" in
"hibernate"|"suspend")
    printf "; %s: going down by \`%s'\n" "$ts" "$1" >> /var/log/pm-suspend.log
    ;;
"resume"|"thaw")
    printf "; %s: waking up by \`%s'\n" "$ts" "$1" >> /var/log/pm-suspend.log
    ;;
esac

Then

$ sudo chmod 755 /etc/pm/sleep.d/01_test

Suspend and wake up, cat log and see:

$ cat /var/log/pm-suspend.log
; Sun Jan 13 06:38:14 CET 2013: going down by `suspend'.
...
; Sun Jan 13 06:38:19 CET 2013: waking up by `resume'.

OK. That works. Now what you want is to set mouse by xset etc. It would be tempting to believe that a simple line like

xset m 14/1 1

In a script in /etc/pm/sleep.d would suffice, but if you try (no harm by trying), you'll see some error in the log file. There is at least two issues. 1: xset require a display 2: root most likely does not have an Xsession.

To resolve this one could specify a user environment etc. by adding a line like this instead:

su YOUR_USERNAME -c "xset -display :0 m 14/1 1"

but as this is a global script one would presumably do it a bit more complex. This script check for users that are logged in and have an :0 display, check if they have an executable file in /home/user/bin/ named .resume that is executable; if so executes it

01_user_resume:

#!/bin/bash

# Time(stamp)
ts=$(date)
# Log file
log="/var/log/pm-suspend.log"
# Array of Users
#   Users (finger/who/w ... etc)
#   Having Xsession (:0)
#   Unique
declare -a users=($(/usr/bin/finger | \
        /bin/grep ':0'| \
        /bin/grep -o '^\w*' | \
        /usr/bin/uniq))
# Array of scritps to look for (using array as it is easy to extend)
declare -a user_scripts_resume=(".resume")

# Run resume script fo all users with X session
run_user_scripts_resume()
{
    local user  # Each user
    local home  # Users home
    local scr   # Script to check for and run
    for user in "${users[@]}"; do
        printf ";; For User: %s.\n" "$user" >> "$log"
        # Identify users home directory
        home=$(/usr/bin/getent passwd "$user" | cut -d: -f6)
        # If user has a file called $HOME/bin/<sctipt> and it is 
        # executable then run it
        for scr in "${user_scripts_resume[@]}"; do
            if [ -f "$home/bin/$scr" ] && [ -x "$home/bin/$scr" ]; then
                printf ";;   Executing: $home/bin/$scr\n" >> "$log"
                # DISPLAY is needed by e.g. xset
                /bin/su "$user" -c "export DISPLAY=:0; $home/bin/.resume"
            fi
        done
    done
}

case "$1" in
"hibernate"|"suspend")
    printf "; %s: going down by \`%s'.\n" "$ts" "$1" >> "$log"
# Nothing to do
    ;;
"resume"|"thaw")
    printf "; %s: waking up by \`%s'.\n" "$ts" "$1" >> "$log"
    printf "; Executing User resume scripts.\n" >> "$log"
    run_user_scripts_resume
    ;;
esac

So:

  • Add that script to a file in /etc/pm/sleep.d/01_user_resume.
  • Make it executable: sudo chmod 755 /etc/pm/sleep.d/01_user_resume

In your home directory create the file bin/.resume - and add e.g. (err see Edit 2 below):

#!bin/bash

sleep 3  # See note on EDIT 2: below    
xset m 15/1 1

Make it executable: chmod 700 bin/.resume

Or, better, use same script for boot and resume – aka re-run the script you used to set mouse on boot.

Suspend and resume. Check if settings has changed by:

xset q
# or
xset q | grep -A 1 Pointer

EDIT 2: Mouse move

Testing this it seems like there is yet another problem. The xset q | grep -A 1 Pointer command reveals that the settings are changed, problem is that once the mouse is used - it reverts. For me this was fixed by adding sleep 1 before xset in the .resume script. You might want to use a longer sleep time to be sure.

Changed so that script was last executed, according to the log file, but this did not help - probably because the scripts seems to be executed in sub-shells - so some process from an earlier script might get executed after last script is executed.

3
  • Thanks for this answer. I will try this when I get back home tonight
    – Olivier
    Jan 11, 2013 at 12:13
  • This works beautifully, except that when I get my computer out of suspend mode, it does not load this. Is there a way to load this when comming back from suspend?
    – Olivier
    Jan 11, 2013 at 21:36
  • @Olivier: Sorry for a bit long delay there. Added some more notes on suspend.
    – Runium
    Jan 13, 2013 at 10:25
0

To fix suspend/resume issue, I finally resorted to using crontab:

$ crontab -e

* * * * * DISPLAY=:0 xset m 2 2

I know its not pretty, but it works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .