liferaft/rustdesk.sh
2024-02-05 10:48:48 +00:00

59 lines
1.8 KiB
Bash

#!/bin/bash
# Variables
RUSTDESK_URL="https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.deb"
RUSTDESK_DEB="rustdesk-1.2.3-x86_64.deb"
# Check for RustDesk installation and remove it if present
if dpkg -l | grep -qw rustdesk; then
echo "RustDesk is already installed. Uninstalling..."
sudo dpkg --purge rustdesk
else
echo "RustDesk is not installed. Proceeding with installation."
fi
echo "Downloading RustDesk..."
# Download the RustDesk .deb package
if curl -L "$RUSTDESK_URL" -o "$RUSTDESK_DEB"; then
echo "Download successful."
else
echo "Download failed. Please check the URL and try again."
exit 1
fi
echo "Installing RustDesk..."
# Attempt to install the RustDesk package
if sudo dpkg -i "$RUSTDESK_DEB"; then
echo "RustDesk installed successfully."
else
echo "Error: dpkg encountered an issue installing RustDesk. Attempting to fix..."
if ! sudo apt-get install -f; then
echo "Error: Failed to resolve dependencies. Exiting."
exit 1
else
echo "Dependencies resolved. Please try installing RustDesk again."
fi
fi
echo "Starting RustDesk..."
# Start RustDesk and attempt to bring its window to the foreground
if ! pgrep -x "rustdesk" > /dev/null; then
rustdesk &
sleep 2 # Give RustDesk a moment to start
# Attempt to focus the RustDesk window. This method may need adjustment based on the desktop environment.
WINDOW_ID=$(xdotool search --onlyvisible --class rustdesk | head -1)
if [ ! -z "$WINDOW_ID" ]; then
xdotool windowactivate "$WINDOW_ID"
else
echo "RustDesk started but could not focus the window automatically."
fi
else
echo "RustDesk is already running."
fi
echo "Cleaning up..."
rm -f "$RUSTDESK_DEB"
echo "Installation complete."