Corsinvest / cv4pve-pepper

Launching SPICE remote-viewer for Proxmox VE VDI client
https://www.corsinvest.it/cv4pve
GNU General Public License v3.0
105 stars 15 forks source link

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

Open komoricodrutz opened 2 weeks ago

komoricodrutz commented 2 weeks ago

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 commented 1 week ago

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?