From 7999b9ad79a5aba6b12be73a938c823fc5b329e8 Mon Sep 17 00:00:00 2001 From: Spacedio Date: Sun, 24 May 2026 21:07:04 -0400 Subject: Reorganization of files. --- bash/.bashrc | 2 +- dgpu-toggle/usr/local/bin/gpu-toggle | 87 ------------------------ nvidia-pm/etc/X11/xorg.conf.dir/10-igpu.conf | 8 --- nvidia-pm/etc/X11/xorg.conf.dir/30-touchpad.conf | 9 --- nvidia-pm/etc/udev/rules.d/80-nvidia-pm.rules | 5 -- system/deploy-system.sh | 21 ++++++ system/etc/X11/xorg.conf.d/10-igpu.conf | 8 +++ system/etc/X11/xorg.conf.d/30-touchpad.conf | 9 +++ system/etc/udev/rules.d/80-nvidia-pm.rules | 5 ++ system/usr/gpu-toggle | 87 ++++++++++++++++++++++++ system/usr/system-maintenance | 29 ++++++++ system/usr/system-update | 36 ++++++++++ 12 files changed, 196 insertions(+), 110 deletions(-) delete mode 100755 dgpu-toggle/usr/local/bin/gpu-toggle delete mode 100644 nvidia-pm/etc/X11/xorg.conf.dir/10-igpu.conf delete mode 100644 nvidia-pm/etc/X11/xorg.conf.dir/30-touchpad.conf delete mode 100644 nvidia-pm/etc/udev/rules.d/80-nvidia-pm.rules create mode 100755 system/deploy-system.sh create mode 100644 system/etc/X11/xorg.conf.d/10-igpu.conf create mode 100644 system/etc/X11/xorg.conf.d/30-touchpad.conf create mode 100644 system/etc/udev/rules.d/80-nvidia-pm.rules create mode 100755 system/usr/gpu-toggle create mode 100755 system/usr/system-maintenance create mode 100755 system/usr/system-update diff --git a/bash/.bashrc b/bash/.bashrc index 12ab075..c60ac13 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -6,7 +6,7 @@ #ALIASES alias ls='ls --color=auto' alias l='ls -lahF' -alias code='code-oss' +alias code='zed' alias xi='sudo xbps-install' alias xr='sudo xbps-remove' alias ..='cd ..' diff --git a/dgpu-toggle/usr/local/bin/gpu-toggle b/dgpu-toggle/usr/local/bin/gpu-toggle deleted file mode 100755 index 4e1ddd2..0000000 --- a/dgpu-toggle/usr/local/bin/gpu-toggle +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -# ------------------------------------------------------------------------- -# GPU-SWITCH: Discrete Graphics Power & Bus Management -# Target: Razer Blade Stealth 13 (Late 2019) | Void Linux -# ------------------------------------------------------------------------- - -# Configuration: Static PCI Identifier for Turing dGPU -# We use a static ID because the device disappears from the bus when disabled. -DEVICE_ID="57:00.0" -PCI_PATH="/sys/bus/pci/devices/0000:$DEVICE_ID" -REQUIRED_MODULES=("nvidia_drm" "nvidia_modeset" "nvidia_uvm" "nvidia") - -if [[ $EUID -ne 0 ]]; then - echo "[ERROR] Elevated privileges required. Please execute with sudo." - exit 1 -fi - -check_status() { - echo "--- System Graphics Status ---" - if [ -d "$PCI_PATH" ]; then - echo "Hardware State: [ ONLINE ] at $DEVICE_ID" - if lsmod | grep -q "nvidia"; then - echo "Driver State: [ LOADED ]" - else - echo "Driver State: [ UNLOADED ]" - fi - else - echo "Hardware State: [ OFFLINE ] (Device removed from PCI bus)" - echo "Driver State: [ UNLOADED ]" - fi - echo "------------------------------" -} - -disable_gpu() { - echo "[INFO] Initializing dGPU shutdown sequence..." - - # 1. Unload Kernel Modules - echo "[STEP 1/2] Terminating NVIDIA kernel modules..." - for mod in "${REQUIRED_MODULES[@]}"; do - if lsmod | grep -q "$mod"; then - modprobe -r "$mod" 2>/dev/null - if [ $? -ne 0 ]; then - echo "[WARN] Module $mod is currently in use. Ensure Xorg/i3 is not using the dGPU." - fi - fi - done - - # 2. Physical Bus Removal - if [ -d "$PCI_PATH" ]; then - echo "[STEP 2/2] Detaching device from PCI bus..." - echo 1 > "$PCI_PATH/remove" - echo "[SUCCESS] dGPU has been isolated and powered down." - else - echo "[SKIP] Device is already detached from the bus." - fi -} - -enable_gpu() { - echo "[INFO] Initializing dGPU activation sequence..." - - # 1. Trigger PCI Rescan - echo "[STEP 1/2] Scanning PCI bridge for hardware changes..." - echo 1 > /sys/bus/pci/rescan - - # Allow firmware-level handshake - sleep 2 - - # 2. Validate and Load Drivers - if [ -d "$PCI_PATH" ]; then - echo "[STEP 2/2] Hardware detected at $DEVICE_ID. Loading modules..." - for mod in "nvidia" "nvidia_uvm" "nvidia_modeset" "nvidia_drm"; do - modprobe "$mod" - done - echo "[SUCCESS] dGPU is now online and available for Prime Offload." - else - echo "[FATAL] Hardware failed to initialize at $DEVICE_ID." - echo "[DEBUG] Check 'dmesg | tail' for PCI link training errors." - fi -} - -case "$1" in - on) enable_gpu ;; - off) disable_gpu ;; - status) check_status ;; - *) echo "Usage: gpu-switch {on|off|status}" ;; -esac diff --git a/nvidia-pm/etc/X11/xorg.conf.dir/10-igpu.conf b/nvidia-pm/etc/X11/xorg.conf.dir/10-igpu.conf deleted file mode 100644 index 49a4151..0000000 --- a/nvidia-pm/etc/X11/xorg.conf.dir/10-igpu.conf +++ /dev/null @@ -1,8 +0,0 @@ -Section "ServerFlags" - Option "AutoAddGPU" "off" -EndSection - -Section "Device" - Identifier "iGPU" - Driver "modesetting" -EndSection diff --git a/nvidia-pm/etc/X11/xorg.conf.dir/30-touchpad.conf b/nvidia-pm/etc/X11/xorg.conf.dir/30-touchpad.conf deleted file mode 100644 index f958e88..0000000 --- a/nvidia-pm/etc/X11/xorg.conf.dir/30-touchpad.conf +++ /dev/null @@ -1,9 +0,0 @@ -Section "InputClass" - Identifier "touchpad" - Driver "libinput" - MatchIsTouchpad "on" - Option "Tapping" "on" - Option "NaturalScrolling" "on" - Option "ClickMethod" "clickfinger" - Option "AccelSpeed" "0.4" -EndSection diff --git a/nvidia-pm/etc/udev/rules.d/80-nvidia-pm.rules b/nvidia-pm/etc/udev/rules.d/80-nvidia-pm.rules deleted file mode 100644 index 05cf9d7..0000000 --- a/nvidia-pm/etc/udev/rules.d/80-nvidia-pm.rules +++ /dev/null @@ -1,5 +0,0 @@ -# Enable runtime PM for NVIDIA VGA/3D controller devices -ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", ATTR{power/control}="auto" -ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", ATTR{power/control}="auto" -# Enable runtime PM for NVIDIA Audio devices -ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto" diff --git a/system/deploy-system.sh b/system/deploy-system.sh new file mode 100755 index 0000000..a83415f --- /dev/null +++ b/system/deploy-system.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Define paths (Relative to script location) +DOT_BIN="./usr/" +DOT_ETC="./etc/" + +# Check for root +if [ "$EUID" -ne 0 ]; then + echo "Please run as root (sudo ./deploy.sh)" + exit +fi + +echo "Deploying system scripts..." +rsync -avh --dry-run --chmod=D755,F755 --chown=root:root "$DOT_BIN" /usr/local/bin/ + +echo "Deploying etc configs..." +rsync -avh --dry-run --chmod=D755,F644 --chown=root:root "$DOT_ETC" /etc/ + +#echo "Reloading services..." +#udevadm control --reload-rules && udevadm trigger +# Add other reloads here as needed diff --git a/system/etc/X11/xorg.conf.d/10-igpu.conf b/system/etc/X11/xorg.conf.d/10-igpu.conf new file mode 100644 index 0000000..49a4151 --- /dev/null +++ b/system/etc/X11/xorg.conf.d/10-igpu.conf @@ -0,0 +1,8 @@ +Section "ServerFlags" + Option "AutoAddGPU" "off" +EndSection + +Section "Device" + Identifier "iGPU" + Driver "modesetting" +EndSection diff --git a/system/etc/X11/xorg.conf.d/30-touchpad.conf b/system/etc/X11/xorg.conf.d/30-touchpad.conf new file mode 100644 index 0000000..f958e88 --- /dev/null +++ b/system/etc/X11/xorg.conf.d/30-touchpad.conf @@ -0,0 +1,9 @@ +Section "InputClass" + Identifier "touchpad" + Driver "libinput" + MatchIsTouchpad "on" + Option "Tapping" "on" + Option "NaturalScrolling" "on" + Option "ClickMethod" "clickfinger" + Option "AccelSpeed" "0.4" +EndSection diff --git a/system/etc/udev/rules.d/80-nvidia-pm.rules b/system/etc/udev/rules.d/80-nvidia-pm.rules new file mode 100644 index 0000000..05cf9d7 --- /dev/null +++ b/system/etc/udev/rules.d/80-nvidia-pm.rules @@ -0,0 +1,5 @@ +# Enable runtime PM for NVIDIA VGA/3D controller devices +ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", ATTR{power/control}="auto" +ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", ATTR{power/control}="auto" +# Enable runtime PM for NVIDIA Audio devices +ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto" diff --git a/system/usr/gpu-toggle b/system/usr/gpu-toggle new file mode 100755 index 0000000..4325829 --- /dev/null +++ b/system/usr/gpu-toggle @@ -0,0 +1,87 @@ +#!/bin/bash + +# ------------------------------------------------------------------------- +# GPU-TOGGLE: Discrete Graphics Power & Bus Management +# Target: Razer Blade Stealth 13 (Late 2019) | Void Linux +# ------------------------------------------------------------------------- + +# Configuration: Static PCI Identifier for Turing dGPU +# We use a static ID because the device disappears from the bus when disabled. +DEVICE_ID="57:00.0" +PCI_PATH="/sys/bus/pci/devices/0000:$DEVICE_ID" +REQUIRED_MODULES=("nvidia_drm" "nvidia_modeset" "nvidia_uvm" "nvidia") + +if [[ $EUID -ne 0 ]]; then + echo "[ERROR] Elevated privileges required. Please execute with sudo." + exit 1 +fi + +check_status() { + echo "--- System Graphics Status ---" + if [ -d "$PCI_PATH" ]; then + echo "Hardware State: [ ONLINE ] at $DEVICE_ID" + if lsmod | grep -q "nvidia"; then + echo "Driver State: [ LOADED ]" + else + echo "Driver State: [ UNLOADED ]" + fi + else + echo "Hardware State: [ OFFLINE ] (Device removed from PCI bus)" + echo "Driver State: [ UNLOADED ]" + fi + echo "------------------------------" +} + +disable_gpu() { + echo "[INFO] Initializing dGPU shutdown sequence..." + + # 1. Unload Kernel Modules + echo "[STEP 1/2] Terminating NVIDIA kernel modules..." + for mod in "${REQUIRED_MODULES[@]}"; do + if lsmod | grep -q "$mod"; then + modprobe -r "$mod" 2>/dev/null + if [ $? -ne 0 ]; then + echo "[WARN] Module $mod is currently in use. Ensure Xorg/i3 is not using the dGPU." + fi + fi + done + + # 2. Physical Bus Removal + if [ -d "$PCI_PATH" ]; then + echo "[STEP 2/2] Detaching device from PCI bus..." + echo 1 > "$PCI_PATH/remove" + echo "[SUCCESS] dGPU has been isolated and powered down." + else + echo "[SKIP] Device is already detached from the bus." + fi +} + +enable_gpu() { + echo "[INFO] Initializing dGPU activation sequence..." + + # 1. Trigger PCI Rescan + echo "[STEP 1/2] Scanning PCI bridge for hardware changes..." + echo 1 > /sys/bus/pci/rescan + + # Allow firmware-level handshake + sleep 2 + + # 2. Validate and Load Drivers + if [ -d "$PCI_PATH" ]; then + echo "[STEP 2/2] Hardware detected at $DEVICE_ID. Loading modules..." + for mod in "nvidia" "nvidia_uvm" "nvidia_modeset" "nvidia_drm"; do + modprobe "$mod" + done + echo "[SUCCESS] dGPU is now online and available for Prime Offload." + else + echo "[FATAL] Hardware failed to initialize at $DEVICE_ID." + echo "[DEBUG] Check 'dmesg | tail' for PCI link training errors." + fi +} + +case "$1" in + on) enable_gpu ;; + off) disable_gpu ;; + status) check_status ;; + *) echo "Usage: gpu-toggle {on|off|status}" ;; +esac diff --git a/system/usr/system-maintenance b/system/usr/system-maintenance new file mode 100755 index 0000000..d2918c6 --- /dev/null +++ b/system/usr/system-maintenance @@ -0,0 +1,29 @@ +#!/bin/bash + +# Configuration +MARKER_FILE="/var/log/last_maintenance_timestamp" +LOG_OUT="/var/log/maintenance.log" +# 604800 seconds = 7 days +INTERVAL=604800 + +# Get last run time or 0 if file doesn't exist +LAST_RUN=$(stat -c %Y "$MARKER_FILE" 2>/dev/null || echo 0) +CURRENT_TIME=$(date +%s) + +if [ $((CURRENT_TIME - LAST_RUN)) -ge $INTERVAL ]; then + { + echo "-------------------------------------------" + echo "[$(date)] Starting weekly maintenance..." + + # 1. Trim SSD + /usr/sbin/fstrim -v / + + # 2. Run Backup (Example) + # /usr/local/bin/backup.sh 2>&1 + + # Update timestamp marker + touch "$MARKER_FILE" + + echo "[$(date)] Maintenance complete." + } >> "$LOG_OUT" 2>&1 +fi diff --git a/system/usr/system-update b/system/usr/system-update new file mode 100755 index 0000000..4187e46 --- /dev/null +++ b/system/usr/system-update @@ -0,0 +1,36 @@ +#!/bin/bash +# /usr/local/bin/sys-update +# Formal system maintenance utility with administrative enforcement + +LOG_FILE="/var/log/system-update.log" + +# Administrative Privileges Check +if [ "$EUID" -ne 0 ]; then + printf ":: [ERROR] This utility requires administrative privileges. Please execute with 'sudo'.\n" >&2 + exit 1 +fi + +set -e + +log_message() { + printf "[$(date +'%Y-%m-%d %H:%M:%S')] %s\n" "$1" >> "$LOG_FILE" +} + +log_message "START: Commencing system maintenance cycle." +printf ":: Initializing hardware state: Activating discrete GPU...\n" +gpu-toggle on + +printf ":: Synchronizing package repositories and performing system upgrade...\n" +xbps-install -Su + +printf ":: Commencing filesystem optimization and orphan removal...\n" +xbps-remove -Oo + +printf ":: Executing kernel image purge for obsolete versions...\n" +vkpurge rm all + +printf ":: Restoring power-efficient state: Deactivating discrete GPU...\n" +gpu-toggle off + +log_message "FINISH: Maintenance cycle completed successfully." +printf ":: [SUCCESS] Operation logged to %s\n" "$LOG_FILE" -- cgit v1.2.3