Sponsored Content
Top Forums Shell Programming and Scripting Poll Wacom input from "libinput debug-events" in Bash Post 303039686 by mrjpaxton on Saturday 12th of October 2019 12:43:42 AM
Old 10-12-2019
Poll Wacom input from "libinput debug-events" in Bash

Hey,

I am making a Bash shell script to grab input from libinput. There's a few reasons why I am doing it this way:
  1. Using Python with python-libinput does not work. I installed version 0.1.0 with pip, and it complains about "ContextType" not existing. So that's a no-go.
  2. I am trying to get away from my dependence on Xorg-related stuff, such as xsetwacom and xserver-input-wacom, and do things that are more compatible with Wayland.
  3. Both methods above do not have support for the four different modes when you press the center ring button on the ExpressKey pad. I plan to eventually support all of these events.

Without explaining my entire plan of this script, I figured I could ask the question that's harder for me to understand, and figure out the rest as I go along.

I want to poll the outputs from "libinput debug-events" in an infinite loop Bash script that will run in the background. This polling will happen, say, every 1 second.

This pseudocode down below can help explain what I am looking to do to start out my script:

Code:
#!/bin/bash
  
while true; do
  sleep 1
  OUTPUT=$(libinput debug-events | grep "TABLET_PAD_BUTTON")
  case ${OUTPUT} in
  "4 pressed (mode 0)")
    echo "Button 4"
    ;;
    # Etc . . .
  esac
done

My big problem is figuring out how to do this.

The thing is, "libinput debug-devices" works a lot like showkey or xev, but not exactly. For some reason, stdin for "TABLET_PAD_BUTTON" is "frozen" until I move the mouse around. Why this is, I have no idea. Regardless to say, I feel like I may be overcomplicating my problem, or I just don't really see a clear cut solution. Doing it this way just doesn't work right, as it is.

The libinput binary program will need to somehow exit after a period of time, because by default it is left running, so some sort of control implementation needs to exist there. Also, I notice that when it loops back to "OUTPUT=xyz" the existing variable data should be replaced by new input data again, which is great. That's exactly how it should work in that case.

Finally, this is a script that needs to run in the background (like a daemon process), and also accept input from libinput/udev devices at all times. And I'm not sure if Bash is powerful enough to tell the libinput binary to do that, is the thing.... If this really needs to be written in C, then perhaps there's no good solution here, and the thread can be closed if that's the case.

Anybody have any idea how I could approach this problem, or could even possibly provide a good bash script solution? Thank you very much in advance!

Last edited by mrjpaxton; 10-12-2019 at 01:55 AM..
 

9 More Discussions You Might Find Interesting

1. Programming

How to convert the "select" function into a "poll" function

i have a program using the select function but i want to convert it to poll... how can i do this? thanks in advance... :) (1 Reply)
Discussion started by: rbolante
1 Replies

2. Shell Programming and Scripting

check input = "empty" and "numeric"

Hi how to check input is "empty" and "numeric" in ksh? e.g: ./myscript.ksh k output show: invalid number input ./myscript.ksh output show: no input ./myscript.ksh 10 output show: input is numeric (6 Replies)
Discussion started by: geoffry
6 Replies

3. UNIX for Advanced & Expert Users

kernel debug:"Symbol file not found for *.ko"

When I debug vmlinux with gdb, after it connect to the target, I got below output: usbcore.ko: No such file or directory. Error while mapping shared library sections: ohci_hcd.ko: No such file or directory. Symbol file not found for usbcore.ko Symbol file not found for ohci_hcd.ko Symbol... (2 Replies)
Discussion started by: yanglei_fage
2 Replies

4. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Explaining behaviour of sudo bash "$0" "$@";

I've found this script part on the stackoverflow: if ; then sudo bash "$0" "$@"; exit "$?"; fi I realized that sudo bash "$0" "$@"; is the only needed for me. But the strange thing happens when I move this line outside the IF statement: sudo bash "$0" "$@"; stops the... (9 Replies)
Discussion started by: boqsc
9 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
IDLE(1) 						      General Commands Manual							   IDLE(1)

NAME
IDLE - An Integrated DeveLopment Environment for Python SYNTAX
idle [ -dins ] [ -t title ] [ file ...] idle [ -dins ] [ -t title ] ( -c cmd | -r file ) [ arg ...] idle [ -dins ] [ -t title ] - [ arg ...] DESCRIPTION
This manual page documents briefly the idle command. This manual page was written for Debian because the original program does not have a manual page. For more information, refer to IDLE's help menu. IDLE is an Integrated DeveLopment Environment for Python. IDLE is based on Tkinter, Python's bindings to the Tk widget set. Features are 100% pure Python, multi-windows with multiple undo and Python colorizing, a Python shell window subclass, a debugger. IDLE is cross-plat- form, i.e. it works on all platforms where Tk is installed. OPTIONS
-h Print this help message and exit. -n Run IDLE without a subprocess (see Help/IDLE Help for details). The following options will override the IDLE 'settings' configuration: -e Open an edit window. -i Open a shell window. The following options imply -i and will open a shell: -c cmd Run the command in a shell, or -r file Run script from file. -d Enable the debugger. -s Run $IDLESTARTUP or $PYTHONSTARTUP before anything else. -t title Set title of shell window. A default edit window will be bypassed when -c, -r, or - are used. [arg]* and [file]* are passed to the command (-c) or script (-r) in sys.argv[1:]. EXAMPLES
idle Open an edit window or shell depending on IDLE's configuration. idle foo.py foobar.py Edit the files, also open a shell if configured to start with shell. idle -est "Baz" foo.py Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell window with the title "Baz". idle -c "import sys; print sys.argv" "foo" Open a shell window and run the command, passing "-c" in sys.argv[0] and "foo" in sys.argv[1]. idle -d -s -r foo.py "Hello World" Open a shell window, run a startup script, enable the debugger, and run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in sys.argv[1]. echo "import sys; print sys.argv" | idle - "foobar" Open a shell window, run the script piped in, passing '' in sys.argv[0] and "foobar" in sys.argv[1]. SEE ALSO
python(1). AUTHORS
Various. 21 September 2004 IDLE(1)
All times are GMT -4. The time now is 01:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy