How to make a program that finds id's of xinput devices and sets xinput some settings

how to get process id of the running program in c
xinput examples
xinput keyboard
xinput unable to find device
xinput set-button-map
virtual core xtest pointer
xinput list-props
xinput linux

I have a G700 mouse connected to my computer. The problem with this mouse in Linux (Ubuntu) is that the sensitivity is very high. I also don't like mouse acceleration, so I've made a script that turns this off. The script looks like this

# This script removes mouse acceleration, and lowers pointer speed
# Suitable for gaming mice, I use the Logitech G700.
# More info:
xinput set-prop 11 'Device Accel Profile' -1
xinput set-prop 11 'Device Accel Constant Deceleration' 2.5
xinput set-prop 11 'Device Accel Velocity Scaling' 1.0
xinput set-prop 12 'Device Accel Profile' -1
xinput set-prop 12 'Device Accel Constant Deceleration' 2.5
xinput set-prop 12 'Device Accel Velocity Scaling' 1.0

Another problem with the G700 mouse is that it shows up as two different devices in xinput. This is most likely because the mouse has a wireless adapter, and is usually also connected via a usb cable (for charging). This is my output from xinput --list (see id 11 and 12):

$ xinput --list
⎡ Virtual core pointer                              id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                    id=4    [slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver                         id=8    [slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver                         id=9    [slave  pointer  (2)]
⎜   ↳ Logitech Unifying Device. Wireless PID:4003   id=10   [slave  pointer  (2)]
⎜   ↳ Logitech G700 Laser Mouse                     id=11   [slave  pointer  (2)]
⎜   ↳ Logitech G700 Laser Mouse                     id=12   [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)]

This isn't usually a problem, since the id's are usually the same. But sometimes the id's of the mouse change, and that's where my question comes in.

What's the simplest way of writing a script/program that finds the id that belongs to the two listings named Logitech G700 Laser Mouse in the output from xinput --list, and then running the commands in the top script using those two ids?

You can do something like the following.

if [ "$SEARCH" = "" ]; then 
    exit 1

ids=$(xinput --list | awk -v search="$SEARCH" \
    '$0 ~ search {match($0, /id=[0-9]+/);\
                  if (RSTART) \
                    print substr($0, RSTART+3, RLENGTH-3)\

for i in $ids
    xinput set-prop $i 'Device Accel Profile' -1
    xinput set-prop $i 'Device Accel Constant Deceleration' 2.5
    xinput set-prop $i 'Device Accel Velocity Scaling' 1.0

So with this you first find all the IDs which match the search pattern $SEARCH and store them in $ids. Then you loop over the IDs and execute the three xinput commands.

You should make sure that $SEARCH does not match to much, since this could result in undesired behavior.

C program to get Process Id and Parent Process Id in Linux , This program will get the Process Id and Parent Process Id of the current Process in C programming Linux. Here we are using two functions getpid() to get� If you are unaware of the exact program name, you can try the ps command. This ps command is used for seeing the running processes on the system. You can use the grep command with the program name (or whatever you remember about it). ps aux | grep -i “name of your desired program” ps aux command returns all the running process on the system.

If the device name is always the same, in this case Logitech G700 Laser Mouse, you can search for matching device IDs by running

xinput list --id-only 'Logitech G700 Laser Mouse'

Python: Find group id, user id, real group id, supplemental group ids , Python Exercises, Practice and Solution: Write a Python program to get the effective group id, effective user id, real group id, a list of� But sometimes the id's of the mouse change, and that's where my question comes in. What's the simplest way of writing a script/program that finds the id that belongs to the two listings named Logitech G700 Laser Mouse in the output from xinput --list, and then running the commands in the top script using those two ids?

My 2 cents for a Logitech Gaming Mouse G502


for id in `xinput --list|grep 'Logitech Gaming Mouse G502'|perl -ne 'while (m/id=(\d+)/g){print "$1\n";}'`; do
    # echo "setting device ID $id"
    notify-send -t 50000  'Mouse fixed'
    xinput set-prop $id "Device Accel Velocity Scaling" 1
    xinput set-prop $id "Device Accel Constant Deceleration" 3

Python id(), The id() function returns identity (unique integer) of an object. When you run the program, the output will something like: id of dummyFoo = 140343867415240 � Finds Keys for Other Software: Microsoft Office 2007, Office 2003, Office XP, Microsoft Money, Nero, Corel Suite, The Sims, and many more programs. Keyfinder Thing doesn't find the right product keys for Windows 10, Windows 8, or Windows NT, even though one may show up in the results.

I did it like the Answer of Raphael Ahrens but used grep and sed instead of awk and The command is now something like my_script part_of_device_name part_of_property_name_(spaces with \space) value:




if [ "$DEVICE" = "" ]; then 
    exit 1

if [ "$PROP" = "" ]; then 
    exit 1

if [ "$VAL" = "" ]; then 
    exit 1

devlist=$(xinput --list | grep "$DEVICE" | sed -n 's/.*id=\([0-9]\+\).*/\1/p')

for dev in $devlist
    props=$(xinput list-props $dev | grep "$PROP" | grep -v $DEFAULT | sed -n 's/.*(\([0-9]\+\)).*/\1/p')

    for prop in $props
        echo $prop
        xinput set-prop $dev $prop $VAL 

Programming in Objective-C, A method that returns an id type consequently just returns a pointer to some object in memory.You can Have the program find all prime numbers up to n = 150. Most product key finder programs were originally designed to find the serial numbers and key codes for operating systems like Windows 10, 8, 7, Vista, etc., but many of them find serials and keys for many other programs, too, like office suites, video games, and more.

For the fun of it, same answer, but simpler way to parse and get ids:

for id in $(xinput list | grep 'Logitech USB Receiver' |  grep pointer | cut -d '=' -f 2 | cut -f 1); do xinput --set-button-map $id 3 2 1; done

Took me a while to figure out this can get the ids:

xinput | cut -d '=' -f 2 | cut -f 1

Find the Application User Model ID of an installed app, Find the Application User Model ID of an installed app To get the names and AUMIDs for Windows Store apps installed for another \Software\Classes\ ActivatableClasses\Package /s /f AppUserModelID | find "REG_SZ"� Make sure the recipe makes at least 5 servings. Repeat some of these steps until you find the right recipe. Consider the resources at your disposal, such as the capabilities of the system you're developing a program for. In the case of lasagna, we assume the person making the lasagna knows how to search the internet, operate an oven, etc.

Information Assurance and Computer Security, DNS ID Spoofing: A false answer is returned to the DNS request before the DNS server answers. The hacker must guess the query ID (ID: field identification which makes it possible to make the When the war dialing program finds a�

Program to determine class, Network and Host ID of an IPv4 address , Input : Output : Given IP address belongs to Class A Network ID is 1 Host ID Please write comments if you find anything incorrect, or you want to share�

The SAP BW to HANA Migration Handbook, 5.3.7 Matchcode IDs Before a Unicode conversion can be completed, you must convert any will force you to repeat the Unicode version process, so make sure you do not skip this step! If the TWTOOL01 program finds matchcode IDs, use�

  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask.
  • That might be true, but this question is more than 4 years old, and has more than 10k views. Any reason for bringing this up now? Are you going to delete the question?
  • No, I don't have plans to delete it. Someone else cited it as "here's a similar question".
  • Can I call this directly from ~/.xinputrc? It seems like that file gets sourced but I'm not sure.
  • @JarettMillard Yes this looks like a good place to put the script above. But maybe you use the approach of @Schoenix or @SergiyKolodyazhnyy and make the resulting script executable. To then only add /path/to/new_script NAME_OF_DEVICE OTHER_OPT to .xinputrc.
  • This doesn't work for my logitech mouse (xinput list --id-only pointer:"Logitech G203 Prodigy Gaming Mouse"). xinput refuses to print the ids, because "There are multiple devices matching". Kind of silly though.
  • +1 for Vinson Chuong - I'm with @MauricioMachado here. This works for me. My mouse is listed in "Virtual core pointer" and "Virtual core keyboard", therefore I'm doing what Markus proposed. e.g. id="$(xinput list --id-only pointer:'SIGMACHIP Usb Mouse')" xinput --set-prop $id 'Evdev Wheel Emulation' 1 xinput --set-prop $id 'Evdev Wheel Emulation Button' 2 which enables scrolling via middle mouse button click. Thanks.