Skip to content

Commit 4650cd5

Browse files
committed
Switch to Remmina for connect, add fullscreen option
Fixes #48 to no longer logout of Windows after being disconnected for 60 seconds (only applies to new installs) Fixes non passwordless sudo systems trying to install any new dependencies in a non-visible shell Fixes usb forwarding udev file not being deleted if usb_passthrough variable is commented Changes WM_CLASS for yad to be bvm Closes #50 After these Remmina optimizations, it runs just as fast as freerdp, but more reliably and sets window decorations. In a future commit I may remove freerdp completely. Restructure config file to be more intuitive Now support new-vm mode being used to reset the config files
1 parent 0ba46f2 commit 4650cd5

File tree

4 files changed

+105
-135
lines changed

4 files changed

+105
-135
lines changed

bvm

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,11 @@ update_check() { #check for updates and reload the script if necessary
639639

640640
copy_icons() { #install icons to a location where the panel will notice them
641641
mkdir -p ~/.local/share/icons/hicolor/scalable/apps
642-
if [ ! -f ~/.local/share/icons/hicolor/scalable/apps/wlfreerdp.png ];then
642+
if [ ! -f ~/.local/share/icons/hicolor/scalable/apps/bvm.png ];then
643643
ln -sf "$DIRECTORY/resources/graphics/icon.png" ~/.local/share/icons/hicolor/scalable/apps/qemu.png
644644
ln -sf "$DIRECTORY/resources/graphics/icon.png" ~/.local/share/icons/hicolor/scalable/apps/wlfreerdp.png
645645
ln -sf "$DIRECTORY/resources/graphics/icon.png" ~/.local/share/icons/hicolor/scalable/apps/xfreerdp.png
646+
ln -sf "$DIRECTORY/resources/graphics/icon.png" ~/.local/share/icons/hicolor/scalable/apps/bvm.png
646647
fi
647648
#for wf-panel-pi at least, updating icon caches seems to do no good
648649
}
@@ -688,7 +689,7 @@ usb_passthrough_frontend() { #help the user add USB devices to be forwarded to t
688689
fi
689690

690691
output="$(lsusb | grep -vi hub | awk '{for(i=6; i<=NF; i++) printf "%s ", $i; print ""}' | sed 's/^/FALSE\n/ ; s/ /\n/' | yad \
691-
--window-icon "${DIRECTORY}/resources/graphics/icon.png" --class wlfreerdp --name wlfreerdp --title "BVM USB Passthrough Manager" \
692+
--window-icon "${DIRECTORY}/resources/graphics/icon.png" --class bvm --name bvm --title "BVM USB Passthrough Manager" \
692693
--width=510 --height=400 --center \
693694
--list --no-headers --checklist --column=:CHK --column=sysname --column=name --separator='\n' --print-column=2 \
694695
--text="Select USB devices to forward to the VM."$'\n'"Forwarded devices will stop working on Linux while the VM is running."$'\n'"Keyboard/mouse: bad idea unless you need all Windows keyboard shortcuts. Must use viewing mode "\""Direct"\"".")" || return 0
@@ -766,6 +767,7 @@ fi
766767
[ -z "$debloat" ] && debloat=true
767768
[ -z "$disksize" ] && disksize=40
768769
[ -z "$free_ram_goal" ] && free_ram_goal=100
770+
[ -z "$fullscreen" ] && fullscreen=false
769771
if [ -z "$vm_mem" ];then
770772
#choose RAM to allocate to VM - 1GB less than total RAM
771773
vm_mem="$(($(awk '/MemTotal/ {print $2}' /proc/meminfo)/1024/1024))"
@@ -795,7 +797,10 @@ vm_username: $vm_username
795797
vm_password: $vm_password
796798
vm_mem: $vm_mem
797799
rdp_port: $rdp_port
798-
download_language: $download_language"
800+
download_language: $download_language
801+
disksize: $disksize
802+
debloat: $debloat
803+
fullscreen: $fullscreen"
799804

800805
#check for updates
801806
update_check
@@ -823,7 +828,10 @@ elif [ ! -z "$vmdir" ] && df -T "$vmdir" 2>/dev/null | grep -q 'fat' ;then
823828
error "The $DL_DIR directory is on a FAT32/FAT16/vfat partition. This type of partition cannot contain files larger than 4GB, however the Windows image will be larger than that.\nPlease format the drive with an Ext4 partition, or use another drive."
824829
fi
825830

826-
install_dependencies || exit 1
831+
#avoid trying to run sudo not in a terminal, in case a password is necessary
832+
if [ "$mode" != gui ];then
833+
install_dependencies || exit 1
834+
fi
827835

828836
echo "BVM mode $mode"
829837

@@ -898,7 +906,7 @@ To get a fresh VM up and running, use a sequence like this:
898906
newvm) #1
899907
if [ -f "$vmdir/gui-steps-complete" ];then
900908
#pick location for new VM, this one already exists
901-
vmdir="$(yad --window-icon "${DIRECTORY}/resources/graphics/icon.png" --class wlfreerdp --name wlfreerdp --title "BVM" --center --directory --file --save --width 500 --text="$vmdir already exists."$'\n'"Proceed only if you are trying to make a second VM.")"
909+
vmdir="$(yad --window-icon "${DIRECTORY}/resources/graphics/icon.png" --class bvm --name bvm --title "BVM" --center --directory --file --save --width 500 --text="$vmdir already exists."$'\n'"Proceed only if you are trying to make a second VM.")"
902910
if [ ! -z "$vmdir" ] && [ "$vmdir" != "$HOME" ];then
903911
kill $YAD_PID
904912
export vmdir
@@ -934,15 +942,22 @@ To get a fresh VM up and running, use a sequence like this:
934942

935943
#change green message to not say next step
936944
define_step_complete="$(echo "$define_step_complete" | sed 's+Please close this terminal to proceed to the next step\.+Thank you for using BVM! This terminal can be closed now.+g')"
945+
946+
if [ "$3" == 'fullscreen' ];then
947+
fullscreen=true
948+
else
949+
fullscreen=false
950+
fi
951+
937952
case "$2" in
938953
Direct)
939-
run_in_terminal "${DIRECTORY}/bvm boot-gtk '$vmdir' ; step_complete"
954+
run_in_terminal "export fullscreen=$fullscreen ; ${DIRECTORY}/bvm boot-gtk '$vmdir' ; step_complete"
940955
;;
941956
FreeRDP)
942-
run_in_terminal "${DIRECTORY}/bvm boot-nodisplay '$vmdir' & sleep 15 ; nosplash=true ${DIRECTORY}/bvm connect-freerdp '$vmdir' ; step_complete"
957+
run_in_terminal "export fullscreen=$fullscreen ; ${DIRECTORY}/bvm boot-nodisplay '$vmdir' & sleep 15 ; nosplash=true ${DIRECTORY}/bvm connect-freerdp '$vmdir' ; step_complete"
943958
;;
944959
Remmina)
945-
run_in_terminal "${DIRECTORY}/bvm boot-nodisplay '$vmdir' & sleep 15 ; nosplash=true ${DIRECTORY}/bvm connect-remmina '$vmdir' ; step_complete"
960+
run_in_terminal "export fullscreen=$fullscreen ; ${DIRECTORY}/bvm boot-nodisplay '$vmdir' & sleep 15 ; nosplash=true ${DIRECTORY}/bvm connect-remmina '$vmdir' ; step_complete"
946961
;;
947962
*)
948963
error "clickhandler: unrecognized boot gui mode"
@@ -998,7 +1013,8 @@ To get a fresh VM up and running, use a sequence like this:
9981013
export button3="@bash -c 'clickhandler download'"
9991014
export button4="@bash -c 'clickhandler prepare'"
10001015
export button5="@bash -c 'clickhandler firstboot'"
1001-
export button6="@bash -c 'clickhandler boot %7'"
1016+
export button6="@bash -c "\""clickhandler boot '%7'"\"""
1017+
echo "button6 is $button6"
10021018
export mount_button="@bash -c 'clickhandler mount'"
10031019
export expand_button="@bash -c 'clickhandler expand'"
10041020
export usbsetup_button="@bash -c 'clickhandler usbsetup'"
@@ -1036,7 +1052,7 @@ To get a fresh VM up and running, use a sequence like this:
10361052
fi
10371053

