Skip to content

Wrapper script to start the app and provide a tray icon to terminate it #71

@neverho0d

Description

@neverho0d

Hi!

It's not the issue, your application is just great and does what it has to do. Thank you a lot!

I just want to share a script I wrote - a wrapper to start the app with fixed connection parameters (port and connection secret) for a quick predefined connection and to create a tray icon to stop the app in a desktop environment.
I think it could be useful for someone else.
Here is a script:

#!/bin/bash

# Command to run in the background
COMMAND="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=remote-touchpad-wait-on-error com.github.unrud.RemoteTouchpad -bind :33333 -move-speed 1.4 -secret THESECRET= -scroll-speed -1"

# Start the command in the background and get its PID
nohup $COMMAND >/dev/null 2>&1 &
PID=$!

# Function to display a confirmation dialog and handle action
confirm() {
    RT_PID=`ps ax | grep 'remote-touchpad ' | grep -v grep | awk '{print $1}'`

    yad --image dialog-question \
	--title "Remote Touchpad" \
	--button=No:0 \
	--button=Yes:1 \
	--text "Terminate the Remote Touchpad?" \
	--mouse
    action=$?
    
    if [[ $action -eq 1 ]]; then
        kill $RT_PID
        exit 0
    fi
}

export -f confirm

# Create a tray icon using yad
yad --notification \
	--image="com.github.unrud.RemoteTouchpad" \
	--text="Terminate Remote Touchpad" \
	--command="bash -c 'confirm'" &

YAD_PID=$!

# Wait for the command to finish
wait $PID

# After the command finishes, remove the tray icon
kill $YAD_PID

The script requires yad to be installed, apt install yad or dnf install yad.
I used the Remote Touchpad installed from Flatpal under Fedora 39, so if the application is installed by another way, the command should be updated.
Also. I use -scroll-speed -1 to make the scrolling direction the same as my laptop's touchpad does, it could be removed if doesn't needed.
Enjoy!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions