accessibility/ydotool: Added (fake key/mouse events, no X).

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
B. Watson 2022-02-01 14:29:39 -05:00 committed by Willy Sudiarto Raharjo
parent d9095ad9cf
commit 783aaed0e9
No known key found for this signature in database
GPG key ID: 3F617144D7238786
7 changed files with 516 additions and 0 deletions

View file

@ -0,0 +1,17 @@
ydotool (send fake keyboard/mouse events to the kernel)
ydotool is an automation tool, similar to xdotool, but it doesn't
require X. It can be used to send input to console or wayland
applications, as well as X.
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.
To use ydotool, the user must have read/write access to /dev/uinput.
On Slackware, this means ydotool would need root access. This
SlackBuild installs ydotool setuid root, but only users in the
'console' group can run it. Since 'console' users can already use the
real keyboard and mouse, it doesn't seem like a huge security risk to
let them send fake events. If this bothers you, run the script with
SETUID=no in the environment to disable it.

View file

@ -0,0 +1,17 @@
diff -Naur ydotool-0.1.9/CMakeLists.txt ydotool-0.1.9.patched/CMakeLists.txt
--- ydotool-0.1.9/CMakeLists.txt 2021-01-03 01:04:26.000000000 -0500
+++ ydotool-0.1.9.patched/CMakeLists.txt 2022-01-31 23:47:50.830095182 -0500
@@ -2,11 +2,11 @@
project(ydotool)
set(CMAKE_CXX_STANDARD 14)
-set(PROJECT_VERSION "0.1.5")
+set(PROJECT_VERSION "0.1.9")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
-set(CPACK_PACKAGE_VERSION_PATCH "5")
+set(CPACK_PACKAGE_VERSION_PATCH "9")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Generic Linux command-line automation tool (no X!)")
set(CPACK_PACKAGE_CONTACT "Reimu NotMoe <https://github.com/ReimuNotMoe>")
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/ReimuNotMoe/ydotool")

View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
ydotool: ydotool (send fake keyboard/mouse events to the kernel)
ydotool:
ydotool: ydotool is an automation tool, similar to xdotool, but it doesn't
ydotool: require X. It can be used to send input to console or wayland
ydotool: applications, as well as X.
ydotool:
ydotool: ydotool works differently from xdotool. xdotool sends X events
ydotool: directly to X server, while ydotool uses the uinput framework of
ydotool: Linux kernel to emulate an input device.
ydotool:
ydotool:

View file

