From ed7e8bae543324bdd6faf0fa614142b471eb5770 Mon Sep 17 00:00:00 2001 From: Luka Jankovic Date: Fri, 14 Aug 2026 21:59:58 +0200 Subject: [PATCH] Add systemd user service and CLI wrapper for remote-touchpad This commit introduces a complete systemd user service setup for remote-touchpad, eliminating the need for users to manually manage the binary process. Key additions: - New rts CLI wrapper script providing a user-friendly interface for service management without requiring root access - Systemd service file for proper background operation with restart policies and dependency management - Service management commands: install, start, stop, status, restart, and uninstall - URL extraction and QR code generation via the url command - Service log viewing via the log command The installation process now: 1. Verifies Go is installed 2. Builds the remote-touchpad binary with appropriate tags 3. Installs service files to ~/.config/systemd/user/ 4. Installs the binary to ~/.local/bin/ 5. Enables and starts the service automatically The README has been updated with comprehensive installation instructions for the new user service approach. --- README.md | 29 ++++++++ remote-touchpad.service | 12 ++++ rts | 149 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 remote-touchpad.service create mode 100755 rts diff --git a/README.md b/README.md index fd05b7a..e039950 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,35 @@ Supports Flatpak's RemoteDesktop portal (for Wayland), Windows and X11. go install github.com/unrud/remote-touchpad@latest ``` +## Linux User Service Installation + +To install remote-touchpad as a user-specific systemd service (no root access required): + +1. Clone the repository and navigate to the project directory: + + ```sh + git clone https://github.com/Unrud/remote-touchpad.git + cd remote-touchpad + ``` + +2. Install the service using the provided wrapper script (no sudo required): + + ```sh + ./rts install + ``` + +3. Access the service: + + * View service status: `./rts status` + * Get URL: `./rts url` + * View logs: `./rts log` + * Stop service: `./rts stop` + * Start service: `./rts start` + * Restart service: `./rts restart` + * Uninstall: `./rts uninstall` + +The service will run in the background and maintain a persistent connection with URL and QR code accessible via the `url` command. + ## Screenshots ![screenshot 1](https://raw.githubusercontent.com/Unrud/remote-touchpad/master/screenshots/1.png) diff --git a/remote-touchpad.service b/remote-touchpad.service new file mode 100644 index 0000000..76f5a74 --- /dev/null +++ b/remote-touchpad.service @@ -0,0 +1,12 @@ +[Unit] +Description=Remote Touchpad Service +After=network.target + +[Service] +Type=simple +ExecStart=%h/.local/bin/remote-touchpad +Restart=always +RestartSec=5s + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/rts b/rts new file mode 100755 index 0000000..84fbe46 --- /dev/null +++ b/rts @@ -0,0 +1,149 @@ +#!/bin/bash + +# Remote Touchpad CLI Wrapper +# Provides easy access to remote-touchpad service + +SERVICE_NAME="remote-touchpad" +SERVICE_USER="$USER" + +install() { + echo "Installing remote-touchpad as a user systemd service..." + + # Check if Go is installed + if ! command -v go &> /dev/null; then + echo "Error: Go is not installed. Please install Go first." + return 1 + fi + + echo "Building remote-touchpad binary..." + go build -tags portal,uinput,x11 -o remote-touchpad + + if [ ! -f "remote-touchpad" ]; then + echo "Error: Failed to build remote-touchpad binary" + return 1 + fi + + # Setup directories + mkdir -p ~/.local/bin ~/.config/systemd/user + + echo "Installing service files..." + cp remote-touchpad ~/.local/bin/ || echo "Error: cp to ~/.local/bin failed" + cp remote-touchpad.service ~/.config/systemd/user/ || echo "Error: cp to ~/.config/systemd/user failed" + + echo "Enabling and starting service..." + systemctl --user daemon-reload + systemctl --user enable --now ${SERVICE_NAME}.service + + echo "✓ remote-touchpad user service installed and started" + echo "" + echo "Use './rts status' to check the service" + echo "Use './rts url' to get the connection URL" +} + +start() { + systemctl --user start ${SERVICE_NAME}.service + echo "Started remote-touchpad service" +} + +stop() { + systemctl --user stop ${SERVICE_NAME}.service + echo "Stopped remote-touchpad service" +} + +status() { + systemctl --user status ${SERVICE_NAME}.service --no-pager +} + +restart() { + systemctl --user restart ${SERVICE_NAME}.service + echo "Restarted remote-touchpad service" +} + +url() { + # Extract URL from service logs + echo "Fetching remote-touchpad URL..." + local url=$(journalctl --user -u ${SERVICE_NAME}.service -n 100 --no-pager 2>/dev/null | grep -oE "http://[^ ]+|https://[^ ]+" | tail -1) + if [ -n "$url" ]; then + echo "Remote Touchpad URL: $url" + # Generate QR code if qrencode is available + if command -v qrencode &> /dev/null; then + echo "Generating QR code..." + echo "$url" | qrencode -t ansiutf8 + else + echo "QR code generation requires qrencode. Install it with:" + echo " sudo apt-get install qrencode # Debian/Ubuntu" + echo " sudo dnf install qrencode # Fedora" + echo " brew install qrencode # macOS" + fi + else + echo "Could not find URL in service logs. Is the service running?" + fi +} + +log() { + echo "Viewing remote-touchpad service logs..." + journalctl --user -u ${SERVICE_NAME}.service --no-pager +} + +uninstall() { + echo "Uninstalling remote-touchpad..." + systemctl --user stop ${SERVICE_NAME}.service + systemctl --user disable ${SERVICE_NAME}.service + rm -f ~/.config/systemd/user/${SERVICE_NAME}.service + rm -f ~/.local/bin/remote-touchpad + systemctl --user daemon-reload + echo "✓ remote-touchpad uninstalled" +} + +help() { + echo "Remote Touchpad CLI Wrapper" + echo "" + echo "Usage: rts [command]" + echo "" + echo "Commands:" + echo " install - Install remote-touchpad as a systemd user service" + echo " start - Start the remote-touchpad service" + echo " stop - Stop the remote-touchpad service" + echo " status - Check service status" + echo " restart - Restart the service" + echo " url - Show the remote-touchpad URL" + echo " log - View service logs" + echo " uninstall - Uninstall the service" + echo " help - Show this help message" +} + +# Main command handler +case "$1" in + install) + install + ;; + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + restart) + restart + ;; + url) + url + ;; + log) + log + ;; + uninstall) + uninstall + ;; + help|--help|-h|"") + help + ;; + *) + echo "Unknown command: $1" + help + exit 1 + ;; +esac