Creative Commons License

This work is licenced under a Creative Commons Licence.

User login

USB Panic Button on Linux

I found this USB "big red button" recently, and decided that I'd love to have a play with it, using it to run dangerous scripts. At just £5, it was worth the risk of lack of Linux support.

When it arrived, I was initially relieved, as it was detected at least by my system:

Bus 001 Device 007: ID 1130:0202 Tenx Technology, Inc.

However, even going down to looking at the scancodes, I couldn't detect any status changes in the switch when pressed. I initially thought I was going to have to hack a driver out of a generic USB mouse driver, which as I don't know C would have been hard.

Fortunately, Google threw up links to this page, which is a perl module to interface with the button. Obviously, this means that somewhere that I was missing, the kernel was detecting the button presses. Rather than re-inventing the wheel, it was obvious that I should use this module to do my work.

On my Ubuntu 8.10 (Intrepid Ibex) machine, I first had to install libinline-perl (and libyaml-perl to stop some CPAN warnings), and then the module in CPAN.

$ sudo aptitude install libinline-perl libyaml-perl
$ sudo cpan
### If this is your first use of CPAN, you'll need to let it run it's configuration process.
### Accepting defaults for this should be fine.
install Device::USB::PanicButton

Now we're ready to use our button via the perl script on the pagelinked to earlier.

    use Device::USB::PanicButton;

    my $pbutton = Device::USB::PanicButton->new();

    if(!$pbutton || $pbutton->error()) {
        printf(STDERR "FATAL: ". $pbutton->error() ."\n");

    while(1) {
        my $result = $pbutton->pressed();

        if($result == 1) {
###            printf("PANIC ;)\n");
               system( "/home/lunarlamp/" );

        } elsif($result < 0) {
            printf(STDERR "WARN: ". $pbutton->error() ."\n");


As you can see, I changed the script to run the bash script that I had already written as I did not want to have to rewrite it in Perl.

I hope this helps anyone else to quickly work out how to use this fun little device under Linux.

Dream Cheeky Button

I got the "big red button" from Dream Cheeky.
lsusb says: Bus 004 Device 004: ID 1d34:000d
With the mentioned lib from freshmeat it does not work, not after changing the vendor_id and product_id to the given values.
usb_set_configuration(pbdev, 1) fails -> busy
usb_claim_interface(pbdev, 0) fails -> nomem

Anyone knows what the difference is and how to use this button?

It appears under /dev/usb/hiddev1, but nothing to see on a cat and pressing the button..

Details of lsusb (-v) here:

dream cheeky driver

Here's some code to drive the dream cheeky button. You can drop me a line at [email protected] if you get stuck.


import time
import usb

def findButton():
for bus in usb.busses():
for dev in bus.devices:
if dev.idVendor == 0x1d34 and dev.idProduct == 0x000d:
return dev

dev = findButton()
handle =
interface = dev.configurations[0].interfaces[0][0]
endpoint = interface.endpoints[0]

except Exception, e:
# It may already be unloaded.


while 1:
# USB setup packet. I think it's a USB HID SET_REPORT.
result = handle.controlMsg(requestType=0x21, # OUT | CLASS | INTERFACE
request= 0x09, # SET_REPORT
value= 0x0200, # report type: OUTPUT

result = handle.interruptRead(endpoint.address, endpoint.maxPacketSize)
print [hex(x) for x in result]
except Exception, e:
# Sometimes this fails. Unsure why.

time.sleep(endpoint.interval * 0.001) # 10ms


I've been trying to get this

I've been trying to get this implementation to work for some time, and keep getting a segmentation fault every time when I get to the 'use Device::USB::PanicButton;' I also get the error message that I must be running as root if i trying to kick off the script when not sudo'ed in. Has anyone run into this issue before? Are these two related? I appreciate the support!

I had the same problem with

I had the same problem with segmentation faults. My solution was to uninstall Device::USB:PanicButton and Device::USB via cpanp and reinstall them. After that, it works.

Great generic driver

I use this one:
It works perfectly on Linux and a whole lot of other systems and is very easy to use.

Repost driver?

The code is no longer available at the download link from freshmeat/freecode. Could someone who already downloaded this please put it back up somewhere for others to share?




This worked perfectly to fire off a photo booth script. You made me look really good at my sister's wedding!


What a bunch of fun! Thanks for the innovative idea.


Have you found a good use for it?


At work I have to, frequently but irregularly, run a script that releases newly committed code from our developers to our testing platform. I've hooked this button up so that it runs that bash script, and now it's no effort whatsoever for me to do so, and makes me giggle with childlike glee each and every time.