@ -0,0 +1,291 @@
.\" Generated by scdoc 1.11.1
.\" Complete documentation for this program is not available as a GNU info page
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.nh
.ad l
.\" Begin generated content:
.TH "YDOTOOL" "1" "2022-02-01"
.P
.SH NAME
.P
ydotool - command-line \fI/dev/uinput\fR automation tool
.P
.SH SYNOPSIS
.P
\fBydotool\fR \fBcmd\fR \fIargs.\&.\&.\&\fR
.P
\fBydotool\fR \fBcmd\fR --help
.P
.SH DESCRIPTION
.P
\fBydotool\fR lets you programmatically (or manually) simulate keyboard input and mouse activity, etc.\& It does this by writing directly to \fI/dev/uinput\fR so it generally needs to run as root.\&
.P
Currently implemented command(s):
.P
\fBtype\fR
.RS 4
Type a string
.RE
\fBkey\fR
.RS 4
Press keys
.RE
\fBmousemove\fR
.RS 4
Move mouse pointer to absolute position
.RE
\fBmousemove_relative\fR
.RS 4
Move mouse pointer to relative position
.RE
\fBclick\fR
.RS 4
Click on mouse buttons
.RE
\fBrecorder\fR
.RS 4
Record/replay input events
.RE
\fBmouseup\fR
.RS 4
Send a mouse up event.\&
.RE
\fBmousedown\fR
.RS 4
Send a mouse down event.\&
.P
.RE
.SH KEYBOARD COMMANDS
\fBkey\fR [\fB--up\fR] [\fB--down\fR] [\fB--delay\fR \fI<ms>\fR] [\fB--key-delay\fR \fI<ms>\fR] [\fB--repeat\fR \fI<times>\fR] [\fB--repeat-delay <ms>\fR] [\fB--persist-delay <ms>\fR] \fI<key sequence>\fR
.P
.RS 4
Type a given keystroke.\& Examples being "alt+r", "ctrl+J",
"ctrl+alt+n", "backspace".\&
.P
Options:
.P
\fB--up\fR
.RS 4
Only keyup
.P
.RE
\fB--down\fR
.RS 4
Only keydown
.P
.RE
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before starting to output keystrokes.\& Default 100ms.\&
.P
.RE
\fB--key-delay\fR \fI<ms>\fR
.RS 4
Delay time between keystrokes.\& Default 12ms.\&
.P
.RE
\fB--repeat\fR \fI<times>\fR
.RS 4
Times to repeat the key sequence.\&
.P
.RE
\fB--repeat-delay\fR \fI<ms>\fR
.RS 4
Delay time between repetitions.\& Default 0ms.\&
.P
.RE
\fB--persist-delay\fR \fI<ms>\fR
.RS 4
Keep virtual device alive for \fI<ms>\fR ms.\& Should be used in conjunction with \fB--down\fR or \fB--up\fR
.P
.RE
Generally, any valid name from \fI/usr/include/linux/input-event-codes.\&h\fR will work.\& Multiple keys are separated by '+'.\&
.P
Each key sequence can be any number of modifiers and keys, separated by plus (+)
For example: alt+r Alt+F4 CTRL+alt+f3 aLT+1+2+3 ctrl+Backspace
.P
Since we are emulating keyboard input, combinations like Shift+# is invalid because typing a `#' involves pressing Shift and 3.\&
.P
Example: Switch to tty1:
.RS 4
ydotool key ctrl+alt+f1
.P
.RE
Example: Close a window in graphical environment:
.RS 4
ydotool key Alt+F4
.P
.RE
.RE
\fBtype\fR [\fB--delay\fR \fI<ms>\fR] [\fB--key-delay\fR \fI<ms>\fR] [\fB--args\fR \fI<N>\fR] [\fB--file\fR \fI<filepath>\fR] "\fIsomething to type\fR"
.P
.RS 4
Types text as if you had typed it on the keyboard.\&
.P
Options:
.P
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before starting typing.\& Default 100ms.\&
.P
.RE
\fB--key-delay\fR \fI<ms>\fR
.RS 4
Delay time between keystrokes.\& Default 12ms.\&
.P
.RE
\fB--args\fR \fI<N>\fR
.RS 4
?\&?\&?\&?\&
.P
.RE
\fB--file\fR \fI<filepath>\fR
.RS 4
Specify a file, the contents of which will be typed as if passed as an argument.\& The filepath may also be '-' to read from stdin.\&
.P
.RE
Example: to type 'Hello world!\&' you would do:
.RS 4
ydotool type 'Hello world!\&'
.P
.RE
.RE
.SH MOUSE COMMANDS
.P
\fBmousemove\fR [\fB--delay\fR \fI<ms>\fR] \fI<x> <y>\fR
.RS 4
Move the mouse to the specific X and Y coordinates on the screen.\&
.P
Options:
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before starting move.\& Default 100ms.\&
.P
.RE
Example: to move the cursor to absolute coordinates (100,100):
.RS 4
ydotool mousemove 100 100
.P
.RE
.RE
\fBmousemove_relative\fR [\fB--delay\fR \fI<ms>\fR] \fI<x>\fR \fI<y>\fR
.RS 4
Move the mouse x,y pixels relative to the current position of the mouse cursor.\&
.P
Options:
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before starting move.\& Default 100ms.\&
.P
.RE
Example: Relatively move mouse pointer to -100,100:
.RS 4
ydotool mousemove_relative -- -100 100
.P
.RE
.RE
\fBclick\fR [\fB--delay\fR \fI<ms>\fR] \fIbutton\fR
.RS 4
Send a click.\& Buttons are: 1=left 2=right 3=middle
.P
Options:
.P
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before click.\& Default 100ms.\&
.P
.RE
Example: Mouse right click:
.RS 4
ydotool click 2
.P
.RE
.RE
\fBrecorder\fR [\fB--delay\fR \fI<ms>\fR] [\fB--record\fR \fI<devices>\fR] [\fB--replay\fR \fI<input files>\fR] [\fB--display\fR] [\fB--duration\fR \fI<ms>\fR]
.P
.RS 4
Options:
.P
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay time before start recording/replaying.\& Default 5000ms.\&
.P
.RE
\fB--record\fR \fI<devices>\fR
.RS 4
Devices to record from.\& Default is all, including non-keyboard devices.\&
.P
.RE
\fB--replay\fR \fI<input files>\fR
.RS 4
The record file can't be replayed on an architecture with different endianness.\&
.P
.RE
\fB--display\fR
.RS 4
?\&?\&?\&?\&
.P
.RE
\fB--duration\fR \fI<ms>\fR
.RS 4
Record duration.\& Otherwise use SIGINT to stop recording.\&
.P
.RE
.RE
\fBmouseup\fR [\fB--delay\fR \fI<ms>\fR] \fIbutton\fR
.RS 4
Send a mouse up event.\& Buttons are: 1=left 2=right 3=middle
.P
Options:
.P
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before click.\& Default 100ms.\&
.P
.RE
Example: Mouse right click:
.RS 4
ydotool click 2
.P
.RE
.RE
\fBmousedown\fR [\fB--delay\fR \fI<ms>\fR] \fIbutton\fR
.RS 4
Send a mouse down event.\& Buttons are: 1=left 2=right 3=middle
.P
Options:
.P
\fB--delay\fR \fI<ms>\fR
.RS 4
Delay before click.\& Default 100ms.\&
.P
.RE
Example: Mouse right click:
.RS 4
ydotool click 2
.P
.RE
.RE
.SH AUTHOR
.P
ydotool was written by ReimuNotMoe.\&
.P
This man page by bob.\&hepple@gmail.\&com
.P
.SH BUGS
.P
When \fBydotool\fR(1) runs and creates a virtual input device, it will take some time for your graphical environment (eg X11/Wayland) to recognize and enable the virtual input device.\& (Usually done by udev)
.P
If the delay is too short, the virtual input device may not be recognized & enabled by the graphical environment in time.\&
.P
In order to solve this problem, there is a persistent background service, \fBydotoold\fR(1), to hold a persistent virtual device, and accept input from \fBydotool\fR(1).\& When \fBydotoold\fR(1) is unavailable, \fBydotool\fR(1) will work without it.\&
.P
.SH COPYRIGHT
MIT License
.P
.SH SEE ALSO
.P
\fBydotoold\fR(8)
.P
Project site: <https://github.\&com/ReimuNotMoe/ydotool>

