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

Application exits when trying to launch it from a script #35

Open
komoricodrutz opened this issue Nov 8, 2024 · 1 comment
Open

Application exits when trying to launch it from a script #35

komoricodrutz opened this issue Nov 8, 2024 · 1 comment

Comments

@komoricodrutz
Copy link

komoricodrutz commented Nov 8, 2024

Hi guys,
Thank you for this nice program, exactly what I was looking for to use in my homelab.

I've created a little script to prompt for VMID, username and password and then to run this program. It works perfectly when run from terminal. But if you run it via double-click, it runs the spice viewer and then immediately exits.
I tried 'exec' at the end and also '& disown', but it still happens.
Am I doing something wrong?

#!/bin/bash
export DISPLAY=:0
spicer="[path-to-cv4pve-pepper]"
server="[my-proxmox-server]"
rviewer="/usr/bin/remote-viewer"
unset username
unset password
unset vmident
echo -n "Enter the VM ID: "
read vmident
echo -n "Enter your User ID: "
read username
prompt="Enter your password: "
while IFS= read -p "$prompt" -r -s -n 1 char
do
    if [[ $char == $'\0' ]]
    then
         break
    fi
    prompt='*'
    password+="$char"
done
echo Launching the Spice viewer...
echo
echo
$spicer --host=$server --username=$username --password=$password --vmid $vmident --viewer $rviewer
#exec $spicer --host=$server --username=$username --password=$password --vmid $vmident --viewer $rviewer
#exec $spicer --host=$server --username=$username --password=$password --vmid $vmident --viewer $rviewer & disown
#$spicer --host=$server --username=$username --password=$password --vmid $vmident --viewer $rviewer & disown
sleep 5

The commented-out sections are what I tried until now. They all work when running it from a terminal window, as mentioned.
The 'sleep 5' entry at the end is just to check that the spice viewer is actually launching and it does. It just exits immediately once the script has finished.
Using Linux Mint 20.3 Cinnamon.

Any help would be appreciated.
Have a wonderful day!

Steps to reproduce:
Run the script from terminal: Everything works fine:
image

Run from Desktop GUI (nemo):
image

image

Runs fine but after the sleep period is over, it just exists

@komoricodrutz
Copy link
Author

As a workaround, I have created a .desktop launcher with the following content:

[Desktop Entry]
Name=SpiceStart
Comment=Self-Contained apps and scripts
Exec=gnome-terminal -x bash -c "[path-to-the-launch-script]sh; exec bash"
Terminal=true
Icon=applications-utilities
Type=Application

Now the only drawback remains that if you close the terminal window by accident, it will also close the spice window. If you close the spice window, the terminal window will remain open.
What can I do to avoid these behaviours?

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