better scripts

This commit is contained in:
2025-07-29 02:07:07 +02:00
parent f648bdc99a
commit f2144078e9
8 changed files with 37 additions and 26 deletions

29
.utils/live-mount.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
[ -z "$MOUNT_DIR" ] && MOUNT_DIR="/mnt"
if ! umount "$MOUNT_DIR" -R; then
echo "Failed to unmount $MOUNT_DIR."
exit 1
fi
[ -z "$DEVICE" ] && DEVICE="/dev/sda"
[ -z "$START_PART" ] && START_PART="1"
efi_part="${DEVICE}p${START_PART}"
START_PART=$(expr $START_PART + 1)
boot_part="${DEVICE}p${START_PART}"
START_PART=$(expr $START_PART + 1)
btrfs_part="${DEVICE}p${START_PART}"
mount "$btrfs_part" -o subvol=@ "$MOUNT_DIR"
mount "$btrfs_part" -o subvol=@home "$MOUNT_DIR"/home
mount "$btrfs_part" -o subvol=@log"$MOUNT_DIR"/var/log
mount "$btrfs_part" -o subvol=@cache "$MOUNT_DIR"/var/cache
mount "$btrfs_part" -o subvol=@tmp "$MOUNT_DIR"/tmp
# mount "$btrfs_part" -o subvol=@swap "$MOUNT_DIR"/swap
mount "$boot_part" "$MOUNT_DIR"/boot
mount "$efi_part" "$MOUNT_DIR"/boot/efi
swapon "$MOUNT_DIR"/swap/swapfile

View File

@@ -1,18 +0,0 @@
#!/bin/sh
device="/dev/nvme0n1"
efi_part="${device}p3"
boot_part="${device}p4"
btrfs_part="${device}p5"
umount /mnt -R
mount $btrfs_part -o subvol=@ /mnt
mount $btrfs_part -o subvol=@home /mnt/home
mount $btrfs_part -o subvol=@log /mnt/var/log
mount $btrfs_part -o subvol=@cache /mnt/var/cache
mount $btrfs_part -o subvol=@tmp /mnt/tmp
mount $btrfs_part -o subvol=@swap /mnt/swap
mount $boot_part /mnt/boot
mount $efi_part /mnt/boot/efi
swapon /mnt/swap/swapfile

3
.utils/set_nv_env Normal file
View File

@@ -0,0 +1,3 @@
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only

View File

@@ -1,16 +0,0 @@
#!/bin/bash
# Based on: https://gist.github.com/XVilka/8346728
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
s="/\\";
for (colnum = 0; colnum<term_cols; colnum++) {
r = 255-(colnum*255/term_cols);
g = (colnum*510/term_cols);
b = (colnum*255/term_cols);
if (g>255) g = 510-g;
printf "\033[48;2;%d;%d;%dm", r,g,b;
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
printf "%s\033[0m", substr(s,colnum%2+1,1);
}
printf "\n";
}'

4
.utils/unset_nv_env Normal file
View File

@@ -0,0 +1,4 @@
# __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia __VK_LAYER_NV_optimus=NVIDIA_only
unset __NV_PRIME_RENDER_OFFLOAD
unset __GLX_VENDOR_LIBRARY_NAME
unset __VK_LAYER_NV_optimus