38 lines
1.3 KiB
Bash
Executable file
38 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
# ─< Check if the user is root and set sudo variable if necessary >───────────────────────
|
|
check_root() {
|
|
_sudo=""
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
if command_exists sudo; then
|
|
notify-send "looking-glass script" "User is not root. Using sudo for privileged operations."
|
|
_sudo="sudo"
|
|
else
|
|
notify-send "looking-glass script" "No sudo found and you're not root! Can't install packages."
|
|
return 1
|
|
fi
|
|
else
|
|
notify-send "looking-glass script" "Root access confirmed."
|
|
_sudo=""
|
|
fi
|
|
}
|
|
|
|
# Define the name of your VM
|
|
VM_NAME="win11"
|
|
connect="looking-glass-client -f /dev/shm/looking-glass -F -S input:rawMouse=yes -k"
|
|
|
|
# Check if the VM is running
|
|
if pgrep -f "qemu.*$VM_NAME" >/dev/null; then
|
|
notify-send "win11" "VM is already there, connecting now.."
|
|
sleep 1.5
|
|
$connect
|
|
else
|
|
notify-send "win11" "VM is currently DOWN. Starting it and connecting then.. Be patient.."
|
|
# Start the VM (adjust the command according to your setup)
|
|
# Example for starting with libvirt:
|
|
$_sudo virsh start "$VM_NAME"
|
|
# Example for starting with a direct QEMU command:
|
|
# qemu-system-x86_64 -enable-kvm -m 4G -cpu host -smp 4 -hda /path/to/win11.img &
|
|
|
|
# Wait a moment to ensure the VM starts properly
|
|
sleep 5 && $connect
|
|
fi
|