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
BASHBUG(1)							      bashbug								BASHBUG(1)

NAME
bashbug - report a bug in bash SYNOPSIS
bashbug [--help] [--version] [bug-report-email-addresses] DESCRIPTION
bashbug is a utility for reporting bugs in Bash to the maintainers. bashbug will start up your preferred editor with a preformatted bug report template for you to fill in. Save the file and quit the editor once you have completed the missing fields. bashbug will notify you of any problems with the report and ask for confirmation before sending it. By default the bug report is mailed to both the GNU developers and the Debian Bash maintainers. The recipients can be changed by giving a comma separated list of bug-report-email-addresses. If you invoke bashbug by accident, just quit your editor. You will always be asked for confirmation before a bug report is sent. OPTIONS
--help Show a brief usage message and exit. --version Show the version of bashbug and exit. bug-report-email-addresses Comma separated list of recipients' email addresses. By default the report is mailed to both the GNU developers and the Debian Bash maintainers. ENVIRONMENT
DEFEDITOR Editor to use for editing the bug report. EDITOR Editor to use for editing the bug report (overridden by DEFEDITOR). SEE ALSO
bash(1), reportbug(1), update-alternatives(8) for preferred editor. AUTHOR
This manual page was written by Christer Andersson <klamm@comhem.se> for the Debian project (but may be used by others). GNU Bash 3.1 11 December 2007 BASHBUG(1)
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy