How to avoid using sudo for footswitch everytime?
Hi,
Installed footswitch with 'sudo make install' for the device ID 0c45:7404 as of below.
But running footswitch requires superuser everytime. How to avoid 'sudo' for running footswitch every time?! Thanks.
Cheers, /z
$ lsusb -d 0c45:7404 Bus 001 Device 003: ID 0c45:7404 Microdia
$ make cc footswitch.c common.c debug.c -o footswitch -Wall -I/usr/include/hidapi -lhidapi-libusb
$ sudo make install /usr/bin/install -c footswitch /usr/local/bin /usr/bin/install -c -m 644 19-footswitch.rules /etc/udev/rules.d
$ footswitch -r Cannot find footswitch with VID:PID=c45:7403 or VID:PID=c45:7404 [init(), footswitch.c:101]
$ sudo footswitch -r [sudo] password for zenny: [switch 1]: a [switch 2]: b [switch 3]: c
Could you paste the output of lsusb -v -d 0c45:7404?
$ lsusb -v -d 0c45:7404
Bus 001 Device 003: ID 0c45:7404 Microdia Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0c45 Microdia idProduct 0x7404 bcdDevice 0.01 iManufacturer 1 iProduct 2 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 59 bNumInterfaces 2 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 1 Keyboard iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 260 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 2 Mouse iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 41 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10
Maybe this could be useful:
$ dmesg | grep PCsensor [ 4.722210] usb 1-2.1: Manufacturer: PCsensor [ 4.733059] input: PCsensor FootSwitch3-F1.8 as /devices/pci0000:00/0000:00:12.2/usb1/1-2/1-2.1/1-2.1:1.0/input/input11 [ 4.734918] hid-generic 0003:0C45:7404.000A: input,hidraw9: USB HID v1.10 Gamepad [PCsensor FootSwitch3-F1.8] on usb-0000:00:12.2-2.1/input0 [ 4.739577] hid-generic 0003:0C45:7404.000B: hiddev0,hidraw10: USB HID v1.10 Device [PCsensor FootSwitch3-F1.8] on usb-0000:00:12.2-2.1/input1
Could you try to update the first line of 19-footswitch.rules to be:
ATTR{product}=="*FootSwitch*"\
and try again?
Could you try to update the first line of 19-footswitch.rules to be:
ATTR{product}=="FootSwitch"\
and try again?
No changes.
NB: Sorry, the markdown converted "* FootSwitch *" to italic FootSwitch.
You put an asterisk before and after FootSwitch, right? If it doesn't work, you may try to use another attribute (like productId or vendorId) in the udev rule. I will also experiment later because I don't have the device right now.
You put an asterisk before and after FootSwitch, right?
Yep as of below:
$ grep -Rn ATTR /etc/udev/rules.d/19-footswitch.rules 1:ATTR{product}=="FootSwitch"\
Sorry, the markdown converted "* FootSwitch *" to italic FootSwitch.
Hi again,
Replacing /etc/udev/rules.d/19-footswitch.rules with the following let run footswitch without sudo:
KERNEL=="hidraw9[0-11]*", SUBSYSTEM=="hidraw", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0C45", ATTRS{idProduct}=="7404", SYMLINK+="footswitch"
Let me know if there is an easier way than this. Thanks!
Cheers, /z
UPDATE: The above stopped working after a reboot, thus back to square one, forcing to use sudo with footswitch.
@rgerganov Did you have time to look at this issue? Appreciate that!
@zenny I cannot reproduce this problem with my device and my linux distro (Ubuntu). What linux distribution do you use?
I had the same problem. Just tried the recommended change to
FootSwitch
and it worked for me.
So now my /etc/udev/rules.d/19-footswitch.rules contains
ATTR{product}=="*FootSwitch*"\
MODE:="0666"\
GROUP="hid"\
RUN+="keymap $name 0x70066 screenlock"\
SYMLINK+="footswitch"
@robrussell Thanks for the update. Could you paste the output of sudo lsusb -v so we can see the value of the product attribute of your device?
A fast hack (important to understand what it does) is as follows:
sudo chown 0:0 footswitch
sudo chmod 6711 footswitch
This makes the executable always run as root, no matter who runs it.
You can match on ids instead of the name. The Product name for my 3 pedal switch from ebay was 413d/2107/0, so it was easier to just change the rule to:
ATTRS{idVendor}=="413d" ATTRS{idProduct}=="2107" MODE:="0666" GROUP="hid" RUN+="keymap $name 0x70066 screenlock" SYMLINK+="footswitch"