10381054
#the window freezes while running a task, and wayland times it out, so run on xwayland
1039-
GDK_BACKEND=x11 yad --window-icon "${DIRECTORY}/resources/graphics/icon.png" --class wlfreerdp --name wlfreerdp --title "BVM" --form --center --width 400 \
1055+
GDK_BACKEND=x11 yad --window-icon "${DIRECTORY}/resources/graphics/icon.png" --class bvm --name bvm --title "BVM" --form --center --width 400 \
10401056
--image "${DIRECTORY}/resources/graphics/icon-80.png" --image-on-top --no-buttons \
10411057
--text="Botspot Virtual Machine, at your service.$([ "$vmdir" != "$HOME/win11" ] && echo -e "\nvmdir: <u>$vmdir</u>")" \
10421058
--field="<b>New Virtual Machine</b>!${DIRECTORY}/resources/graphics/1.png!Make a folder to put the VM files in - by default this is ~/win11":FBTN "@bash -c 'clickhandler newvm'" \
@@ -1045,7 +1061,7 @@ To get a fresh VM up and running, use a sequence like this:
10451061
--field="<b>Prepare for installation</b>!${DIRECTORY}/resources/graphics/4.png!Bundle up driver files and get ready for first boot":FBTN "$initial_button4" \
10461062
--field="<b>Install Windows 11</b>!${DIRECTORY}/resources/graphics/5.png!Boot the VM for the first time to install Windows":FBTN "$initial_button5" \
10471063
--field="<b>Run Windows 11</b>!${DIRECTORY}/resources/graphics/6.png!Boot the VM normally":FBTN "$initial_button6" \
1048-
--field="Viewing mode:":CB "Direct!^FreeRDP!Remmina" \
1064+
--field="Viewing mode:":CB "Direct!Direct fullscreen!FreeRDP!FreeRDP fullscreen!^Remmina!Remmina fullscreen" \
10491065
--field="Mount disk.qcow2!!Browse the full C: drive of the VM to add/remove files":FBTN "$initial_mount_button" \
10501066
--field="Expand disk.qcow2!!Increase the size of the storage available to the VM":FBTN "$initial_expand_button" \
10511067
--field="USB passthrough!!Give the VM direct access to specific USB devices":FBTN "$initial_usbsetup_button"
@@ -1057,10 +1073,15 @@ To get a fresh VM up and running, use a sequence like this:
10571073
mkdir -p "$vmdir" || error "failed to create vmdir '$vmdir'!"
10581074

