0

I have two scripts which I would like to be run when I log into my profile.

~/.scripts/startup/user-sensei-raw-startup.sh:

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

unset ids
unset ids_array

~/.scripts/startup/root-sensei-raw-startup.sh:

#!/bin/bash
sensei-raw-ctl --show
sensei-raw-ctl --polling 500
sensei-raw-ctl --cpi-on 450
sensei-raw-ctl --cpi-off 5670

To run them manually I would run the command when I login:

bash ~/.scripts/startup/user-sensei-raw-startup.sh && sudo bash ~/.scripts/startup/root-sensei-raw-startup.sh

The first script can be run via bash however the other script I need to run via sudo bash. Issue is that I must type in my password for the second script to run.

Any ideas of how I can automate this so that I don't have to type in my sudo password all the time? I would also prefer not to save my sudo password in plaintext.

0

I think your best bit would be to wrap the entire script, using shc (Bash script compiler). That way you could use plain text, like echo password | sudo -S script.sh in your script. I suppose someone could decompile, but we're pretty far out there, and then if that's the concern, don't store your sudo password.

Link to SHC.
shc github

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.