📜 ⬆️ ⬇️

thd or triggerhappy global hotkey daemon

What is it about? Automated USB buttons on a headless server for 200 rubles, or even cheaper.

Introduction: At home there is a "home" server. A sort of box Lenovo q190 size slightly more than a DVD box. There is also a Samsung SCX-4220 MFP. It all works on ubuntu 14.04 LTS, prints nicely through CUPS, scans nicely, but not so with automation.

Sadness: The fact is that on the Samsung there is no separate button to scan on the computer, which could be intercepted and the script run the scan.

Sudden solution : the second month buying another new battery to my laptop, I noticed such a thing on the shop window.
')
USB 7.1 channel sound.

USB 7.1 channel sound

Such zvukovushki lie in almost every store for 200 rubles a bunch. Oh, I think, what if the Chinese + buttons and this is a keyboard? Give me one?

Implementation: I bought it, connected it to the headless q190 and started watching the output

$ lsusb
Bus 001 Device 005: ID 0d8c: 013c C-Media Electronics, Inc. CM108 Audio Controller

Sadly, I think, but decided to look, what else was there in dmesg?

hid-generic 0003: 0D8C: 013C.0002: input, hidraw0: USB HID v1.00 Device [C-Media Electronics Inc. USB PnP Sound Device] on usb-0000: 00: 1a.0-1.4 / input3

Oh, what the doctor ordered. Fine!

Sound card buttons are a small USB keyboard. That's what I need.

THD: github.com/wertarbyte/triggerhappy

In Ubuntu 14.04, he is a "mess".

$ apt-get install thd

Setup:
$ cat /etc/triggerhappy/triggers.d/brj.conf
KEY_VOLUMEDOWN 1 /home/brj/bin/scanme.sh
KEY_VOLUMEUP 1 /home/brj/grab-torrent.sh

By key vol down - starts scanning
On the vol up key, the torente picks up the latest files and starts the jump.

Script launching scan:

#! / bin / sh
outscan = "scan-` data + "% Y-% m-% d-% H% M% S" `"
scanimage --progress --mode Color --format = tiff --resolution 300> /tmp/image.tiff
convert /tmp/image.tiff /home/brj/Dropbox/${outscan}.jpg
rm /tmp/image.tiff

Practical work: at first, he additionally hung sounds from super mario and mpg123 to know if it works or not. The system is working properly, so removed.

Where else to use? Such a thing is limited only by the imagination and the number of buttons. It is possible to switch the Internet to a backup channel, scan, overload servers / services, make archiving to an external screw, in general, what is enough for imagination to automate.

Successes.

Source: https://habr.com/ru/post/257445/


All Articles