10591075
#copy configuration file
1060-
cp -n "${DIRECTORY}/resources/bvm-config" "$vmdir"
1076+
cp -f "${DIRECTORY}/resources/bvm-config" "$vmdir"
1077+
#copy remmina config
1078+
#Remmina edits its config file and removes the password on first run, so make a copy for this VM to avoid modifying the version in the main folder.
1079+
cp -f "${DIRECTORY}/resources/connect.remmina" "$vmdir/connect.remmina"
10611080

1062-
#for GUI: track which step was completed
1063-
echo 1 > "$vmdir/gui-steps-complete"
1081+
#for GUI: track which step was completed. Avoid resetting an existing value to 1
1082+
if [ ! -f "$vmdir/gui-steps-complete" ];then
1083+
echo 1 > "$vmdir/gui-steps-complete"
1084+
fi
10641085

10651086
status_green "You should now be ready for the next step: $0 download $vmdir"
10661087
;;
@@ -1271,10 +1292,10 @@ To get a fresh VM up and running, use a sequence like this:
12711292
display_flags=(-vga none -device virtio-gpu-pci -display none)
12721293
;;
12731294
boot-ramfb)
1274-
display_flags=(-vga none -device ramfb -display gtk,gl=off,grab-on-hover=on)
1295+
display_flags=(-vga none -device ramfb -display gtk,gl=off,grab-on-hover=on$([ "$fullscreen" == true ] && echo ',full-screen=on'))
12751296
;;
12761297
boot-gtk|boot)
1277-
display_flags=(-vga none -device virtio-gpu-pci -display gtk,gl=on,grab-on-hover=on)
1298+
display_flags=(-vga none -device virtio-gpu-pci -display gtk,gl=on,grab-on-hover=on$([ "$fullscreen" == true ] && echo ',full-screen=on'))
12781299
;;
12791300
*)
12801301
error "Unknown suffix after 'boot': '$mode'"
@@ -1304,8 +1325,8 @@ To get a fresh VM up and running, use a sequence like this:
13041325

13051326
#handle USB forwarding preferences set by usb_passthrough variable
13061327
usb_forwarding_flags=() #this is not to be set in the config file, but created in the for loop. Set usb_passthrough instead.
1328+
udev_file="/etc/udev/rules.d/10-bvm-hw-access${rdp_port}.rules"
13071329
if [ ! -z "$usb_passthrough" ];then
1308-
udev_file="/etc/udev/rules.d/10-bvm-hw-access${rdp_port}.rules"
13091330
sudo rm -f "$udev_file"
13101331
trap "sudo rm -f '$udev_file'" EXIT SIGINT #remove this udev rule file on exit
13111332
IFS=' '
@@ -1318,7 +1339,12 @@ To get a fresh VM up and running, use a sequence like this:
13181339

