From b4d43e1d4d390ad4f429a02edd90927070a35050 Mon Sep 17 00:00:00 2001 From: Spacedio Date: Tue, 21 Apr 2026 18:59:39 -0400 Subject: Cleanup of Polybar files. --- dgpu-toggle/usr/bin/gpu-toggle | 87 --------- dgpu-toggle/usr/local/bin/gpu-toggle | 87 +++++++++ polybar/.config/polybar/config.ini | 209 ++------------------- polybar/.config/polybar/modules.ini | 186 ++++++++++++++++++ polybar/.config/polybar/scripts/battery-time.sh | 11 ++ polybar/.config/polybar/scripts/battery-wattage.sh | 19 ++ 6 files changed, 318 insertions(+), 281 deletions(-) delete mode 100755 dgpu-toggle/usr/bin/gpu-toggle create mode 100755 dgpu-toggle/usr/local/bin/gpu-toggle create mode 100644 polybar/.config/polybar/modules.ini create mode 100755 polybar/.config/polybar/scripts/battery-time.sh create mode 100755 polybar/.config/polybar/scripts/battery-wattage.sh diff --git a/dgpu-toggle/usr/bin/gpu-toggle b/dgpu-toggle/usr/bin/gpu-toggle deleted file mode 100755 index 4e1ddd2..0000000 --- a/dgpu-toggle/usr/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/dgpu-toggle/usr/local/bin/gpu-toggle b/dgpu-toggle/usr/local/bin/gpu-toggle new file mode 100755 index 0000000..4e1ddd2 --- /dev/null +++ b/dgpu-toggle/usr/local/bin/gpu-toggle @@ -0,0 +1,87 @@ +#!/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/polybar/.config/polybar/config.ini b/polybar/.config/polybar/config.ini index 09656ec..686c5a9 100644 --- a/polybar/.config/polybar/config.ini +++ b/polybar/.config/polybar/config.ini @@ -8,30 +8,26 @@ ; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ ; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ; -; by husseinhareb :) -; ;========================================================== -include-file = $HOME/.config/polybar/colors.ini +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ + +;; File Inclusion +; include an external file, like module file, etc. +include-file = ~/.config/polybar/colors.ini +include-file = ~/.config/polybar/modules.ini -;[colors] -;background = #1E1E2E -;background-alt = #1E1E2E -;foreground = #C5C8C6 -;primary = #F0C674 -;secondary = #8ABEB7 -;alert = #A54242 -;disabled = #707880 -;white = #EAEAEA -;grey = #61616C -;green = #25D865 -;blue = #168ECA -;mauve = #490761 +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ [settings] -screenchange-reload = true -pseudo-transparency = true +throttle-output = 5 +throttle-output-for = 10 + +screenchange-reload = false +pseudo-transparency = false + +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ [bar/main] #dpi = ${xrdb:Xft.dpi:96} @@ -59,7 +55,7 @@ module-margin = 0 ;border-bottom-size = 1 -;border-bottom-color = ${colors.background2} +;border-bottom-color = ${colors.magenta} ;padding-left = 1 ;padding-right = 1 @@ -68,178 +64,3 @@ module-margin = 0 modules-left = void space space date space space xwindow modules-center = xworkspaces modules-right = cpu space space memory space separator space mic space pulseaudio space separator space wlan space separator space battery space - -;modules-right = pulseaudio cpu memory wlan battery date - -[module/xworkspaces] -type = internal/xworkspaces - -label-active =  -label-active-padding = 1 -label-active-foreground = ${colors.disabled} -label-active-font = 1 - -label-occupied =  -label-occupied-padding = 1 -label-occupied-font = 1 - -label-empty =  -label-empty-background = ${colors.background} -label-empty-padding = 1 -label-empty-font = 1 - -[module/xwindow] -type = internal/xwindow -label = %title:0:60:...% -label-foreground = ${colors.white} - -[network-base] -type = internal/network -interval = 5 -format-connected = -format-disconnected = -label-disconnected = %{F#F0C674}%ifname%%{F#707880} disconnected - -[module/cpu] -type = internal/cpu -interval = 2 -format-prefix = "CPU " -format-prefix-foreground = ${colors.primary} -label = %percentage:2%% - -[module/wlan] -inherit = network-base -interface-type = wireless -label-connected = %{F#F0C674}%ifname%%{F-} %essid% %local_ip% - -[module/memory] -type = internal/memory -interval = 2 -;format-prefix = " " -format-prefix-foreground = ${colors.magenta} -label = %gb_used% %percentage_used%% -label-foreground = ${colors.foreground} - -[module/gpu-status] -type = custom/script - -; Path to the helper script we just created -exec = ~/.config/polybar/scripts/dgpu-status.sh - -; Update interval in seconds -interval = 5 - -; Professional styling -format-prefix = "dGPU Status: " -format-padding = 1 -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/wlan] -;inherit = network-base -;interface-type = wireless - -;interval = 1 -;format-connected-prefix-foreground = ${colors.white} -;format-connected-foreground = ${colors.white} -;format-connected = -;label-connected = 󰖩 -;label-connected-padding = 0 - -;format-disconnected = -;format-disconnected-padding = 0 -;label-disconnected = 󰖪 -;label-disconnected-foreground = ${colors.white} -;label-disconnected-padding = 0 - -[module/mic] -type = custom/script -exec = ~/.config/polybar/scripts/mic-status.sh -tail = true -; Click to toggle mute -click-left = pactl set-source-mute @DEFAULT_SOURCE@ toggle -; Scroll up to increase volume -scroll-up = pactl set-source-volume @DEFAULT_SOURCE@ +5% -; Scroll down to decrease volume -scroll-down = pactl set-source-volume @DEFAULT_SOURCE@ -5% - -[module/pulseaudio] -type = internal/pulseaudio - -format-volume-prefix = "󰕾 " -format-volume-foreground = ${colors.foreground} -format-volume-prefix-foreground = ${colors.foreground} -format-volume = -label-volume = %percentage%% - -label-muted = 󰖁 %percentage%% -label-muted-foreground = ${colors.disabled} - -[module/battery] -type = internal/battery -full-at = 99 -low-at = 20 -battery = BAT0 -adapter = ADP1 -poll-interval = 5 -format-charging-foreground = ${colors.foreground} -format-discharging-foreground = ${colors.foreground} -format-charging = -format-discharging = -label-charging = %percentage%% -label-discharging =%percentage%% -label-full = Full -label-low = LOW - -ramp-capacity-0 = " " -ramp-capacity-1 = " " -ramp-capacity-2 = " " -ramp-capacity-3 = " " -ramp-capacity-4 = " " - -bar-capacity-width = 10 - -animation-charging-0 = " " -animation-charging-1 = " " -animation-charging-2 = " " -animation-charging-3 = " " -animation-charging-4 = " " -animation-charging-framerate = 750 - -animation-discharging-0 = " " -animation-discharging-1 = " " -animation-discharging-2 = " " -animation-discharging-3 = " " -animation-discharging-4 = " " - -animation-discharging-framerate = 500 - -animation-low-0 = ! -animation-low-1 = -animation-low-framerate = 200 - -[module/date] -type = internal/date -interval = 1 -date = %I:%M %p|%d-%m -label = %date% -label-foreground = ${colors.primary} - -[module/void] -type = custom/text -content =  -content-foreground = ${colors.green} -content-margin = 0 - -[module/space] -type = custom/text -content = " " - -[module/separator] -type = custom/text -content = "|" -content-foreground = ${colors.disabled} diff --git a/polybar/.config/polybar/modules.ini b/polybar/.config/polybar/modules.ini new file mode 100644 index 0000000..d82a909 --- /dev/null +++ b/polybar/.config/polybar/modules.ini @@ -0,0 +1,186 @@ +[module/xworkspaces] +type = internal/xworkspaces + +label-active =  +label-active-padding = 1 +label-active-foreground = ${colors.disabled} +label-active-font = 1 + +label-occupied =  +label-occupied-padding = 1 +label-occupied-font = 1 + +label-empty =  +label-empty-background = ${colors.background} +label-empty-padding = 1 +label-empty-font = 1 + +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ + +[module/xwindow] +type = internal/xwindow +label = %title:0:60:...% +label-foreground = ${colors.white} + +;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ + +[module/cpu] +type = internal/cpu +interval = 2 +format =