Code Monkey home page Code Monkey logo

ydotool's Introduction

ydotool Build Status Release Status

Generic Linux command-line automation tool (no X!)

ydotool is not limited to Wayland. You can use it on anything as long as it accepts keyboard/mouse/whatever input. For example, X11, text console, "RetroArch OS", fbdev apps (fbterm/mplayer/SDL1/LittleVGL/Qt Embedded), etc.

Important Note

The man page is not always up to date. Please use --help to ensure correctness.

ChangeLog

This project is now refactored. (v1.0.0)

Changes:

  • Rewritten in pure C99
  • No external dependencies
  • Uses a lot less memory & no dynamic memory allocation

Breaking Changes:

  • recorder removed because it's irrelevant. It will become a separate project
  • Command chaining and sleep are removed because this should be your shell's job
  • ydotool now must work with ydotoold
  • Usage of click and key are changed

Good News:

  • Some people can finally build this project offline
  • key now (only) accepts keycodes, so it's not limited to a specific keyboard layout
  • Now it's possible to implement support for different keyboard layouts in type

Usage

Currently implemented command(s):

  • type - Type a string
  • key - Press keys
  • mousemove - Move mouse pointer to absolute position
  • click - Click on mouse buttons

Examples

Switch to tty1 (Ctrl+Alt+F1), wait 2 seconds, and type some words:

ydotool key 29:1 56:1 59:1 59:0 56:0 29:0; sleep 2; ydotool type 'echo Hey guys. This is Austin.'

Close a window in graphical environment (Alt+F4):

ydotool key 56:1 62:1 62:0 56:0

Relatively move mouse pointer to -100,100:

ydotool mousemove -x -100 -y 100

Move mouse pointer to 100,100:

ydotool mousemove --absolute -x 100 -y 100

Mouse right click:

ydotool click 0xC1

Mouse repeating left click:

ydotool click --repeat 5 --next-delay 25 0xC0

Notes

Runtime

This program requires access to /dev/uinput. This usually requires root permissions.

Available key names

See /usr/include/linux/input-event-codes.h

Why a background service is needed

ydotool works differently from xdotool. xdotool sends X events directly to X server, while ydotool uses the uinput framework of Linux kernel to emulate an input device.

When ydotool runs and creates a virtual input device, it will take some time for your graphical environment (X11/Wayland) to recognize and enable the virtual input device. (Usually done by udev)

So, if the delay was too short, the virtual input device may not get recognized & enabled by your graphical environment in time.

In order to solve this problem, a persistent background service, ydotoold, is made to hold a persistent virtual device, and accept input from ydotool.

Since v1.0.0, the use of ydotoold is mandatory.

Build

CMake 3.4+ is required.

Compile

At least on Fedora 39, might require sudo dnf install -y scdoc to have acccess to the scdoc manpage generator.

mkdir build
cd build
cmake ..
make -j `nproc`

Troubleshooting

Custom keyboard layouts

Currently, ydotool does not recognize if the user is using a custom keyboard layout. In order to comfortably use ydotool alongside a custom keyboard layout, the user could use one of the following fixes/workarounds:

Sway

In sway, the process is fairly easy. Following the instructions there, you would end up with something like:

input "16700:8197:DELL_DELL_USB_Keyboard" {
	xkb_layout "us,us"
	xkb_variant "dvorak,"
	xkb_options "grp:shifts_toggle, caps:swapescape"
}

The identifier for your keyboard can be obtained from the output of swaymsg -t get_inputs.

Hyprland

You can use Per-device input configs in Hyprland. Simply add following snippet to your config:

device:ydotoold-virtual-device {
    kb_layout = us
    kb_variant =
    kb_options =
}

Use a hardware-configurable keyboard

As mentioned here, consider using a hardware-based configuration that supports using a custom layout without configuring it in software.

Older Notes

Current situation

This project is now being maintained thanks to all the people that are supporting this project!

All backers and sponsors are listed here.

How to support us

  • Donate on our Patreon
  • Buy our products on our Official Store, if they are meaningful to you (please leave a message: ydotool user, so we can know that this purchase is for supporting ydotool)

More talks

Article: "Open Source" is Broken

Independent software developers in China, like us, have 10 times more life pressure than Marak, the author of faker.js. Since ydotool has the opportunity to benefit large IT companies who won't pay a penny to us, we've changed the license to AGPLv3. These large IT companies are the main cause of life pressure here, such as the "996" working hours.

Marak's fate will repeat on all open source developers eventually (of course we aren't talking about those who were born in billionare families) if we just keep fighting with each other and do nothing to improve the situation. If you make open source software as well, don't hesitate to ask for donations if you actually need them.

Also make sure you understand all the terms of AGPLv3 before using this software.

ydotool's People

Contributors

reimunotmoe avatar classicoldsong avatar bhepple avatar 1ace avatar t0fik avatar tinfoilsubmarine avatar maxice8 avatar adeliktas avatar satmandu avatar kitakar5525 avatar icedman avatar supercheetah avatar jacob-horton avatar smattr avatar mnutt avatar mgoral avatar r00tman avatar antoniojpfernandes avatar automaticit-anthonyyen1 avatar jgcodes2020 avatar kraem avatar hed-mhernandez avatar 9ary avatar pallaswept avatar thyrc avatar tbm avatar kepi avatar johngebbie avatar cincodenada avatar jingmatrix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.