13191340
usb_forwarding_flags+=(-device usb-host,vendorid=0x$vendor,productid=0x$product,driver=usb-host)
13201341
done
1342+
#now reload udev rules
1343+
sudo udevadm control -R
1344+
sudo udevadm trigger
13211345

1346+
elif [ -f "$udev_file" ];then #if usb redirection is now disabled, make sure to remove our udev file if present
1347+
sudo rm -f "$udev_file"
13221348
#now reload udev rules
13231349
sudo udevadm control -R
13241350
sudo udevadm trigger
@@ -1429,7 +1455,7 @@ To get a fresh VM up and running, use a sequence like this:
14291455

14301456
while true;do #Relaunch the viewer between VM reboots
14311457
case "$mode" in
1432-
connect-freerdp|connect)
1458+
connect-freerdp)
14331459

14341460
freerdp_flags=(/v:127.0.0.1:$rdp_port /u:$vm_username /p:$vm_password /relax-order-checks /cert:ignore +auto-reconnect \
14351461
/dynamic-resolution /sound +window-drag -sec-rdp -sec-tls +offscreen-cache +home-drive +menu-anims +multitouch \
@@ -1440,26 +1466,40 @@ To get a fresh VM up and running, use a sequence like this:
14401466
freerdp_flags+=(-window-drag -aero -menu-anims)
14411467
fi
14421468

1469+
#fullscreen mode: add flag to enable it
1470+
if [ "$fullscreen" == true ];then
1471+
freerdp_flags+=(/f)
1472+
fi
1473+
14431474
$freerdp_command "${freerdp_flags[@]}" "${add_freerdp_flags[@]}"
14441475
;;
1445-
connect-remmina)
1476+
connect-remmina|connect)
14461477

14471478
#change remmina's graphical settings based on reduce_graphics setting
14481479
if [ "$reduce_graphics" == true ];then
14491480
quality=0
14501481
else
14511482
quality=9
14521483
fi
1453-
#Remmina edits its config file and removes the password on first run, so make a copy for this VM to avoid modifying the version in the main folder.
1454-
cp -n "${DIRECTORY}/resources/connect.remmina" "$vmdir/connect.remmina"
1484+
1485+
#Copy new-and-improved remmina config
1486+
grep -qF 'to get microphone input working' "$vmdir/connect.remmina" || cp -f "${DIRECTORY}/resources/connect.remmina" "$vmdir/connect.remmina"
1487+
#Use Remmina to set parameters in profile
14551488
echo -e "$vm_username\n$vm_password\n127.0.0.1:$rdp_port\n$quality\n$HOME" | remmina --update-profile "$vmdir/connect.remmina" --set-option username --set-option password --set-option server --set-option quality --set-option drive
14561489

1490+
#fullscreen mode - enable toolbar, otherwise hide left-align toolbar which is mostly useless
1491+
if [ "$fullscreen" == true ];then
1492+
fullscreen_flag='--enable-fullscreen'
1493+
else
1494+
fullscreen_flag='--disable-toolbar'
1495+
fi
1496+
14571497
#now run remmina with its newly created/updated config file
1458-
remmina -c "$vmdir/connect.remmina" --enable-extra-hardening --no-tray-icon
1498+
remmina -c "$vmdir/connect.remmina" --enable-extra-hardening --no-tray-icon $fullscreen_flag --class bvm --name bvm
14591499
;;
14601500
esac
14611501
status "RDP viewer exited. Analyzing..."
1462-
sleep 5
1502+
sleep 6
14631503

14641504
#wait for RDP service to come back, or exit loop if QEMU stopped
14651505
messaged=0
@@ -1478,7 +1518,7 @@ To get a fresh VM up and running, use a sequence like this:
14781518
#immediately got to this state, so VM never went offline but RDP viewer closed.
14791519
#ask for user input to prevent a forever failed connection loop
14801520
status_green "VM never went offline."
1481-
status -n "Assuming you disconnected. Press any key to reconnect."
1521+
status -n "Assuming you disconnected. Press any key to reconnect, or Ctrl+C to exit."
14821522
read -N1 key
14831523
break
14841524
fi
@@ -1659,6 +1699,7 @@ sudo chown $USER:$USER /dev/tap$(cat /sys/class/net/macvtap0/ifindex)
16591699

