Some checks are pending
Test / test (linux, []) (push) Waiting to run
Test / test (linux, [null portal uinput x11]) (push) Waiting to run
Test / test (linux, [null]) (push) Waiting to run
Test / test (linux, [portal]) (push) Waiting to run
Test / test (linux, [uinput]) (push) Waiting to run
Test / test (linux, [x11]) (push) Waiting to run
Test / test (windows, []) (push) Waiting to run
Test / test (windows, [null]) (push) Waiting to run
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.
149 lines
4 KiB
Bash
Executable file
149 lines
4 KiB
Bash
Executable file
#!/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
|