X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Flib%2Flogin_functions.sh;h=97cb68aa3551c08397eba7b0bd3f3ab8b552aa99;hb=5dfe845a1f4b3b9c1fc302fa5306d662f6d86e06;hp=c4a583ab7f0727635442ef2281f0a7d7be6bcbb1;hpb=c5f3db4310cb09059b824d2ba7c68883c174bb89;p=khome.git diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index c4a583a..97cb68a 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -431,30 +431,33 @@ flat_top_5() { motd_batt() { case "$(uname)" in 'Linux') - upower --dump \ - | awk ' - /^Device:[ \t]+/ { - device["path"] = $2 - next - } - - / battery/ && device["path"] { - device["is_battery"] = 1 - next - } - - / percentage:/ && device["is_battery"] { - device["battery_percentage"] = $2 - sub("%$", "", device["battery_percentage"]) - next - } - - /^$/ { - if (device["is_battery"] && device["path"] == "/org/freedesktop/UPower/devices/DisplayDevice") - print device["battery_percentage"], 100, "batt" - delete device - } - ' + if which upower > /dev/null + then + upower --dump \ + | awk ' + /^Device:[ \t]+/ { + device["path"] = $2 + next + } + + / battery/ && device["path"] { + device["is_battery"] = 1 + next + } + + / percentage:/ && device["is_battery"] { + device["battery_percentage"] = $2 + sub("%$", "", device["battery_percentage"]) + next + } + + /^$/ { + if (device["is_battery"] && device["path"] == "/org/freedesktop/UPower/devices/DisplayDevice") + print device["battery_percentage"], 100, "batt" + delete device + } + ' + fi ;; esac } @@ -606,6 +609,8 @@ motd() { | sort -u \ | xargs \ | column -t + + # TODO: iptables summary } ssh_invalid_attempts_from() {