Skip to content

Commit 8b84a29

Browse files
committed
fix: polybar interface-type auto-detect, remove hardcoded interface code
1 parent cc21fcc commit 8b84a29

5 files changed

Lines changed: 16 additions & 114 deletions

File tree

configs/fish/conf.d/fnm.fish

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
set FNM_PATH "$HOME/.local/share/fnm"
33
if [ -d "$FNM_PATH" ]
44
set PATH "$FNM_PATH" $PATH
5-
fnm env --use-on-cd --shell fish | source
5+
# Only initialize if fnm binary exists
6+
if command -q fnm
7+
fnm env --use-on-cd --shell fish | source
8+
end
69
end

configs/polybar/config.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ label = %percentage_used%% %used%/%total%
139139

140140
[module/network-wifi]
141141
type = internal/network
142-
; WiFi interface (auto-configured by install script)
143-
interface = wlan0
142+
; Auto-detect wireless interface (polybar 3.6+)
143+
interface-type = wireless
144144
interval = 3.0
145145

146146
; Connected state - shows signal strength icon and network name
@@ -165,8 +165,8 @@ click-right = nm-applet
165165

166166
[module/network-eth]
167167
type = internal/network
168-
; Ethernet interface (auto-configured by install script)
169-
interface = eth0
168+
; Auto-detect wired interface (polybar 3.6+)
169+
interface-type = wired
170170
interval = 3.0
171171

172172
; Connected state - shows wired icon and label

configs/xprofile

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,4 @@ if command -v dbus-update-activation-environment >/dev/null 2>&1; then
2121
dbus-update-activation-environment --systemd DISPLAY XAUTHORITY SSH_AUTH_SOCK XDG_CURRENT_DESKTOP 2>/dev/null || true
2222
fi
2323

24-
# Auto-detect network interfaces for polybar (handles USB adapters changing ports)
25-
# Each module auto-hides when disconnected, so both can be configured
26-
if [ -f "$HOME/.config/polybar/config.ini" ] && [ -w "$HOME/.config/polybar/config.ini" ]; then
27-
# Detect WiFi interface (prefer active/UP one)
28-
WIFI_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: wl" | head -1 | awk -F: '{print $2}' | tr -d ' ')
29-
if [ -n "$WIFI_IFACE" ] && echo "$WIFI_IFACE" | grep -qE '^[a-zA-Z0-9_-]+$'; then
30-
sed -i "/^\[module\/network-wifi\]/,/^\[module\// s/^interface = .*/interface = $WIFI_IFACE/" "$HOME/.config/polybar/config.ini" 2>/dev/null || true
31-
fi
32-
33-
# Detect Ethernet interface
34-
ETH_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: (enp|eth)" | head -1 | awk -F: '{print $2}' | tr -d ' ')
35-
if [ -n "$ETH_IFACE" ] && echo "$ETH_IFACE" | grep -qE '^[a-zA-Z0-9_-]+$'; then
36-
sed -i "/^\[module\/network-eth\]/,/^\[module\// s/^interface = .*/interface = $ETH_IFACE/" "$HOME/.config/polybar/config.ini" 2>/dev/null || true
37-
fi
38-
fi
24+
# Network interfaces auto-detected by polybar (interface-type = wireless/wired)

install.sh

Lines changed: 6 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ LOCK_FILE="/tmp/draphyOS-install-$UID.lock"
5656
LOG_FILE="/tmp/draphyOS-install.log"
5757

5858
# Hardware detection results (populated by configure_hardware, written by create_marker)
59-
DETECTED_WIFI_IFACE=""
60-
DETECTED_ETH_IFACE=""
6159
IS_VM_MODE="false"
6260

