From 228c36d8881e5b2c284d86d61c9d7bb8c1ea8e29 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sat, 23 Nov 2024 21:41:00 +0100 Subject: [PATCH] feat: add ydotool, ydotoold --- .forgejo/workflows/package.yml | 2 + README.md | 2 + ydotool/build.sh | 83 +++++++++++++++++++++++++++++++++ ydotool/debian.conffiles | 1 + ydotool/debian.default | 1 + ydotool/debian.postinst | 15 ++++++ ydotool/debian.postrm | 9 ++++ ydotool/debian.prerm | 9 ++++ ydotool/ydotool.debian.control | 22 +++++++++ ydotool/ydotoold.debian.control | 22 +++++++++ ydotool/ydotoold.service | 13 ++++++ 11 files changed, 179 insertions(+) create mode 100755 ydotool/build.sh create mode 100644 ydotool/debian.conffiles create mode 100644 ydotool/debian.default create mode 100755 ydotool/debian.postinst create mode 100755 ydotool/debian.postrm create mode 100755 ydotool/debian.prerm create mode 100644 ydotool/ydotool.debian.control create mode 100644 ydotool/ydotoold.debian.control create mode 100644 ydotool/ydotoold.service diff --git a/.forgejo/workflows/package.yml b/.forgejo/workflows/package.yml index 6ddb6c3..e9bd7eb 100644 --- a/.forgejo/workflows/package.yml +++ b/.forgejo/workflows/package.yml @@ -62,3 +62,5 @@ jobs: python3-telethon: *job repo.s3lph.me-apt-source: *job republik-feeder: *job + ydotool: *job + ydotoold: *job diff --git a/README.md b/README.md index 84b17eb..523bac5 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,5 @@ information, please see [https://repo.s3lph.me/](https://repo.s3lph.me/). - [python3-telethon](https://github.com/tulir/Telethon) - [repo.s3lph.me-apt-source](https://repo.s3lph.me) - [republik-feeder](https://github.com/maetthu/republik-feeder) +- [ydotool](https://github.com/s3lph/ydotool) (My fork until https://github.com/ReimuNotMoe/ydotool/pull/261 is merged) +- [ydotoold](https://github.com/s3lph/ydotool) (My fork until https://github.com/ReimuNotMoe/ydotool/pull/261 is merged) diff --git a/ydotool/build.sh b/ydotool/build.sh new file mode 100755 index 0000000..f809f39 --- /dev/null +++ b/ydotool/build.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +set -exo pipefail + +ROOT=$(pwd) + +function fetch() { + git clone https://github.com/s3lph/ydotool "${SRCDIR}/ydotool" +} + +function prepare() { + apt install -y build-essential cmake pkg-config scdoc + cd "${SRCDIR}/ydotool" + export VERSION="$(git describe --tags | cut -d- -f1-2 | sed -re "s/-/~/g" -e "s/^v//g")-1" + export ISODATE="$(git log -1 --format="%aI")" + mkdir build + cd build + cmake .. + make + strip ydotool + strip ydotoold +} + +function prepare_ydotool() { + mkdir -p \ + "${PKGDIR_YDOTOOL}/DEBIAN" \ + "${PKGDIR_YDOTOOL}/usr/bin" \ + "${PKGDIR_YDOTOOL}/usr/share/man/man1" \ + "${PKGDIR_YDOTOOL}/usr/share/doc/ydotool" + cp "${SRCDIR}/ydotool/build/ydotool" "${PKGDIR_YDOTOOL}/usr/bin/ydotool" + cp "${SRCDIR}/ydotool/build/manpage/ydotool.1" "${PKGDIR_YDOTOOL}/usr/share/man/man1/ydotool.1" + gzip -9n "${PKGDIR_YDOTOOL}/usr/share/man/man1/ydotool.1" + cp "${SRCDIR}/ydotool/LICENSE" "${PKGDIR_YDOTOOL}/usr/share/doc/ydotool/copyright" + cp "${ROOT}/ydotool.debian.control" "${PKGDIR_YDOTOOL}/DEBIAN/control" + sed -re "s/__VERSION__/${VERSION}/g" -i "${PKGDIR_YDOTOOL}/DEBIAN/control" + sed -re "s/__MAINTAINER__/${MAINTAINER}/g" -i "${PKGDIR_YDOTOOL}/DEBIAN/control" + find "${PKGDIR_YDOTOOL}" -exec touch -m -d "${ISODATE}" {} \; +} + +function prepare_ydotoold() { + mkdir -p \ + "${PKGDIR_YDOTOOLD}/DEBIAN" \ + "${PKGDIR_YDOTOOLD}/etc/default" \ + "${PKGDIR_YDOTOOLD}/usr/bin" \ + "${PKGDIR_YDOTOOLD}/lib/systemd/system" \ + "${PKGDIR_YDOTOOLD}/usr/share/man/man8" \ + "${PKGDIR_YDOTOOLD}/usr/share/doc/ydotoold" + cp "${SRCDIR}/ydotool/build/ydotoold" "${PKGDIR_YDOTOOLD}/usr/bin/ydotoold" + cp "${SRCDIR}/ydotool/build/manpage/ydotoold.8" "${PKGDIR_YDOTOOLD}/usr/share/man/man8/ydotoold.8" + gzip -9n "${PKGDIR_YDOTOOLD}/usr/share/man/man8/ydotoold.8" + cp "${SRCDIR}/ydotool/LICENSE" "${PKGDIR_YDOTOOLD}/usr/share/doc/ydotoold/copyright" + cp "${ROOT}/ydotoold.debian.control" "${PKGDIR_YDOTOOLD}/DEBIAN/control" + cp "${ROOT}/debian.conffiles" "${PKGDIR_YDOTOOLD}/DEBIAN/conffiles" + cp "${ROOT}/debian.default" "${PKGDIR_YDOTOOLD}/etc/default/ydotoold" + cp "${ROOT}/debian.postinst" "${PKGDIR_YDOTOOLD}/DEBIAN/postinst" + cp "${ROOT}/debian.prerm" "${PKGDIR_YDOTOOLD}/DEBIAN/prerm" + cp "${ROOT}/debian.postrm" "${PKGDIR_YDOTOOLD}/DEBIAN/postrm" + cp "${ROOT}/ydotoold.service" "${PKGDIR_YDOTOOLD}/lib/systemd/system/ydotoold.service" + sed -re "s/__VERSION__/${VERSION}/g" -i "${PKGDIR_YDOTOOLD}/DEBIAN/control" + sed -re "s/__MAINTAINER__/${MAINTAINER}/g" -i "${PKGDIR_YDOTOOLD}/DEBIAN/control" + find "${PKGDIR_YDOTOOLD}" -exec touch -m -d "${ISODATE}" {} \; +} + +function package() { + cd "${BUILDDIR}" + dpkg-deb --build "${PKGDIR_YDOTOOL}" "${BUILDDIR}" + dpkg-deb --build "${PKGDIR_YDOTOOLD}" "${BUILDDIR}" +} + +function build() { + export BUILDDIR=${ROOT}/build + export SRCDIR=${BUILDDIR}/srcdir + export PKGDIR_YDOTOOL=${BUILDDIR}/pkgdir-ydotool + export PKGDIR_YDOTOOLD=${BUILDDIR}/pkgdir-ydotoold + mkdir -p ${SRCDIR} ${PKGDIR_YDOTOOL} ${PKGDIR_YDOTOOLD} + fetch + prepare + prepare_ydotool + prepare_ydotoold + package +} + +build diff --git a/ydotool/debian.conffiles b/ydotool/debian.conffiles new file mode 100644 index 0000000..8ad7544 --- /dev/null +++ b/ydotool/debian.conffiles @@ -0,0 +1 @@ +/etc/default/ydotoold diff --git a/ydotool/debian.default b/ydotool/debian.default new file mode 100644 index 0000000..3da79f7 --- /dev/null +++ b/ydotool/debian.default @@ -0,0 +1 @@ +ARGS="--socket-path=/run/.ydotool_socket --socket-own=root:ydotool --socket-perm=0660" \ No newline at end of file diff --git a/ydotool/debian.postinst b/ydotool/debian.postinst new file mode 100755 index 0000000..1ec4e57 --- /dev/null +++ b/ydotool/debian.postinst @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +if [[ "$1" == "configure" ]]; then + + if ! getent group ydotool >/dev/null; then + groupadd --system ydotool + fi + + deb-systemd-helper enable ydotoold.service + deb-systemd-invoke restart ydotoold.service + +fi + diff --git a/ydotool/debian.postrm b/ydotool/debian.postrm new file mode 100755 index 0000000..305068d --- /dev/null +++ b/ydotool/debian.postrm @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +if [[ "$1" == "remove" ]]; then + + systemctl daemon-reload || true + +fi diff --git a/ydotool/debian.prerm b/ydotool/debian.prerm new file mode 100755 index 0000000..e074cfb --- /dev/null +++ b/ydotool/debian.prerm @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +if [[ "$1" == "remove" ]]; then + + deb-systemd-invoke stop ydotoold.service + +fi diff --git a/ydotool/ydotool.debian.control b/ydotool/ydotool.debian.control new file mode 100644 index 0000000..ff3c622 --- /dev/null +++ b/ydotool/ydotool.debian.control @@ -0,0 +1,22 @@ +Package: ydotool +Version: 2:__VERSION__ +Maintainer: __MAINTAINER__ +Section: utils +Priority: optional +Architecture: amd64 +Depends: libc6 +Recommends: ydotoold +Description: Command-line automation tool - cli + Generic Linux command-line automation tool + . + 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 an 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) + . + This package contains the command-line utility. diff --git a/ydotool/ydotoold.debian.control b/ydotool/ydotoold.debian.control new file mode 100644 index 0000000..754e757 --- /dev/null +++ b/ydotool/ydotoold.debian.control @@ -0,0 +1,22 @@ +Package: ydotoold +Version: 2:__VERSION__ +Maintainer: __MAINTAINER__ +Section: utils +Priority: optional +Architecture: amd64 +Depends: libc6 +Suggests: ydotool +Description: Command-line automation tool - daemon + Generic Linux command-line automation tool + . + 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 an 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) + . + This package contains the daemon. diff --git a/ydotool/ydotoold.service b/ydotool/ydotoold.service new file mode 100644 index 0000000..d3617ae --- /dev/null +++ b/ydotool/ydotoold.service @@ -0,0 +1,13 @@ +[Unit] +Description=Command-line automation tool - daemon + +[Service] +Type=simple +User=root +WorkingDirectory=/run +EnvironmentFile=/etc/default/ydotoold +ExecStart=/usr/bin/ydotoold $ARGS +Restart=always + +[Install] +WantedBy=multi-user.target