diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2021-10-11 15:08:51 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2021-10-11 15:08:51 -0500 |
commit | 2cf3ea2f828f6da07adff92a7dc5bce6069620ab (patch) | |
tree | 213dabd2d9301d3930f47f2a03c901dfbb100297 /keyboard | |
parent | 551e1c638a6a4ff2130b3c374774f6006b28467d (diff) | |
download | scripts-2cf3ea2f828f6da07adff92a7dc5bce6069620ab.tar.xz scripts-2cf3ea2f828f6da07adff92a7dc5bce6069620ab.zip |
sinking
Diffstat (limited to 'keyboard')
-rwxr-xr-x | keyboard/mnt | 7 | ||||
-rwxr-xr-x | keyboard/umnt | 4 | ||||
-rwxr-xr-x | keyboard/virt | 28 |
3 files changed, 34 insertions, 5 deletions
diff --git a/keyboard/mnt b/keyboard/mnt index 5f82aa4..7547912 100755 --- a/keyboard/mnt +++ b/keyboard/mnt @@ -1,10 +1,11 @@ #!/bin/sh -if partition=`lsblk --noheadings --paths --raw | awk '/part $/ { print $1, "(" $4 ")" }' | dmenu -p "Choose drive to mount: " | sed 's/ .*//'` \ +# '/part\s*$\|rom\s*$/!d; s/\s*[^[:space:]]*\s*$/\)/; s/\s/ \(/' # More correct in my opinion, but slower +if partition=`lsblk -npro "name,size,type,mountpoint" | sed '/part $\|rom $/!d; s/ [a-z]* $/\)/; s/ / \(/' | dmenu -p "Choose drive to mount: " | cut -d' ' -f1` \ && [ -n "$partition" ] \ -&& mountpoint=`ls --directory /media/mnt/*/ | dmenu -p "Choose mountpoint: "` \ +&& mountpoint=`ls -d /media/mnt/slot*/ | dmenu -p "Choose mountpoint: "` \ && [ -n "$mountpoint" ] then - doas mount "$partition" "$mountpoint" \ + doas mount "$partition" "$mountpoint"; user="$(whoami)"; ug="$(groups | cut -d' ' -f1)"; doas chown "$user":"$ug" "$mountpoint" \ && notify-send --urgency low "Device Successfully Mounted" "Successfully Mounted partition \"$partition\" to mountpoint \"$mountpoint\"" \ || notify-send --urgency low "Error Mounting Device" "Could not mount partition \"$partition\" to mountpoint \"$mountpoint\"" fi diff --git a/keyboard/umnt b/keyboard/umnt index a77dc65..8191047 100755 --- a/keyboard/umnt +++ b/keyboard/umnt @@ -2,7 +2,7 @@ exclude='\/efi$|\/boot$|\/home$|tbhdd$|\/$' if mountedpartition=`lsblk --noheadings --paths --raw | awk "/part .+/ && !/$exclude/ "'{ print $1, "(on", $7 ")" }' | dmenu -p "Unmount Device... "` then - doas umount "`echo $mountedpartition | sed 's/ .*//'`" \ - && notify-send --urgency low "Device Successfully Unmounted" "Partition \"$mountedpartition\" successfully unmounted" \ + doas umount -A "`echo $mountedpartition | sed 's/ .*//'`" \ + && notify-send --urgency low "Device Successfully Unmounted" "Partition \"$mountedpartition\" successfully unmounted" --time 120000 \ || notify-send --urgency low "Error Unmounting Device" "Could not unmount partition \"$mountedpartition\"" fi diff --git a/keyboard/virt b/keyboard/virt new file mode 100755 index 0000000..446bfb3 --- /dev/null +++ b/keyboard/virt @@ -0,0 +1,28 @@ +#!/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() { awk '/^processor/ { cpus++ } END{ print cpus/2 }' /proc/cpuinfo; } +startvm() { + qemu-system-x86_64 \ + -enable-kvm \ + -cpu host \ + -m $(halfram) \ + -smp $(halfthreads) \ + -vga virtio \ + -display sdl,gl=on \ + -audiodev pa,id=pa1,server=/run/user/1000/pulse/native \ + -soundhw all \ + -boot menu=on \ + -drive file="$virtdir/$1.img" \ +; } + +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 |