-   Linux - Laptop and Netbook (
-   -   acpi script to change LED requires root and I need to make it not require root. (

Sidicas 01-31-2013 11:12 PM

acpi script to change LED requires root and I need to make it not require root.
Distro: Debian Wheezy (Testing)
Laptop: Dell Inspiron 15R Special Edition (2012)
CPU: Intel Core i7 Ivy Bridge


I bought a new Dell 15R Special Edition laptop (2012 model).

The function key to enable/disable the touchpad does not work although I see that xev is generating X86TouchpadToggle events.

I found that /etc/acpi/ works for disabling the touchpad since it's the same touchpad as Asus laptops.

However, this script has a problem in that it assumes the laptop has an asus led, which it doesn't.

So I've created a new script to work with my laptop, as follows...


< ledf=/sys/class/leds/asus::touchpad/brightness
> ledf=/sys/class/leds/dell-laptop::touchpad/brightness source which I copy&pasted from


set -e

[ -f $pff ] || exit 0

atp_error() {
        logger -t${0##*/} -perr -- $*
        exit 1

. $pff || atp_error "Sourcing $pff failed"

[ -x /usr/bin/xinput ] || atp_error "Please install package xinput to enable toggling of touchpad devices."


    # extract the device id for the supplied touch device name
    # XXX:      according to man page 'list', 'list-props' and 'set-int-prop' are
    #  options, not arguments.
    xinput --list | sed -nr "s|.*$1.*id=([0-9]+).*|\1|p"

ENABLEPROP="Synaptics Off"
# Get the xinput device number and enabling property for the touchpad
XINPUTNUM=$(getTouchDeviceId "SynPS/2 Synaptics TouchPad")

if [ -z "$XINPUTNUM" ]; then
    XINPUTNUM=$(getTouchDeviceId "PS/2 Elantech Touchpad")
    ENABLEPROP="Device Enabled"

# if we failed to get an input, exit
[ "$XINPUTNUM" ] || atp_error "Invalid TouchPad id '$XINPUTNUM'"

# get the current state of the touchpad
TPSTATUS=$(xinput --list-props $XINPUTNUM | awk "/$ENABLEPROP/ { print \$NF }")
case $TPSTATUS in
                atp_error "Invalid TouchPad status '$TPSTATUS'"

# XXX: '--set-int-prop' deprecated
xcmd="xinput --set-int-prop $XINPUTNUM '$ENABLEPROP' 8"
if [ $TPSTATUS -eq 0 ]; then
        eval $xcmd 1 || atp_error "Command '$xcmd 1' failed"
        [ ! -w $ledf ] || echo 0 >$ledf ||
                atp_error "Writing 0 to $ledf failed"
        eval $xcmd 0 || atp_error "Command '$xcmd 0' failed"
        [ ! -w $ledf ] || echo 1 >$ledf ||
                atp_error "Writing 0 to $ledf failed"

It works PERFECTLY on my Dell laptop.

My problem is that it appears that I need sudo or root access to run this script. I want to somehow bind this script to the function key Fn+F3 which triggers a XF86TouchpadToggle key event.

Any ideas/suggestions? I've tried kde-config-touchpad and ktouchpadenabler. ktouchpadenabler only disables the touchpad until it is touched (worthless, possibly a bug) and kde-config-touchpad doesn't seem to provide a way to completely disable the touchpad by the keyboard.

Further, when I try to bind XF86TouchpadToggle to any hotkeys inside of KDE, I get an error popup that says "The key you just pressed is not supported by QT"!

So I need to somehow go *around* kde to get this done.. I'm not sure how to do it..
Right now, I'm just executing the script manually in a console with sudo or root and it works for toggling the touchpad (including LED status!) but I'm not sure what the proper way to do it is.

Any help is greatly appreciated.


[    0.000000] DMI: Dell Inc. Inspiron 7520/0PXH02, BIOS A07 10/03/2012
[    7.953394] dcdbas dcdbas: Dell Systems Management Base Driver (version 5.6.0-3.2)
[    8.104005] input: Dell WMI hotkeys as /devices/virtual/input/input8

Edit #2:
An acpi event is *not* generated when I press the Fn+F3 button to toggle the touchpad.. So I guess I *CAN'T* use acpid to run the script. What can I do??

Sidicas 02-01-2013 12:07 AM

Alright, I've got it... After spending a while looking through other people trying to manipulate system leds from userspace by doing ridiculous things (editing udev rules, ick!)

I added this to /etc/sudoers:

myusername ALL = (root) NOPASSWD: /etc/acpi/

And I also made sure that /etc/acpi/ is read-only, executable for everybody.

Which allows me to execute "sudo /etc/acpi/" without prompting for a password. Now I just need to bind this script to XF86TouchpadToggle and I'm done.

All times are GMT -5. The time now is 08:57 PM.