View file

@ -0,0 +1,118 @@
#!/bin/bash
# Slackware build script for ydotool
# Written by B. Watson (yalhcru@gmail.com)
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# Note: this is not the latest version of ydotool, though it's newer
# than the version that Debian packages. It uses the stable(ish)
# libevdevplus and libuinputplus versions that Debian also packages.
# Later ytodool, libevdevplus, and libuinputplus versions are
# rapidly-moving targets for now. Plus, latest ydotool uses "CPM"
# (Cmake Package Manager) to auto-download its dependencies, and I
# haven't had time to figure out how to defeat that so the script can
# run without doing network access...
cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=ydotool
VERSION=${VERSION:-0.1.9}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i586 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
fi
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i586" ]; then
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
else
SLKCFLAGS="-O2"
LIBDIRSUFFIX=""
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
\! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
# The cmake project version variables control the shared library's
# version, which should match the actual ytodool version... version
# 0.1.9 thinks it's 0.1.5.
patch -p1 < $CWD/project_version.diff
mkdir -p build
cd build
cmake \
-DDYNAMIC_BUILD=on \
-DSTATIC_BUILD=off \
-DCMAKE_CXX_FLAGS_RELEASE="$SLKCFLAGS -DNDEBUG" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIB_SUFFIX=${LIBDIRSUFFIX} \
-DMAN_INSTALL_DIR=/usr/man \
-DCMAKE_BUILD_TYPE=Release ..
make VERBOSE=1
make install/strip DESTDIR=$PKG
cd ..
# Upstream's man pages are in scdoc format, which looks like a pretty
# nice text-to-manpage mini-language. Rather than require scdoc as a
# dependency, I just converted the man pages and included them with
# the script. If they ever need to be generated again, use this:
if [ "${CONVERT_MAN:-no}" = "yes" ]; then
sed -i 's,\\fR,,' manpage/ydotool.1.scd
scdoc < manpage/ydotool.1.scd > $CWD/ydotool.1
scdoc < manpage/ydotoold.8.scd > $CWD/ydotoold.8
fi
PMAN=$PKG/usr/man
mkdir -p $PMAN/man{1,8}
gzip -9c < $CWD/$PRGNAM.1 > $PMAN/man1/$PRGNAM.1.gz
gzip -9c < $CWD/${PRGNAM}d.8 > $PMAN/man8/${PRGNAM}d.8.gz
# Install setuid unless disabled. See README for rationale.
if [ "${SETUID:-yes}" = "yes" ]; then
chown root:console $PKG/usr/bin/*
chmod 4750 $PKG/usr/bin/*
fi
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a LICENSE README* $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View file

@ -0,0 +1,10 @@
PRGNAM="ydotool"
VERSION="0.1.9"
HOMEPAGE="https://github.com/ReimuNotMoe/ydotool"
DOWNLOAD="https://github.com/ReimuNotMoe/ydotool/archive/v0.1.9/ydotool-0.1.9.tar.gz"
MD5SUM="5b1de1443bd62c1bd60219d8972e5fb6"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="libuinputplus libevdevplus"
MAINTAINER="B. Watson"
EMAIL="yalhcru@gmail.com"

View file

@ -0,0 +1,44 @@
.\" Generated by scdoc 1.11.1
.\" Complete documentation for this program is not available as a GNU info page
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.nh
.ad l
.\" Begin generated content:
.TH "ydotoold" "8" "2022-02-01"
.P
.SH NAME
.P
ydotoold - daemon for \fBydotool\fR(1)
.P
.SH SYNOPSIS
.P
\fBydotoold\fR
.P
.SH DESCRIPTION
.P
\fBydotool\fR lets you programmatically (or manually) simulate
keyboard input and mouse activity, etc.\& It does this by writing
directly to \fB/dev/uinput\fR so it generally needs to run as root.\&
.P
When \fBydotool\fR(1) runs and creates a virtual input device, it will take some time for your graphical environment (eg X11/Wayland) to recognize and enable the virtual input device.\& (Usually done by udev)
.P
If the delay is too short, the virtual input device may not be recognized & enabled by the graphical environment in time.\&
.P
In order to solve this problem, the \fBydotoold\fR background service holds a persistent virtual device, and accepts input from \fBydotool\fR(1).\& When \fBydotoold\fR(1) is unavailable, \fBydotool\fR(1) will work without it.\&
.P
.SH AUTHOR
.P
\fBydotool\fR(1) and \fBydotoold\fR(8) were written by ReimuNotMoe.\&
.P
This man page by bob.\&hepple@gmail.\&com
.P
.SH COPYRIGHT
.P
MIT License
.P
.SH SEE ALSO
.P
\fBydotool\fR(1)
.P
Project site: <https://github.\&com/ReimuNotMoe/ydotool>