i3status: Use default route for ethernet address first.

This commit is contained in:
David Tomaschik
2019-06-07 16:15:46 -07:00
parent e325cc3b93
commit 4d2d8c89f6

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
function general { function general {
cat <<-EOF cat <<-EOF
general { general {
colors = true colors = true
interval = 5 interval = 5
@@ -45,6 +45,17 @@ function wireless {
} }
function wired { function wired {
local def_iface="$(ip route get 1.1.1.1 2>&1 | grep -oP 'dev \K\S+')"
if test -n "${def_iface}" ; then
cat <<-EOF
ethernet "${def_iface}" {
format_up = "E: %ip"
format_down = "E: down"
}
order += "ethernet ${def_iface}"
EOF
return 0
fi
cat <<-EOF cat <<-EOF
ethernet _first_ { ethernet _first_ {
format_up = "E: %ip" format_up = "E: %ip"
@@ -107,7 +118,7 @@ function battery {
} }
function audio { function audio {
cat <<-EOF cat <<-EOF
volume master { volume master {
format = "♪: %volume" format = "♪: %volume"
format_muted = "♪: MUTE" format_muted = "♪: MUTE"