Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    xset in UDEV-rule not working


    Hello,

    I am stuck with this udev problem for a long time now. And I can't figure it out by myself, even after doing quite some research. So I'll ask it here:

    Every time I plug in my external keyboard I want to adjust the delay and autorepeat with xset like this:
    Code:
    xset r rate 150 60
    Just for doing that I wrote this udev rule:
    Code:
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="046a", ATTRS{idProduct}=="0011", ACTION=="add", SYMLINK+="cherry_keyboard", ENV{DISPLAY}=":0.0", RUN+="/home/nnmaed/udev_cherry_keyboard.sh"
    The script:

    Code:
    #!/bin/bash
    
    export XAUTHORITY=/home/nnmaed/.Xauthority
    export DISPLAY=:0
    
    touch /home/nnmaed/yyy
    xset r rate 150 60
    touch /home/nnmaed/zzz
    The rule works just fine. The symlink is created and both of the test files yyy and zzz are created. BUT, the only thing that gets 'ignored' is the xset command.

    For the life of me I can't figure out why.

    In an other forum I read, that it had something to do with the xsession. Someone suggested I should add the XAUTHORITY and DISPLAY variables so udev could link the script to the current xsession. I did that but to no avail.

    I also read somewhere that it doesn't work because the script is executed as root but the xset command must be executed only as user. But when I execute
    Code:
    sudo su
    xset r rate 150 60
    from the terminal, it works.

    Another strange thing is that it seems to work for other people:

    bbs.archlinux.org/viewtopic.php?id=105335


    I hope that someone can help me with this very annoying issue.

  2. #2
    Quote Originally Posted by nnmaed View Post
    The script:
    Code:
    #!/bin/bash
    
    export XAUTHORITY=/home/nnmaed/.Xauthority
    export DISPLAY=:0
    
    touch /home/nnmaed/yyy
    xset r rate 150 60
    touch /home/nnmaed/zzz
    The rule works just fine. The symlink is created and both of the test files yyy and zzz are created. BUT, the only thing that gets 'ignored' is the xset command.
    try
    Code:
    xset r rate 150 60 >  /home/nnmaed/zzz 2>&1
    maybe you can glean some extra info from that.




    In an other forum I read, that it had something to do with the xsession. Someone suggested I should add the XAUTHORITY and DISPLAY variables so udev could link the script to the current xsession. I did that but to no avail.

    I also read somewhere that it doesn't work because the script is executed as root but the xset command must be executed only as user. But when I execute
    Code:
    sudo su
    xset r rate 150 60
    that still could be the reason.
    anyhow you can't use sudo su in a script like that.
    try
    Code:
    sudo -u nnmaed xset r rate 150 60 >  /home/nnmaed/zzz 2>&1




    Another strange thing is that it seems to work for other people:

    bbs.archlinux.org/viewtopic.php?id=105335
    that's a long thread and i'm pressed for time; can you shows us exactly WHAT in that thread makes you think that?

  3. #3
    Linux Guru Segfault's Avatar
    Join Date
    Jun 2008
    Location
    Acadiana
    Posts
    1,568
    Did you think in what environment this script is running? Is the $PATH set for this environment? It is possible the commands touch and xset are not found.

  4. $spacer_open
    $spacer_close
  5. #4
    I believe the issue is that your rule is triggered multiple times .you can verify if this is the case with udevadm monitor.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •