diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2021-11-11 22:23:10 -0600 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2021-11-11 22:23:10 -0600 |
commit | a92bcfe91bc274970840cbd65e1389d0c4371e02 (patch) | |
tree | b0d507fc9bee430cb429d32e796201773c8599d3 /launch | |
parent | 73688982c135a0276a64aec7d61aaff4e9434d09 (diff) | |
download | scripts-a92bcfe91bc274970840cbd65e1389d0c4371e02.tar.xz scripts-a92bcfe91bc274970840cbd65e1389d0c4371e02.zip |
tssg changes and such
Diffstat (limited to 'launch')
-rwxr-xr-x | launch/virt | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/launch/virt b/launch/virt new file mode 100755 index 0000000..f1035a0 --- /dev/null +++ b/launch/virt @@ -0,0 +1,30 @@ +#!/bin/sh +virtdir=~/.local/share/virt + +halfram() { awk '/^MemTotal/ { printf "%dM\n", $2/2/1024 }' /proc/meminfo; } # Needs to be either in M or G according to man page +halfthreads() { echo $(( $(nproc) / 2 )); } +startvm() { + qemu-system-x86_64 \ + -enable-kvm \ + -cpu host \ + -m $(halfram) \ + -smp $(halfthreads) \ + -net nic \ + -nographic \ + -vga none \ + -audiodev pa,id=pa1,server=/run/user/1000/pulse/native \ + -soundhw all \ + -boot menu=on \ + -drive file="$virtdir/$1.img" \ +; } + + #-display sdl,gl=on \ +vms="$(ls $virtdir)" + +[ -n "$1" ] && vm="$1" || vm=$(echo "$vms" | sed 's/\.img//' | dmenu -p "Choose Virtual Machine Image or Enter Name for New Virtual Machine") + +if echo "$vms" | grep "^$vm.img$" >/dev/null; then + startvm "$vm" +else + qemu-img create -f qcow2 "$virtdir/$vm.img" $(echo -n "4G\n8G\n16G\n32G" | dmenu -p "Choose Size of Virtual Machine \"$vm\"") +fi |