How can I run a shell script on input device event
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a USB remote presenter that appears as a keyboard.
Using evtest
I can see the input events from the device.
How can I capture those events in a shell script?
I had see some solutions using C
but I would prefer something with only bash
if possible.
I already tried something with xbindkeys
, but my keyboard events were captured as well and I don't want that.
I also read something about udev rules
but seems to me that these rules are only useful for plug and unplug events.
shell-script usb devices input events
add a comment |Â
up vote
1
down vote
favorite
I have a USB remote presenter that appears as a keyboard.
Using evtest
I can see the input events from the device.
How can I capture those events in a shell script?
I had see some solutions using C
but I would prefer something with only bash
if possible.
I already tried something with xbindkeys
, but my keyboard events were captured as well and I don't want that.
I also read something about udev rules
but seems to me that these rules are only useful for plug and unplug events.
shell-script usb devices input events
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a USB remote presenter that appears as a keyboard.
Using evtest
I can see the input events from the device.
How can I capture those events in a shell script?
I had see some solutions using C
but I would prefer something with only bash
if possible.
I already tried something with xbindkeys
, but my keyboard events were captured as well and I don't want that.
I also read something about udev rules
but seems to me that these rules are only useful for plug and unplug events.
shell-script usb devices input events
I have a USB remote presenter that appears as a keyboard.
Using evtest
I can see the input events from the device.
How can I capture those events in a shell script?
I had see some solutions using C
but I would prefer something with only bash
if possible.
I already tried something with xbindkeys
, but my keyboard events were captured as well and I don't want that.
I also read something about udev rules
but seems to me that these rules are only useful for plug and unplug events.
shell-script usb devices input events
edited Mar 6 at 2:49
Jeff Schaller
31.2k846105
31.2k846105
asked Mar 6 at 1:45
paulequilibrio
131115
131115
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
This example is monitoring taps on touchpad:
xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad"
| grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
done
You can easily modify it for your needs.
add a comment |Â
up vote
0
down vote
@JeffSchaller, thank you for the edits.
Based on @IporSircer's answer (thanks!), I was able to create the following script:
#!/bin/bash
device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
event_blank='*code 48 (KEY_B), value 1*'
event_esc='*code 1 (KEY_ESC), value 1*'
event_f5='*code 63 (KEY_F5), value 1*'
event_prev='*code 104 (KEY_PAGEUP), value 1*'
event_next='*code 109 (KEY_PAGEDOWN), value 1*'
evtest "$device" | while read line; do
case $line in
($event_blank) echo "BLANK SCREEN" ;;
($event_f5) echo "F5" ;;
($event_esc) echo "ESCAPE" ;;
($event_prev) echo "PREVIOUS" ;;
($event_next) echo "NEXT" ;;
esac
done
Using evtest
I was able to find out the event number /dev/input/event18
for the device, but this number may vary depending on the devices on your system and in which order they were connected
Because of that I used udevadm info /dev/input/event18
to find out the device's unique id
S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd
Finally, using evtest
again I was able to catch all events from device to use them on the case
statement.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
This example is monitoring taps on touchpad:
xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad"
| grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
done
You can easily modify it for your needs.
add a comment |Â
up vote
2
down vote
This example is monitoring taps on touchpad:
xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad"
| grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
done
You can easily modify it for your needs.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
This example is monitoring taps on touchpad:
xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad"
| grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
done
You can easily modify it for your needs.
This example is monitoring taps on touchpad:
xinput test-xi2 --root "AlpsPS/2 ALPS DualPoint TouchPad"
| grep --line-buffered "EVENT type 15 (RawButtonPress)"| while read line; do
paplay --volume 22000 -d $PULSE_SINK $HOME/scripts/data/click.aiff
done
You can easily modify it for your needs.
edited Mar 6 at 17:05
answered Mar 6 at 7:37
Ipor Sircer
8,7951920
8,7951920
add a comment |Â
add a comment |Â
up vote
0
down vote
@JeffSchaller, thank you for the edits.
Based on @IporSircer's answer (thanks!), I was able to create the following script:
#!/bin/bash
device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
event_blank='*code 48 (KEY_B), value 1*'
event_esc='*code 1 (KEY_ESC), value 1*'
event_f5='*code 63 (KEY_F5), value 1*'
event_prev='*code 104 (KEY_PAGEUP), value 1*'
event_next='*code 109 (KEY_PAGEDOWN), value 1*'
evtest "$device" | while read line; do
case $line in
($event_blank) echo "BLANK SCREEN" ;;
($event_f5) echo "F5" ;;
($event_esc) echo "ESCAPE" ;;
($event_prev) echo "PREVIOUS" ;;
($event_next) echo "NEXT" ;;
esac
done
Using evtest
I was able to find out the event number /dev/input/event18
for the device, but this number may vary depending on the devices on your system and in which order they were connected
Because of that I used udevadm info /dev/input/event18
to find out the device's unique id
S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd
Finally, using evtest
again I was able to catch all events from device to use them on the case
statement.
add a comment |Â
up vote
0
down vote
@JeffSchaller, thank you for the edits.
Based on @IporSircer's answer (thanks!), I was able to create the following script:
#!/bin/bash
device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
event_blank='*code 48 (KEY_B), value 1*'
event_esc='*code 1 (KEY_ESC), value 1*'
event_f5='*code 63 (KEY_F5), value 1*'
event_prev='*code 104 (KEY_PAGEUP), value 1*'
event_next='*code 109 (KEY_PAGEDOWN), value 1*'
evtest "$device" | while read line; do
case $line in
($event_blank) echo "BLANK SCREEN" ;;
($event_f5) echo "F5" ;;
($event_esc) echo "ESCAPE" ;;
($event_prev) echo "PREVIOUS" ;;
($event_next) echo "NEXT" ;;
esac
done
Using evtest
I was able to find out the event number /dev/input/event18
for the device, but this number may vary depending on the devices on your system and in which order they were connected
Because of that I used udevadm info /dev/input/event18
to find out the device's unique id
S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd
Finally, using evtest
again I was able to catch all events from device to use them on the case
statement.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
@JeffSchaller, thank you for the edits.
Based on @IporSircer's answer (thanks!), I was able to create the following script:
#!/bin/bash
device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
event_blank='*code 48 (KEY_B), value 1*'
event_esc='*code 1 (KEY_ESC), value 1*'
event_f5='*code 63 (KEY_F5), value 1*'
event_prev='*code 104 (KEY_PAGEUP), value 1*'
event_next='*code 109 (KEY_PAGEDOWN), value 1*'
evtest "$device" | while read line; do
case $line in
($event_blank) echo "BLANK SCREEN" ;;
($event_f5) echo "F5" ;;
($event_esc) echo "ESCAPE" ;;
($event_prev) echo "PREVIOUS" ;;
($event_next) echo "NEXT" ;;
esac
done
Using evtest
I was able to find out the event number /dev/input/event18
for the device, but this number may vary depending on the devices on your system and in which order they were connected
Because of that I used udevadm info /dev/input/event18
to find out the device's unique id
S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd
Finally, using evtest
again I was able to catch all events from device to use them on the case
statement.
@JeffSchaller, thank you for the edits.
Based on @IporSircer's answer (thanks!), I was able to create the following script:
#!/bin/bash
device='/dev/input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd'
event_blank='*code 48 (KEY_B), value 1*'
event_esc='*code 1 (KEY_ESC), value 1*'
event_f5='*code 63 (KEY_F5), value 1*'
event_prev='*code 104 (KEY_PAGEUP), value 1*'
event_next='*code 109 (KEY_PAGEDOWN), value 1*'
evtest "$device" | while read line; do
case $line in
($event_blank) echo "BLANK SCREEN" ;;
($event_f5) echo "F5" ;;
($event_esc) echo "ESCAPE" ;;
($event_prev) echo "PREVIOUS" ;;
($event_next) echo "NEXT" ;;
esac
done
Using evtest
I was able to find out the event number /dev/input/event18
for the device, but this number may vary depending on the devices on your system and in which order they were connected
Because of that I used udevadm info /dev/input/event18
to find out the device's unique id
S: input/by-id/usb-Targus_Laser_Presentation_Remote-if02-event-kbd
Finally, using evtest
again I was able to catch all events from device to use them on the case
statement.
answered Mar 6 at 14:05
paulequilibrio
131115
131115
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428399%2fhow-can-i-run-a-shell-script-on-input-device-event%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password