diff options
| -rw-r--r-- | i3/.config/i3/config | 2 | ||||
| -rw-r--r-- | polybar/.config/polybar/modules.ini | 17 | ||||
| -rwxr-xr-x | polybar/.config/polybar/scripts/dgpu-status.sh | 14 | ||||
| -rwxr-xr-x | system/deploy-system.sh | 6 | ||||
| -rwxr-xr-x | system/usr/gpu-toggle | 1 | ||||
| -rwxr-xr-x | system/usr/polybar-gpu-trigger | 29 | ||||
| -rwxr-xr-x | system/usr/system-maintenance | 5 | ||||
| -rwxr-xr-x | system/usr/system-update | 2 |
8 files changed, 47 insertions, 29 deletions
diff --git a/i3/.config/i3/config b/i3/.config/i3/config index db04490..ff00d0f 100644 --- a/i3/.config/i3/config +++ b/i3/.config/i3/config @@ -23,7 +23,7 @@ client.focused_inactive #16161d #16161d #c0caf5 #16161d #16161d client.unfocused #16161d #16161d #c0caf5 #16161d #16161d # --- Autostart --- -exec --no-startup-id pulseaudio --start +exec --no-startup-id pipewire exec --no-startup-id /usr/bin/openrazer-daemon exec --no-startup-id brightnessctl set 40% exec --no-startup-id xss-lock -- physlock -m -d diff --git a/polybar/.config/polybar/modules.ini b/polybar/.config/polybar/modules.ini index d82a909..e8952d1 100644 --- a/polybar/.config/polybar/modules.ini +++ b/polybar/.config/polybar/modules.ini @@ -84,19 +84,14 @@ label-muted-foreground = ${colors.disabled} ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ [module/gpu-status] -type = custom/script -exec = ~/.config/polybar/scripts/dgpu-status.sh -interval = 5 +type = custom/ipc +hook-0 = ~/.config/polybar/scripts/dgpu-status.sh +initial = 1 -format-prefix = "dGPU Status: " -format-padding = 1 +format-prefix = "" format-background = ${colors.background-alt} format-foreground = ${colors.primary} -; Optional: Left-click to open a terminal and toggle -; click-left = st -e sudo gpu-switch on -; click-right = st -e sudo gpu-switch off - ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ [module/battery] @@ -113,7 +108,7 @@ format-discharging = <ramp-capacity><label-discharging> label-charging = %percentage%% label-discharging =%percentage%% label-full = Full -label-low = LOW +label-low = LOW ramp-capacity-0 = " " ramp-capacity-1 = " " @@ -139,7 +134,7 @@ animation-discharging-4 = " " animation-discharging-framerate = 500 animation-low-0 = ! -animation-low-1 = +animation-low-1 = animation-low-framerate = 200 ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ diff --git a/polybar/.config/polybar/scripts/dgpu-status.sh b/polybar/.config/polybar/scripts/dgpu-status.sh index 257c744..6a51656 100755 --- a/polybar/.config/polybar/scripts/dgpu-status.sh +++ b/polybar/.config/polybar/scripts/dgpu-status.sh @@ -1,15 +1,7 @@ #!/bin/bash -# Path to the dGPU on the PCI bus -PCI_PATH="/sys/bus/pci/devices/0000:57:00.0" - -if [ -d "$PCI_PATH" ]; then - # Optional: Check if the driver is actually loaded - if lsmod | grep -q "nvidia"; then - echo "ON" # Icon for NVIDIA/GPU Active - else - echo "STBY" # Hardware present but driver unloaded - fi +if /usr/local/bin/gpu-toggle status; then + echo " ON" else - echo "OFF" # GPU powered down and removed + echo " OFF" fi diff --git a/system/deploy-system.sh b/system/deploy-system.sh index a83415f..d8cf4b2 100755 --- a/system/deploy-system.sh +++ b/system/deploy-system.sh @@ -5,16 +5,16 @@ DOT_BIN="./usr/" DOT_ETC="./etc/" # Check for root -if [ "$EUID" -ne 0 ]; then +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/ +rsync -avh --dry-run --backup --suffix=_old --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/ +rsync -avh --dry-run --backup --suffix=_old --chmod=D755,F644 --chown=root:root "$DOT_ETC" /etc/ #echo "Reloading services..." #udevadm control --reload-rules && udevadm trigger diff --git a/system/usr/gpu-toggle b/system/usr/gpu-toggle index 35d6c47..b44022f 100755 --- a/system/usr/gpu-toggle +++ b/system/usr/gpu-toggle @@ -1,4 +1,5 @@ #!/bin/bash +# /usr/local/bin/gpu-toggle # ------------------------------------------------------------------------- # GPU-TOGGLE: Discrete Graphics Power & Bus Management diff --git a/system/usr/polybar-gpu-trigger b/system/usr/polybar-gpu-trigger new file mode 100755 index 0000000..55b52fc --- /dev/null +++ b/system/usr/polybar-gpu-trigger @@ -0,0 +1,29 @@ +#!/bin/bash
+# /usr/local/bin/polybar-gpu-trigger
+
+# 1. Critical sleep to prevent the udev timing race condition
+sleep 0.5
+
+# Find the Process ID (PID) of Polybar
+POLYBAR_PID=$(pgrep -x polybar)
+if [ -z "$POLYBAR_PID" ]; then
+ exit 0
+fi
+
+# Loop through found PIDs to locate the correct user context
+for pid in $POLYBAR_PID; do
+ if [ -f "/proc/$pid/environ" ]; then
+ USER_UID=$(stat -c "%u" "/proc/$pid")
+ USER_NAME=$(id -nu "$USER_UID")
+
+ # Safely parse the environment file for XDG_RUNTIME_DIR
+ XDG_DIR=$(tr '\0' '\n' < "/proc/$pid/environ" | grep '^XDG_RUNTIME_DIR=' | cut -d= -f2-)
+
+ if [ -n "$XDG_DIR" ]; then
+ # Drop root privileges and forcefully send the text directly into Polybar
+ sudo -u "$USER_NAME" XDG_RUNTIME_DIR="$XDG_DIR" \
+ polybar-msg action "#gpu-status.send.0" >/dev/null 2>&1
+ break
+ fi
+ fi
+done
diff --git a/system/usr/system-maintenance b/system/usr/system-maintenance index d2918c6..f7a7051 100755 --- a/system/usr/system-maintenance +++ b/system/usr/system-maintenance @@ -1,4 +1,5 @@ #!/bin/bash +# /usr/local/bin/system-maintenance # Configuration MARKER_FILE="/var/log/last_maintenance_timestamp" @@ -14,7 +15,7 @@ if [ $((CURRENT_TIME - LAST_RUN)) -ge $INTERVAL ]; then { echo "-------------------------------------------" echo "[$(date)] Starting weekly maintenance..." - + # 1. Trim SSD /usr/sbin/fstrim -v / @@ -23,7 +24,7 @@ if [ $((CURRENT_TIME - LAST_RUN)) -ge $INTERVAL ]; then # 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 index 4187e46..79b26a8 100755 --- a/system/usr/system-update +++ b/system/usr/system-update @@ -1,5 +1,5 @@ #!/bin/bash -# /usr/local/bin/sys-update +# /usr/local/bin/system-update # Formal system maintenance utility with administrative enforcement LOG_FILE="/var/log/system-update.log" |
