Add create .desktop shortcut feature.

Deleted debug messages. Use `quemu-virgil` icon from the 'current' directory, not a specified version's directory. Tidied some code.
pull/24/head
Mark Crouch 5 years ago committed by GitHub
parent 1dd2c813d7
commit 7a5433f8fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      README.md
  2. 35
      quickemu

@ -91,6 +91,11 @@ Starting /media/martin/Quickemu/ubuntu-focal-desktop.conf
* Complete the installation as normal.
* A Desktop shortcut can be created (in ~/.local/share/applications):
```
./quickemu --shortcut --vm ubuntu-focal-desktop.conf
```
### Windows 10
You can use `quickemu` to run a Windows 10 virtual machine.
@ -160,6 +165,7 @@ Usage
You can also pass optional parameters
--delete : Delete the disk image.
--shortcut : Create a desktop shortcut
--snapshot apply <tag> : Apply/restore a snapshot.
--snapshot create <tag> : Create a snapshot.
--snapshot delete <tag> : Delete a snapshot.
@ -169,7 +175,7 @@ You can also pass optional parameters
## TODO
- [ ] Create desktop launcher for a VM
- [x] Create desktop launcher for a VM
- [ ] Improve disk management
- [x] Add USB pass-through support
- [x] Fix Virgil 3D on EFI boot

@ -8,6 +8,12 @@ function disk_delete() {
else
echo "NOTE! ${disk_img} not found. Doing nothing."
fi
local VMNAME=$(basename "${VM}" .conf)
local SHORTCUT_DIR="/home/${USER}/.local/share/applications/"
if [ -e ${SHORTCUT_DIR}/${VMNAME}.desktop ]; then
rm -v "${SHORTCUT_DIR}/${VMNAME}.desktop"
echo "Deleted ${VM} desktop shortcut"
fi
}
function snapshot_apply() {
@ -377,6 +383,22 @@ function vm_boot() {
fi
}
function shortcut_create {
local VMNAME=$(basename "${VM}" .conf)
local LAUNCHER_DIR="$(dirname "$(realpath "$0")")"
local filename="/home/${USER}/.local/share/applications/${VMNAME}.desktop"
cat << EOF > ${filename}
[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Exec=${LAUNCHER_DIR}/${LAUNCHER} --vm ${VM}
Name=${VMNAME}
Icon=/snap/qemu-virgil/current/meta/gui/icon.png
EOF
echo "Created ${VMNAME}.desktop file"
}
function usage() {
echo
echo "Usage"
@ -384,6 +406,7 @@ function usage() {
echo
echo "You can also pass optional parameters"
echo " --delete : Delete the disk image."
echo " --shortcut : Create a desktop shortcut"
echo " --snapshot apply <tag> : Apply/restore a snapshot."
echo " --snapshot create <tag> : Create a snapshot."
echo " --snapshot delete <tag> : Delete a snapshot."
@ -408,6 +431,7 @@ SNAPSHOT_TAG=""
STATUS_QUO=""
USB_PASSTHOUGH=""
VM=""
SHORTCUT=0
readonly LAUNCHER=$(basename "${0}")
readonly DISK_MIN_SIZE=$((197632 * 8))
@ -441,6 +465,9 @@ while [ $# -gt 0 ]; do
VM="${2}"
shift
shift;;
-shortcut|--shortcut)
SHORTCUT=1
shift;;
-h|--h|-help|--help)
usage;;
*)
@ -495,4 +522,10 @@ if [ -n "${SNAPSHOT_ACTION}" ]; then
esac
fi
vm_boot
if [ ${SHORTCUT} -eq 1 ]; then
# echo "VM=" ${VM}
shortcut_create
exit
fi
vm_boot

Loading…
Cancel
Save