Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
neverho0d opened this issue Feb 8, 2024 · 0 comments

Comments

@neverho0d
Copy link

neverho0d commented Feb 8, 2024

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!

@neverho0d neverho0d changed the title Hi! Wrapper script to start the app and provide tray icon to terminate it Feb 8, 2024
@neverho0d neverho0d changed the title Wrapper script to start the app and provide tray icon to terminate it Wrapper script to start the app and provide a tray icon to terminate it Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant