From 1d6d0491a5c60a32287b6fc88726e43fc946a177 Mon Sep 17 00:00:00 2001 From: John Gebbie Date: Wed, 12 Oct 2022 20:50:01 +0100 Subject: [PATCH] New package: ydotool-1.0.1 --- srcpkgs/ydotool/INSTALL.msg | 6 + srcpkgs/ydotool/files/50-ydotool.conf | 8 + srcpkgs/ydotool/files/80-uinput.rules | 4 + srcpkgs/ydotool/files/ydotoold/log/run | 2 + srcpkgs/ydotool/files/ydotoold/run | 2 + .../patches/man-update-for-1.0.1.patch | 266 ++++++++++++++++++ .../patches/socket-group-permission.patch | 36 +++ srcpkgs/ydotool/template | 27 ++ 8 files changed, 351 insertions(+) create mode 100644 srcpkgs/ydotool/INSTALL.msg create mode 100644 srcpkgs/ydotool/files/50-ydotool.conf create mode 100644 srcpkgs/ydotool/files/80-uinput.rules create mode 100755 srcpkgs/ydotool/files/ydotoold/log/run create mode 100755 srcpkgs/ydotool/files/ydotoold/run create mode 100644 srcpkgs/ydotool/patches/man-update-for-1.0.1.patch create mode 100644 srcpkgs/ydotool/patches/socket-group-permission.patch create mode 100644 srcpkgs/ydotool/template diff --git a/srcpkgs/ydotool/INSTALL.msg b/srcpkgs/ydotool/INSTALL.msg new file mode 100644 index 000000000000..1812d29a7afc --- /dev/null +++ b/srcpkgs/ydotool/INSTALL.msg @@ -0,0 +1,6 @@ +udev rules for uinput has been installed, +to access /dev/uinput, add yourself to group input: + + $ sudo usermod -a -G input $USER + +and then re-login to make it effective. diff --git a/srcpkgs/ydotool/files/50-ydotool.conf b/srcpkgs/ydotool/files/50-ydotool.conf new file mode 100644 index 000000000000..bb6d376aa21c --- /dev/null +++ b/srcpkgs/ydotool/files/50-ydotool.conf @@ -0,0 +1,8 @@ +# This fixes `ydotool mousemove` by disabling acceleration: +# https://github.com/ReimuNotMoe/ydotool/issues/158 +Section "InputClass" + Identifier "ydotoold virtual device" + MatchDriver "libinput" + Option "AccelProfile" "flat" + Option "AccelSpeed" "0" +EndSection diff --git a/srcpkgs/ydotool/files/80-uinput.rules b/srcpkgs/ydotool/files/80-uinput.rules new file mode 100644 index 000000000000..6067c917b4c5 --- /dev/null +++ b/srcpkgs/ydotool/files/80-uinput.rules @@ -0,0 +1,4 @@ +# This allows users in group input to write to /dev/uinput, +# as required by the ydotoold command: +# https://github.com/ReimuNotMoe/ydotool/issues/25#issuecomment-535842993 +KERNEL=="uinput", GROUP="input", MODE="0660", OPTIONS+="static_node=uinput" diff --git a/srcpkgs/ydotool/files/ydotoold/log/run b/srcpkgs/ydotool/files/ydotoold/log/run new file mode 100755 index 000000000000..14f2459503cc --- /dev/null +++ b/srcpkgs/ydotool/files/ydotoold/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec logger -p daemon.info -t ydotoold diff --git a/srcpkgs/ydotool/files/ydotoold/run b/srcpkgs/ydotool/files/ydotoold/run new file mode 100755 index 000000000000..430cefd9bcd9 --- /dev/null +++ b/srcpkgs/ydotool/files/ydotoold/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec chpst -u _ydotoold:input ydotoold 2>&1 diff --git a/srcpkgs/ydotool/patches/man-update-for-1.0.1.patch b/srcpkgs/ydotool/patches/man-update-for-1.0.1.patch new file mode 100644 index 000000000000..1f5812eb8933 --- /dev/null +++ b/srcpkgs/ydotool/patches/man-update-for-1.0.1.patch @@ -0,0 +1,266 @@ +From d06f10c5ff5ad0217ef0655964deb51e211fba90 Mon Sep 17 00:00:00 2001 +From: John Gebbie +Date: Sat, 15 Oct 2022 11:36:32 +0100 +Subject: [PATCH] Update ydotool.1.scd and ydotoold.8.scd + +Bring manual up to date with version 1.0.1 +--- + manpage/ydotool.1.scd | 140 ++++++++++++++--------------------------- + manpage/ydotoold.8.scd | 23 +++---- + 2 files changed, 57 insertions(+), 106 deletions(-) + +diff --git a/manpage/ydotool.1.scd b/manpage/ydotool.1.scd +index b8f318c..4c01a38 100644 +--- a/manpage/ydotool.1.scd ++++ b/manpage/ydotool.1.scd +@@ -1,20 +1,19 @@ + YDOTOOL(1) +- + # NAME + + ydotool - command-line _/dev/uinput_ automation tool + + # SYNOPSIS + +-*ydotool* *cmd* _args_ [ , *cmd* _args_ ... ] ++*ydotool* *cmd* _args_ + + *ydotool* *cmd* --help + + # DESCRIPTION + +-*ydotool* lets you programmatically (or manually) simulate keyboard input and mouse activity, etc. It does this by writing directly to _/dev/uinput_ so it generally needs to run as root. ++*ydotool* lets you programmatically (or manually) simulate keyboard input and mouse activity, etc. ++The *ydotoold*(8) daemon must be running. + +-It's possible to chain multiple commands together, separated by a comma between two spaces. + + Currently implemented command(s): + +@@ -26,67 +25,37 @@ Currently implemented command(s): + Move mouse pointer to absolute position + *click* + Click on mouse buttons +-*recorder* +- Record/replay input events +-*sleep* +- sleep for a while + + # KEYBOARD COMMANDS +-*key* [*--up*] [*--down*] [*--next-delay* __] [*--key-delay* __] [*--repeat* __] [*--repeat-delay *] __ ++*key* [*-d*,*--key-delay* __] [__ ...] + +- Type a given keystroke. Examples being "alt+r", "ctrl+J", +- "ctrl+alt+n", "backspace". ++ Type a given keycode. ++ ++ e.g. 28:1 28:0 means pressing on the Enter button on a standard US keyboard. + +- Options: ++ 42:1 38:1 38:0 24:1 24:0 38:1 38:0 42:0 - "LOL" + +- *--up* +- Only keyup +- +- *--down* +- Only keydown ++ Non-interpretable values, such as 0, aaa, l0l, will only cause a delay. + +- *--delay* __ +- Delay before starting to output keystrokes. Default 100ms. ++ See `/usr/include/linux/input-event-codes.h' for available key codes (KEY_\*). + +- *--key-delay* __ ++ Options: ++ *-d*,*--key-delay* __ + Delay time between keystrokes. Default 12ms. + +- *--repeat* __ +- Times to repeat the key sequence. +- +- *--repeat-delay* __ +- Delay time between repetitions. Default 0ms. +- +- Generally, any valid name from _/usr/include/linux/input-event-codes.h_ will work. Multiple keys are separated by '+'. +- +- 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 +- +- Since we are emulating keyboard input, combinations like Shift+# is invalid because typing a `#' involves pressing Shift and 3. +- +- Example: Switch to tty1: +- ydotool key ctrl+alt+f1 +- +- Example: Close a window in graphical environment: +- ydotool key Alt+F4 +- +-*type* [*--next-delay* __] [*--key-delay* __] [*--texts* _arg_] [*--file* __] "_texts_" ++*type* [*-D*,*--next-delay* __] [*-d*,*--key-delay* __] [*-f*,*--file* __] "_text_" + + Types text as if you had typed it on the keyboard. + + Options: + +- *--next-delay* __ +- Delay before starting typing. Default 100ms. +- +- *--key-delay* __ +- Delay time between keystrokes. Default 12ms. ++ *-d*,*--key-delay* __ ++ Delay time between key events (up/down each). Default 12ms. + +- *--texts* _arg_ +- Texts to type ++ *-D*,*--next-delay* __ ++ Delay between strings. Default 0ms. + +- *--file* __ ++ *-f*,*--file* __ + 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. + + Example: to type 'Hello world!' you would do: +@@ -94,8 +63,8 @@ Currently implemented command(s): + + # MOUSE COMMANDS + +-*mousemove* _ _ +- Move the mouse to the specific relative X and Y coordinates on the screen. ++*mousemove* [*-a*,*--absolute*] _ _ ++ Move the mouse to the relative X and Y coordinates on the screen. + + Options: + *--absolute* +@@ -104,61 +73,48 @@ Currently implemented command(s): + Example: to move the cursor to absolute coordinates (100,100): + ydotool mousemove --absolute 100 100 + +-*click* [*--next-delay* __] _button_ +- Send a click. Buttons are: _left_, _right_ or _middle_ ++*click* [*-d*,*--next-delay* __] [*-r*,*--repeat* _N_ ] [_button_ ...] ++ Send a click. + + Options: ++ *-d*,*--next-delay* __ ++ Delay between input events (up/down, a compete click means doubled time). Default 25ms. + +- *--next-delay* __ +- Delay before click. Default 100ms. +- +- *--up* +- Only mouseup +- +- *--down* +- Only mousedown +- +- *--buttons* __ +- Buttons to press (left, right, middle) +- +- Example: Mouse middle click: +- ydotool click middle +- +-*recorder* [*--record* __] [*--replay* __] [*--display*] [*--duration* __] [*--devices* __] [*--file* __] ++ *-r*,*--repeat* _N_ ++ Repeat entire sequence N times + +- Options: +- +- *--record* __ +- Devices to record from. Default is all, including non-keyboard devices. ++ all mouse buttons are represented using hexadecimal numeric values, with an optional ++ bit mask to specify if mouse up/down needs to be omitted. + +- *--replay* __ +- The record file can't be replayed on an architecture with different endianness. ++ - 0x00 - LEFT ++ - 0x01 - RIGHT ++ - 0x02 - MIDDLE ++ - 0x03 - SIDE ++ - 0x04 - EXTR ++ - 0x05 - FORWARD ++ - 0x06 - BACK ++ - 0x07 - TASK ++ - 0x40 - Mouse down ++ - 0x80 - Mouse up ++ ++ Examples: + +- *--display* +- Display ++ - 0x00: chooses left button, but does nothing (you can use this to implement extra sleeps) ++ - 0xC0: left button click (down then up) ++ - 0x41: right button down ++ - 0x82: middle button up + +- *--duration* __ +- Record duration. Otherwise use SIGINT to stop recording. ++ The '0x' prefix can be omitted if you want. + +- *--devices* __ +- Devices, separated by comma, to record from. Default is all devices (default: "") ++# YDOTOOL SOCKET + +- *--file* __ +- File to record to / replay from ++The socket to write to for *ydotoold*(8) can be changed by the environment variable YDOTOOL_SOCKET. + + # AUTHOR + + ydotool was written by ReimuNotMoe. + +-This man page by bob.hepple@gmail.com +- +-# BUGS +- +-When *ydotool*(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) +- +-If the delay is too short, the virtual input device may not be recognized & enabled by the graphical environment in time. +- +-In order to solve this problem, there is a persistent background service, *ydotoold*(1), to hold a persistent virtual device, and accept input from *ydotool*(1). When *ydotoold*(1) is unavailable, *ydotool*(1) will work without it. ++This manpage was written by bob.hepple@gmail.com but updated since. + + # LICENCE + AGPLv3 +diff --git a/manpage/ydotoold.8.scd b/manpage/ydotoold.8.scd +index 8ed56ec..5c33cb4 100644 +--- a/manpage/ydotoold.8.scd ++++ b/manpage/ydotoold.8.scd +@@ -10,29 +10,24 @@ ydotoold \- daemon for *ydotool*(1) + + # DESCRIPTION + +-*ydotool* lets you programmatically (or manually) simulate +-keyboard input and mouse activity, etc. It does this by writing +-directly to */dev/uinput* so it generally needs to run as root. +- +-When *ydotool*(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) +- +-If the delay is too short, the virtual input device may not be recognized & enabled by the graphical environment in time. +- +-In order to solve this problem, the *ydotoold* background service holds a persistent virtual device, and accepts input from *ydotool*(1). When *ydotoold*(1) is unavailable, *ydotool*(1) will work without it. ++*ydotoold* holds a persistent virtual device, and accepts input from *ydotool*(1). + + # OPTIONS + +- *--socket-path arg* __ +- Socket path (default: /tmp/.ydotool_socket) ++ *-p*, *--socket-path arg* __ ++ Set socket path. ++ ++ *-P*, *--socket-perm arg* __ ++ Set socket permission. + +- *--socket-perm arg* __ +- Socket permission (default: 0600) ++ *-h*, *--help* ++ Display help and exit. + + # AUTHOR + + *ydotool*(1) and *ydotoold*(8) were written by ReimuNotMoe. + +-This man page by bob.hepple@gmail.com ++This manpage was written by bob.hepple@gmail.com but updated since. + + # LICENCE + diff --git a/srcpkgs/ydotool/patches/socket-group-permission.patch b/srcpkgs/ydotool/patches/socket-group-permission.patch new file mode 100644 index 000000000000..ed8d31284496 --- /dev/null +++ b/srcpkgs/ydotool/patches/socket-group-permission.patch @@ -0,0 +1,36 @@ +This requires the user to be in the group used for ydotoold, rather +than the same user. This means a user in the correct group can use the +service without root permissions. + +The socket path is changed due to the restricted deletion flag of /tmp, +which stops a member of the same group overwriting it, which ydotoold +does each time. + +diff --git a/Client/ydotool.c b/Client/ydotool.c +index c86f20b..79bd8b0 100644 +--- a/Client/ydotool.c ++++ b/Client/ydotool.c +@@ -134,7 +134,7 @@ int main(int argc, char **argv) { + if (env_sp) { + daemon_socket_path = env_sp; + } else { +- daemon_socket_path = "/tmp/.ydotool_socket"; ++ daemon_socket_path = "/var/lib/ydotoold/socket"; + } + + fd_daemon_socket = socket(AF_UNIX, SOCK_DGRAM, 0); +diff --git a/Daemon/ydotoold.c b/Daemon/ydotoold.c +index 10b4ca2..e0d061b 100644 +--- a/Daemon/ydotoold.c ++++ b/Daemon/ydotoold.c +@@ -59,8 +59,8 @@ + + #include + +-static const char *opt_socket_path = "/tmp/.ydotool_socket"; +-static const char *opt_socket_perm = "0600"; ++static const char *opt_socket_path = "/var/lib/ydotoold/socket"; ++static const char *opt_socket_perm = "0660"; + + static void show_help() { + puts( diff --git a/srcpkgs/ydotool/template b/srcpkgs/ydotool/template new file mode 100644 index 000000000000..850eeef9dd7d --- /dev/null +++ b/srcpkgs/ydotool/template @@ -0,0 +1,27 @@ +# Template file for 'ydotool' +pkgname=ydotool +version=1.0.1 +revision=1 +build_style=cmake +hostmakedepends="pkg-config scdoc" +short_desc="Generic command-line automation tool, works on Wayland and X11" +maintainer="John Gebbie " +license="AGPL-3.0-only" +homepage="https://github.com/ReimuNotMoe/ydotool" +distfiles="https://github.com/ReimuNotMoe/ydotool/archive/v${version}.tar.gz" +checksum=02311cdc608f205711b06a95e5fd71093b2294f4920efc526f5e98a2ddab42b8 + +system_accounts="_ydotoold" +_ydotoold_groups="input" + +# Used instead of /tmp so any group input user can replace the socket. +make_dirs='/var/lib/ydotoold 0775 _ydotoold input' + +post_install() { + vsv ydotoold + vinstall "${FILESDIR}/80-uinput.rules" 644 usr/lib/udev/rules.d + vinstall "${FILESDIR}/50-ydotool.conf" 644 usr/share/X11/xorg.conf.d + vlicense LICENSE + vman build/manpage/ydotool.1 + vman build/manpage/ydotoold.8 +}