Coding desktop shortcut for KMV virt-manager guest os Z16

I've been at this for hours. I honestly have no clue what I'm doing.

I'm trying to make a desktop shortcut to the QEMU/KMV guest os.

I found this code, which calls the guest up in terminal like a charm.

virt-manager --connect qemu:///system --show-domain-console Xubuntu

So I took that to create a script and saved it as an .sh file to /scripts/

virt-manager --connect qemu:///system --show-domain-console Xubuntu

Then I made a .desktop file with this information and saved it to /usr/share/applications/...

[Desktop Entry]
Comment=Start Xubuntu VM

I used chmod +x to make the script executable and for the shortcut too.

But it isn't working. Clicking the shortcut brings up a window asking if I want to run it or display its contents. Nothing happens when I select "execute" and the icon isn't showing either.

I do have snippets of code from other sources, but for the life of me I can't make this work. Help?!

Just for reference, I got the info from these 2 sources:
Virt-Manager Directly launch Guest Os
Shortcut Launcher for KMV

Should this be:

/usr/bin/virt-manager --connect qemu:///system --show-domain-console Xubuntu $1

Avoid referencing home as ~ in a desktop entry. Use the Full Path, instead
(replace "$USER" or "username" with your actual system username):

Lol. I know. I only changed it here in the forum as I'd prefer not to share my user name publicly. It's typed out in the file. :wink:

But I don't know what you mean about the "~" . Should I just take it out?

Okay, I updated the script (thank you!)... but still nada. There must be something I've got wrong, but I just don't know enough to know what it is.


Gonna call on @337harvey and see if he can help - he is pretty good with bash scripting.

Super appreciate it!

Questions though? It's a learning moment for me. What does the $1 do? And, should I be saving my script as a .sh or .bash?

First argument.

A .sh is a Shell Script.
So that is the proper way to save it. I think that .bash would be a file name only. For example~/.bash_history

1 Like

Okay, did that. Now I'm getting an error from Virt-Manager

Error starting Virtual Machine manager: Unhandled command line options ['home/myusername/Desktop/Xubuntu-vm.desktop']

At least it's trying to respond to the script now.

Um... This may be a dumb question on my part, but in the above, you had it in /scripts - did you move the file?
EDIT: Nevermind, I misread it and yes, it was a dumb question. I just realized what I read and what I thought I read.

Can you remove the first argument ($1) and then try it?

Sorry, food was calling.

I'm looking it over now... give me a few minutes if you don't mind.

1 Like

I keep telling you...


1 Like

I understand what your trying to do, but if you scrolled down in the first link it provided a script that should perform what you are looking for complete with the desktop entry.

# call this script with domainname as parameter
# to start domain and open viewer

/usr/bin/virsh start $1
# domain must be known to virsh

/usr/bin/virt-viewer -w $1
# -w to wait until domain is running.

This script takes the domain as input ($1) from the command-line... so you would call:

sh [domain-name]

In your script above you call the domain Xubuntu... is this correct? Remember capitalization counts. You can hardcode it like that but defining the domain at the terminal when called allows for change. Matter of choice.

1 Like

The desktop file looks OK... tilde is an alias to /home/$USER/ directory

1 Like

Your missing something... an = after connect, no spaces.

So your script should read:

virt-manager --connect=qemu:///system --show-domain-console Xubuntu


True, I just prefer full path because it is easy to miss a whitespace after tilde.

1 Like

Thanks so much for replying @337harvey . It's actually working now (mostly). Moved the script and icon to a folder in the /home/ directory, and just removed the ' ' around the directory names and it's working and have it on my dash dock no less!

Only, for the life of me, I cannot get the png icon to show. Any ideas?

Right click it, choose properties then click on the left image and browse to the .png file. Click ok

1 Like

Which script did you use for anyone else looking for the solution?

Actually, it's working now, without the = . It was the ' ' around the directory names. Just can't get the icon to show.

Well, it was a part of the command... sometimes those things are written to be omitted on occasion. Up to the developer

1 Like