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

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/env bash
## Collect data
cache_dir="$HOME/.cache/eww/weather"

View File

@@ -12,6 +12,10 @@ if [ "$LOGNAME" != "$USER" ]; then
exit 1
fi
if [ "$(ps -o comm= -p $(ps -o ppid= -p $$) 2>/dev/null)" = "su" ]; then
exit 1
ppid=$(ps -o ppid= -p $$ 2>/dev/null)
if [ -n "$ppid" ]; then
parent_comm=$(ps -o comm= -p "$ppid" 2>/dev/null)
if [ "$parent_comm" = "su" ]; then
exit 1
fi
fi

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/env bash
# get highest workspace ID
max_id=$(hyprctl workspaces | grep '^workspace ID ' | awk '{print $3}' | sort -n | tail -1)

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

2
.scripts/set_nv_env.sh → .utils/set_nv_env Executable file → Normal file
View File

@@ -1,5 +1,3 @@
#!/bin/sh
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only

2
.scripts/unset_nv_env.sh → .utils/unset_nv_env Executable file → Normal file
View File

@@ -1,5 +1,3 @@
#!/bin/sh
# __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