4
#!/bin/bash
ids=$(xinput list | awk '/SteelSeries Sensei Raw Gaming Mouse .*pointer/ {print $8}' | sed 's/id=\(.*\)/\1/')

if [ -z "$ids" ]; then
  exit 0;
fi

read -a ids_array <<< $ids

echo fixing id ${ids_array[0]}
xinput set-prop ${ids_array[0]} 'Device Accel Profile' -1
xinput set-prop ${ids_array[0]} 'Device Accel Constant Deceleration' 2.5
xinput set-prop ${ids_array[0]} 'Device Accel Adaptive Deceleration' 1
xinput set-prop ${ids_array[0]} 'Device Accel Velocity Scaling' 1

echo fixing id ${ids_array[1]}
xinput set-prop ${ids_array[1]} 'Device Accel Profile' -1
xinput set-prop ${ids_array[1]} 'Device Accel Constant Deceleration' 1.5
xinput set-prop ${ids_array[1]} 'Device Accel Adaptive Deceleration' 1
xinput set-prop ${ids_array[1]} 'Device Accel Velocity Scaling' 1

sudo sensei-raw-ctl --show
sudo sensei-raw-ctl --polling 500
sudo sensei-raw-ctl --cpi-on 450
sudo sensei-raw-ctl --cpi-off 5670

unset ids
unset ids_array

I wish for the following script to run once when I login or when the computer starts up. The above script is located in /home/karl/.scripts/startup/sensei-raw-startup.sh.

I DO NOT wish to use the GUI to add the script. I wish to learn a bit more about how to do it manually.

What files do I need to create, what must be in them and where should they be located to be able to run my script which is located in the said directory.

9

1. Using /etc/profile.d

You can run the script on login by placing the script in /etc/profile.d/

These files are executed upon login.

To create a symbolic link to the file you want to execute, use

sudo ln -s /home/karl/.scripts/startup/sensei-raw-startup.sh /etc/profile.d/myscript.sh

2. Using upstart

Another possibility is to use upstart

start on desktop-session-start

and place your script there.

  • How does this handle sudo commands? – Karl Morrison Dec 2 '15 at 1:13
  • @KarlMorrison echo "password" | sudo -S command – mcantsin Dec 2 '15 at 1:22
  • Where is that supposed to reside? In the file? You need to be a little more specific (I'm still learning this stuff!). – Karl Morrison Dec 2 '15 at 1:23
  • @KarlMorrison personally I think you should use the upstart solution, as /etc/profile.d is not really meant to be used like this. My suggestion is more a "hack". I you still want to try, just add the echo "password" in front of the | sudo -S part, whereafter sudo won't ask for the password any more. – mcantsin Dec 2 '15 at 1:25
  • Indeed I've tried: askubuntu.com/questions/704815/upstart-not-running-sh-script perhaps you could see whats wrong? :/ – Karl Morrison Dec 2 '15 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.