Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#!/usr/bin/env python # Copyright Kris Occhipinti # June 27th 2018 # https://filmsbykris.com # Licensed under the GPLv3 # https://www.gnu.org/licenses/gpl-3.0.txt # # Allows normal HID Keyboard like device to be read in background # Install needed files # sudo apt install xinput python-evdev # # Disable device as HID in Xorg (Sycreader in my exmaple) # xinput --disable "$(xinput|grep "Sycreader RFID Technology"|cut -d\= -f2|awk '{print $1}')" # # You will probably want to make the device readable rather then run this script as root # sudo chmod +r /dev/input/by-id/usb-Sycreader_RFID_Technology_Co.__Ltd_SYC_ID_IC_USB_Reader_08FF20140315-event-kbd # (again Sycreader_RFID is my device change to your device import os from evdev import InputDevice, categorize, ecodes output = "" #set your device dev = "/dev/input/by-id/usb-Sycreader_RFID_Technology_Co.__Ltd_SYC_ID_IC_USB_Reader_08FF20140315-event-kbd" device = InputDevice(dev) # my keyboard #check list of codes and run command if cound def find_command(code): for line in open("codes.lst"): if code in line: command = line.split("|")[1].rstrip("\n\r") + " &" print(command) os.system(command) #main loop for event in device.read_loop(): if event.type == ecodes.EV_KEY & event.value == 1: #print(categorize(event)) # 28 is enter key. #so when "Enter" is pressed if event.code == 28: print(output) find_command(output) # if output == "2267233788": # os.system("/usr/games/minetest &") #clear Variable output = "" else: #if "Enter" is not pressed add last value to string output += str(event.code)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)