Hyprland-dotfiles/scripts/launchvm.sh

61 lines
2.0 KiB
Bash
Raw Permalink Normal View History

2023-06-07 02:51:31 -04:00
#!/bin/bash
2024-05-27 09:18:12 -04:00
# _ _ __ ____ __
# | | __ _ _ _ _ __ ___| |__ \ \ / / \/ |
# | | / _` | | | | '_ \ / __| '_ \ \ \ / /| |\/| |
# | |__| (_| | |_| | | | | (__| | | | \ V / | | | |
# |_____\__,_|\__,_|_| |_|\___|_| |_| \_/ |_| |_|
#
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
2023-06-07 02:51:31 -04:00
2023-09-22 11:45:38 -04:00
if [ -f ~/private/win11-credentials.sh ]; then
2024-05-27 09:18:12 -04:00
echo "Credential file exists. Using the file."
source ~/private/win11-credentials.sh
2023-09-22 11:45:38 -04:00
else
2024-05-27 09:18:12 -04:00
win11user="USER"
win11pass="PASS"
win11ip="192.168.122.44"
win11name="windows11"
echo "## Preparing to remotely access your Windows virtual machine ##"
echo -n "Please enter your virtual machine name [default: $win11name]: "
read vmname
vmname=${vmname:-$win11name}
echo -n "Please enter your virtual machine ip [default: $win11ip]: "
read vmip
vmip=${vmip:-$win11ip}
echo -n "Please enter your username [default: $win11user]: "
read user
user=${user:-$win11user}
echo -n "Please enter your password [default: $win11pass]: "
read password
password=${password:-$win11pass}
2023-09-22 11:45:38 -04:00
fi
2024-05-27 09:18:12 -04:00
# echo "Hello, $vmname, $vmip, $user, $password"
2023-10-04 11:05:17 -04:00
2024-05-27 09:18:12 -04:00
tmp=$(virsh --connect qemu:///system list | grep " $vmname " | awk '{ print $3}')
2023-09-22 11:45:38 -04:00
2024-05-27 09:18:12 -04:00
if ([ "x$tmp" == "x" ] || [ "x$tmp" != "xrunning" ]); then
echo "Virtual Machine $vmname is starting now... Waiting 30s before starting xfreerdp."
notify-send "Virtual Machine $vmname 11 is starting now..." "Waiting 30s before starting xfreerdp."
virsh --connect qemu:///system start $vmname
sleep 30
2023-06-07 02:51:31 -04:00
else
2024-05-27 09:18:12 -04:00
notify-send "Virtual Machine $vmname is already running." "Launching xfreerdp now!"
echo "Starting xfreerdp now..."
2023-06-07 02:51:31 -04:00
fi
2024-05-27 09:18:12 -04:00
if command -v xfreerdp >/dev/null 2>&1; then
xfreerdp -grab-keyboard /v:$vmip /size:100% /cert-ignore /u:$user /p:$password /d: /dynamic-resolution /gfx-h264:avc444 +gfx-progressive /f &
elif command -v xfreerdp3 >/dev/null 2>&1; then
xfreerdp3 -v:$vmip -u:$user -p:$password -d: -dynamic-resolution /cert:ignore /f /gfx:AVC444 &
else
echo "'xfreerdp' or 'xfreerdp3' command not found."
fi