6361
# Failed items tracking (displayed at end of installation)
@@ -578,6 +576,7 @@ EOF
578576
rm -f /tmp/ueberzugpp.repo
579577
print_step "ueberzugpp repo added"
580578
else
579+
rm -f /tmp/ueberzugpp.repo
581580
print_warning "Failed to add ueberzugpp repo"
582581
FAILED_ITEMS+=("ueberzugpp-repo")
583582
fi
@@ -590,6 +589,7 @@ EOF
590589
rm -f /tmp/ueberzugpp.repo
591590
print_step "ueberzugpp repo added (Fedora 41 fallback)"
592591
else
592+
rm -f /tmp/ueberzugpp.repo
593593
print_warning "Failed to add ueberzugpp repo (fallback)"
594594
FAILED_ITEMS+=("ueberzugpp-repo")
595595
fi
@@ -1493,82 +1493,9 @@ configure_hardware() {
14931493
fi
14941494
fi
14951495

1496-
# Detect network interfaces (both WiFi and Ethernet)
1497-
# Polybar has separate modules for each - they auto-hide when disconnected
1498-
local WIFI_IFACE=""
1499-
local ETH_IFACE=""
1500-
1501-
# Detect WiFi interface (prefer active one from default route)
1502-
local DEFAULT_IFACE
1503-
DEFAULT_IFACE=$(ip route show default 2>/dev/null | awk '/default/ {print $5}' | head -1)
1504-
1505-
if [[ "$DEFAULT_IFACE" == wl* ]]; then
1506-
WIFI_IFACE="$DEFAULT_IFACE"
1507-
else
1508-
# Fallback: find any WiFi interface
1509-
WIFI_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: wl" | head -1 | awk -F: '{print $2}' | tr -d ' ')
1510-
fi
1511-
1512-
# Detect Ethernet interface
1513-
if [[ "$DEFAULT_IFACE" != wl* ]] && [ -n "$DEFAULT_IFACE" ]; then
1514-
ETH_IFACE="$DEFAULT_IFACE"
1515-
else
1516-
# Fallback: find any Ethernet interface
1517-
ETH_IFACE=$(ip link show 2>/dev/null | grep -E "^[0-9]+: (enp|eth)" | head -1 | awk -F: '{print $2}' | tr -d ' ')
1518-
fi
1519-
1520-
# Configure WiFi module
1521-
if [ -n "$WIFI_IFACE" ]; then
1522-
print_step "WiFi interface detected: $WIFI_IFACE"
1523-
# Update interface in network-wifi module section only (escape special chars for sed)
1524-
local wifi_escaped
1525-
wifi_escaped=$(printf '%s\n' "$WIFI_IFACE" | sed 's/[&/\]/\\&/g')
1526-
if sed -i "/^\[module\/network-wifi\]/,/^\[module\// s/^interface = .*/interface = ${wifi_escaped}/" "$polybar_config" 2>/dev/null; then
1527-
# Verify WiFi interface was set
1528-
if ! grep -q "interface = $WIFI_IFACE" "$polybar_config" 2>/dev/null; then
1529-
print_warning "WiFi interface config may not have been written correctly"
1530-
FAILED_ITEMS+=("hardware-wifi-verify")
1531-
((hw_failures++))
1532-
fi
1533-
else
1534-
print_warning "Failed to configure WiFi interface in polybar"
1535-
FAILED_ITEMS+=("hardware-wifi")
1536-
((hw_failures++))
1537-
fi
1538-
# Store for writing to marker file later (marker created in create_marker)
1539-
DETECTED_WIFI_IFACE="$WIFI_IFACE"
1540-
else
1541-
print_step "No WiFi interface detected (module will be hidden)"
1542-
fi
1543-
1544-
# Configure Ethernet module
1545-
if [ -n "$ETH_IFACE" ]; then
1546-
print_step "Ethernet interface detected: $ETH_IFACE"
1547-
# Update interface in network-eth module section only (escape special chars for sed)
1548-
local eth_escaped
1549-
eth_escaped=$(printf '%s\n' "$ETH_IFACE" | sed 's/[&/\]/\\&/g')
1550-
if sed -i "/^\[module\/network-eth\]/,/^\[module\// s/^interface = .*/interface = ${eth_escaped}/" "$polybar_config" 2>/dev/null; then
1551-
# Verify Ethernet interface was set
1552-
if ! grep -q "interface = $ETH_IFACE" "$polybar_config" 2>/dev/null; then
1553-
print_warning "Ethernet interface config may not have been written correctly"
1554-
FAILED_ITEMS+=("hardware-eth-verify")
1555-
((hw_failures++))
1556-
fi
1557-
else
1558-
print_warning "Failed to configure Ethernet interface in polybar"
1559-
FAILED_ITEMS+=("hardware-eth")
1560-
((hw_failures++))
1561-
fi
1562-
# Store for writing to marker file later (marker created in create_marker)
1563-
DETECTED_ETH_IFACE="$ETH_IFACE"
1564-
else
1565-
print_step "No Ethernet interface detected (module will be hidden)"
1566-
fi
1567-
1568-
if [ -z "$WIFI_IFACE" ] && [ -z "$ETH_IFACE" ]; then
1569-
print_warning "No network interfaces detected. Please configure polybar manually."
1570-
FAILED_ITEMS+=("hardware-no-network")
1571-
fi
1496+
# Network interfaces auto-detected by polybar (interface-type = wireless/wired)
1497+
# No manual configuration needed - polybar 3.6+ handles this automatically
1498+
print_step "Network interfaces: auto-detected by polybar"
15721499

15731500
if [ $hw_failures -gt 0 ]; then
15741501
print_warning "Hardware configured with $hw_failures issue(s)"
@@ -3005,13 +2932,7 @@ create_marker() {
30052932
print_step "Detected: Fedora ${variant_id:-unknown}"
30062933
fi
30072934

3008-
# Write hardware detection results (populated by configure_hardware and configure_vm)
3009-
if [ -n "$DETECTED_WIFI_IFACE" ]; then
3010-
echo "WIFI_IFACE=$DETECTED_WIFI_IFACE" >> "$MARKER_FILE"
3011-
fi
3012-
if [ -n "$DETECTED_ETH_IFACE" ]; then
3013-
echo "ETH_IFACE=$DETECTED_ETH_IFACE" >> "$MARKER_FILE"
3014-
fi
2935+
# Write hardware detection results (populated by configure_vm)
30152936
if [ "$IS_VM_MODE" = "true" ]; then
30162937
echo "VM_MODE=true" >> "$MARKER_FILE"
30172938
fi

uninstall.sh

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,15 +1022,7 @@ main() {
10221022
if [ -f "$MARKER_FILE" ] && grep -q "VM_MODE=true" "$MARKER_FILE" 2>/dev/null; then
10231023
echo " - VM-optimized picom settings"
10241024
fi
1025-
# Check for network interface configuration
1026-
if [ -f "$MARKER_FILE" ]; then
1027-
local wifi_iface eth_iface
1028-
wifi_iface=$(grep "WIFI_IFACE=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2)
1029-
eth_iface=$(grep "ETH_IFACE=" "$MARKER_FILE" 2>/dev/null | cut -d= -f2)
1030-
if [ -n "$wifi_iface" ] || [ -n "$eth_iface" ]; then
1031-
echo " - Network config: ${wifi_iface:+WiFi: $wifi_iface} ${eth_iface:+Eth: $eth_iface}"
1032-
fi
1033-
fi
1025+
# Network interfaces auto-detected by polybar (no config to remove)
10341026
echo ""
10351027
echo "You will be asked about:"
10361028
echo " - fnm (Node.js version manager)"

0 commit comments

Comments
 (0)