16601700
#remmina is faster than all other viewing methods that work, has perfect audio too
16611701
#remmina config doc: https://remmina.gitlab.io/remminadoc.gitlab.io/md__builds__remmina_remmina_ci__remmina_wiki__remmina__config__file__options.html
1702+
#remmina colordepth options: https://github.com/FreeRDP/Remmina/blob/7bc15420b6e6a2a4540f20aeccfabe9cff4b7fd3/plugins/rdp/rdp_plugin.c#L1686
16621703
#cannot run program on startup because exec= uses FreeRDP_AlternateShell which is ignored by Windows 10/11
16631704
#See https://superuser.com/questions/1202758/how-to-use-rdp-alternative-shell-inital-program-in-windows-10education
16641705
#RemoteApp not supported by Remmina

resources/bvm-config

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,33 @@
55
#BVM sources the script on each run in order to pick up your settings in an easier format.
66

77
#Do not change this file if it is in the bvm/resources folder. Leave that one alone.
8-
#Make changes to the copy of the file in your VM directory. Example: ~/win11/bvm-config
9-
#This file will be copied to the VM folder when you run bvm new-vm
8+
#Make changes to the copy of the file in your VM directory that is created after running bvm new-vm
109

11-
#Windows username and password to set during the firstboot mode
10+
#Windows username and password to set during the firstboot mode.
1211
vm_username="Win11ARM"
1312
vm_password="win11arm"
14-
#If you change the credentials later, update them here for the connect mode to work.
13+
#If you change your windows user/password, change it here too for the connect mode to work.
1514

16-
#Select language. List all languages with: bvm list-languages
15+
#Select Windows language to download. List all languages with: bvm list-languages
1716
download_language="English (United States)"
1817

19-
#If you have mutliple VMs, give each one a unique value.
20-
rdp_port=3389
21-
#Make sure this value does not conflict with other network services shown when running netstat -tuln
22-
23-
#Change this to false if you don't want Microsoft bloatware, ads, and Windows Defender removed
18+
#Change this to false if you don't want Microsoft bloatware, ads, and Windows Defender removed during firstboot.
2419
debloat=true
2520
#Be aware that other registry changes (like dark mode, disabling hibernation, and RDP) will still be run on the VM.
2621
#Inspect the firstlogin.ps1 and autounattend.xml files for more details.
2722

23+
#Choose the initial size of the disk image.
24+
disksize=40
25+
#This can go as low as 20 if you encounter the "Insufficient free disk space" error.
26+
#The drive can be expanded later, but not from this config option.
27+
28+
##### ATTENTION!!!
29+
##### The above options need to be set before running the download step.
30+
##### The remaining options can be changed at any time.
31+
32+
#If you have mutliple VMs, give each one a unique value.
33+
rdp_port=3389
34+
2835
#Force RAM allocation for QEMU. (in gigabytes) It's recommended to leave this commented for BVM to choose a sensible value.
2936
#vm_mem=4
3037
#If your device has 4GB or less RAM, it is strongly recommended you set up ZRAM.
@@ -36,24 +43,22 @@ debloat=true
3643
#Every second, the VM will adjust its RAM allocation to make sure this much is freely available for Linux.
3744
#If linux tasks begin to use more, the VM will compensate and use less.
3845

39-
#Uncomment this to change size of the installation drive image in gigabytes. Default 40
40-
#disksize=40
41-
#You can reduce this if you encounter the "Insufficient free disk space" error.
42-
#The lower limit is somewhere around 15 GB (untested)
43-
44-
#Uncomment to enable additional output to help troubleshoot issues.
45-
#bvm_debug=true
46-
#Even more debugging: (displays every command run by the script)
47-
#set -x
48-
4946
#USB forwarding: uncomment this line for the VM to have direct access to a USB device.
5047
#usb_passthrough='05dc:a720'
5148
#Replace 05dc:a720 with the value you see, for the device you want, from the output of lsusb
5249
#For multiple devices, keep it in those quotes, but separate each one with a space character.
5350

54-
#Uncomment this to turn off animations and transparency (lowers CPU a bit, makes more of a difference on X11)
51+
#Uncomment this to turn off animations and transparency in the connect mode
5552
#reduce_graphics=true
5653

54+
#Uncomment to view the VM in fullscreen. Uncommenting this overrides the fullscreen setting in GUI.
55+
#fullscreen=true
56+
57+
#Uncomment to enable additional output to help troubleshoot issues.
58+
#bvm_debug=true
59+
#Even more debugging: (displays every command run by the script)
60+
#set -x
61+
5762
#Uncomment to disable BVM updates. Useful if you have changed the script and do not want your changes overwritten
5863
#disable_updates=true
5964
#Most users should not have to be modifying the bvm script. It is preferable to keep all changes in this config file.

0 commit comments

Comments
 (0)