Skip to content

Commit

Permalink
edotool ver 1.03c
Browse files Browse the repository at this point in the history
  • Loading branch information
evuraan committed Aug 21, 2021
1 parent 5a9beca commit 1d80153
Show file tree
Hide file tree
Showing 7 changed files with 690 additions and 1 deletion.
114 changes: 113 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
# edotool
# edotool
Simulate keystrokes. `X11` and `Wayland` supported.

<img src="https://user-images.githubusercontent.com/39205936/130298707-8c845a13-4438-4bdc-a815-89451f549db6.png" width="50%">

[edotool](https://evuraan.info/evuraan/stuff/edotool.png)

## Screengrab
Using `edotool` keystrokes can be sent remotely to the active window.
```bash
$ sleep 10; for i in `seq 1 5`; do ./edotool -i /dev/input/event9 -e "$i: She sells seasells, at the seashore. ${RANDOM}"; ./edotool -i /dev/input/event9 -e "KEY_ENTER"; echo "Sent $i"; done
```

https://user-images.githubusercontent.com/39205936/130187383-776d230f-2dbd-480b-9446-feb444831ed9.mp4

[mp4](https://evuraan.info/evuraan/stuff/edotool.mp4) | [gif](./edotool.gif)

## Usage
```bash
$ ./edotool -h
Usage: ./edotool
-h --help print this usage and exit
-v --version print version information and exit
-d --debug show verbose output
-k --keys show available keys
-i /dev/input/event1 kbd device to use
-e --events events to relay
```
### Using /dev/input/eventXX
If you are a member of `input` group, `edotool` can be run without root permissions.
```bash
sudo gpasswd -a $USER input
newgrp input
```
In this mode, `edotool` will try to locate an appropriate `input` device it can use.
* If an appropriate kbd device cannot be found, `edotool` will ask you to specify a suitable device using the `-i` option.
```bash
$ ./edotool -i /dev/input/event9 -e "She sells seasells, at the seashore."
She sells seasells, at the seashore.
```
### Using /dev/uinput
`/dev/uinput` requires root permission:
```bash
$ ./edotool -i /dev/uinput -e "She sells seasells, at the seashore."
Error opening /dev/uinput: Permission denied
```
Retrying, with `sudo` access:
```bash
$ sudo ./edotool -i /dev/uinput -e "She sells seasells, at the seashore."
She sells seasells, at the seashore.
```
### Sending key codes
Specific keystrokes can be sent, either chained together with a `+` or individually:
```bash
$ ./edotool -i /dev/input/event9 -e "KEY_SPACE + KEY_S + KEY_A + KEY_D + KEY_SPACE"
sad
```
#### keys supported:
Use `-k` option to get a list of supported keys:
```bash
$ ./edotool -k | head -10
Available keys:
key --> KEY_LEFT_UP
key --> KEY_CHANNELUP
key --> KEY_FN_1
key --> KEY_BATTERY
key --> KEY_UWB
key --> KEY_WWAN
key --> KEY_BOOKMARKS
key --> KEY_F24
./snip/.
```
### Debug mode
Send `-d` to turn on debugging. This would produce a <b>lot</b> of debug output:
```bash
$ ./edotool -i /dev/input/event9 -e "KEY_SPACE + KEY_M + KEY_A + KEY_D + KEY_SPACE" -d
Thu Aug 19 22:41:09 2021 edotool/1.03a Incoming events: KEY_SPACE + KEY_M + KEY_A + KEY_D + KEY_SPACE
Thu Aug 19 22:41:09 2021edotool/1.03aCopyright © 2021 Evuraan <evuraan@gmail.com>. All rights reserved.
This program comes with ABSOLUTELY NO WARRANTY.
Thu Aug 19 22:41:09 2021 edotool/1.03a Howdy!
Thu Aug 19 22:41:09 2021 edotool/1.03a keyboard device: /dev/input/event9
Thu Aug 19 22:41:09 2021 [C] [getFd] fd opened: 3
Thu Aug 19 22:41:09 2021 edotool/1.03a key: KEY_SPACE val: 57
Thu Aug 19 22:41:09 2021 edotool/1.03a key: KEY_M val: 50
Thu Aug 19 22:41:09 2021 edotool/1.03a key: KEY_A val: 30
Thu Aug 19 22:41:09 2021 edotool/1.03a key: KEY_D val: 32
Thu Aug 19 22:41:09 2021 edotool/1.03a key: KEY_SPACE val: 57
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 57
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 50
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 30
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 32
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 57
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 0 code 0
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 57
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 50
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 30
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 32
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 1 code 57
Thu Aug 19 22:41:09 2021 [C] [emit] emitted 24 bytes type 0 code 0
Thu Aug 19 22:41:09 2021 [C] [handleEvents] Handled 5 events
Thu Aug 19 22:41:09 2021 edotool/1.03a Bye bye!
mad
```
## Optional: Build
If you prefer to build yourself, you will need the [Go Programming Language](https://golang.org/dl/) installed on your `Linux` System.

Go into the `src` folder and build as:
```
go build
```
## Related
- [Swipe Gestures on Linux](https://evuraan.info/Swipe/?ref=odotool)

Binary file added edotool.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added edotool.mp4
Binary file not shown.
Binary file added edotool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions src/getDev.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* Copyright (C) 2021 Evuraan, <evuraan@gmail.com> */

package main

import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)

const (
devices = "/proc/bus/input/devices"
touchpad = "TouchPad"
keyboard = "keyboard"
)

var (
touchPadIdentifier = ""
)

func getDeviceForPattern(lookForA string) (devicePath string) {
if len(lookForA) < 1 {
return
}
lookFor := strings.ToLower(lookForA)
fmap := parseFileToMap(devices)
if len(fmap) < 1 {
return
}
var entry, lentr string
pat := regexp.MustCompile(`event\d*`)
for k := range fmap {
entry = fmap[k]
if len(entry) < 1 {
continue
}
lentr = strings.ToLower(entry)
if strings.Contains(lentr, lookFor) {
pos := k + 4
if len(fmap) < pos {
continue
}
handler := fmap[pos]
s := pat.FindString(handler)

if len(s) > 0 {
devicePath = fmt.Sprintf("/dev/input/%s", s)
return devicePath
}
}
}

return devicePath
}

func parseFileToMap(configFile string) (someDict map[int]string) {
someDict = make(map[int]string)

func() {
f, err := os.Open(configFile)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not open config file: %v\n", err)
os.Exit(1)
}
defer f.Close()
fscanner := bufio.NewScanner(f)
for fscanner.Scan() {
line := fscanner.Text()
if len(line) > 0 {
someDict[len(someDict)] = line
}
}
}()

return someDict
}
3 changes: 3 additions & 0 deletions src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module edotool

go 1.15
Loading

0 comments on commit 1d80153

Please sign in to comment.