diff options
author | Joursoir <chat@joursoir.net> | 2023-11-14 19:37:00 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2023-11-16 12:34:57 +0300 |
commit | 62ea5555e7f3fa53b1cb31fe881c888fc4a27828 (patch) | |
tree | 7ad6e5cb1beb93f6c85a1c7671597eb9a9b94759 /dotconfig/polybar | |
parent | c23573c831a3504aed83cbf2e904cbd357380fbd (diff) | |
download | dotfiles-62ea5555e7f3fa53b1cb31fe881c888fc4a27828.tar.gz dotfiles-62ea5555e7f3fa53b1cb31fe881c888fc4a27828.tar.bz2 dotfiles-62ea5555e7f3fa53b1cb31fe881c888fc4a27828.zip |
ditconfig/polybar: use dynamic network interface detection
As result, provide name of the network interface to polybar instead of
interface type.
Diffstat (limited to 'dotconfig/polybar')
-rwxr-xr-x | dotconfig/polybar/launch.sh | 4 | ||||
-rw-r--r-- | dotconfig/polybar/modules | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/dotconfig/polybar/launch.sh b/dotconfig/polybar/launch.sh index f607575..6a70ea0 100755 --- a/dotconfig/polybar/launch.sh +++ b/dotconfig/polybar/launch.sh @@ -7,11 +7,11 @@ killall -9 polybar while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done # Set variables -NETWORK_TYPE="wired" # or `wireless` +NETWORK_INTERFACE=$(ip route | grep '^default' | awk '{print $5}' | head -n1) # Launch the bar echo "---" | tee -a /tmp/mypolybar.log for m in $(polybar --list-monitors | cut -d":" -f1); do - MONITOR=$m NETWORK_TYPE=$NETWORK_TYPE polybar main >> /tmp/mypolybar.log 2>&1 & disown + MONITOR=$m NETWORK_INTERFACE=$NETWORK_INTERFACE polybar main >> /tmp/mypolybar.log 2>&1 & disown done echo "Bar launched..." diff --git a/dotconfig/polybar/modules b/dotconfig/polybar/modules index 049e5f3..2cb39a3 100644 --- a/dotconfig/polybar/modules +++ b/dotconfig/polybar/modules @@ -237,12 +237,17 @@ [module/network] type = internal/network + ; Name of the network interface to display. You can get the names of the + ; interfaces on your machine with `ip link` + ; Wireless interfaces often start with `wl` and ethernet interface with `eno` or `eth` + interface = ${env:NETWORK_INTERFACE:eno1} + ; If no interface is specified, polybar can detect an interface of the given type. ; If multiple are found, it will prefer running interfaces and otherwise just ; use the first one found. ; Either 'wired' or 'wireless' ; New in version 3.6.0 - interface-type = ${env:NETWORK_TYPE:wired} + ; interface-type = ${env:NETWORK_TYPE:wired} ; Seconds to sleep between updates interval = 1.0 |