mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-05-11 05:55:37 +00:00
Merge pull request #209 from DaarkMoon/master
Correction for grep regex when upower is used
This commit is contained in:
@ -3,10 +3,14 @@
|
||||
# Bug: https://github.com/ohmybash/oh-my-bash/issues/68
|
||||
if ! command -v "command_exists" >/dev/null; then command_exists() { command -v "$1" >/dev/null ; } fi
|
||||
|
||||
_omb_plugin_battery__upower_print_info() {
|
||||
upower -i "$(upower -e | sed -n '/BAT/{p;q;}')"
|
||||
}
|
||||
|
||||
ac_adapter_connected(){
|
||||
if command_exists upower;
|
||||
then
|
||||
upower -i $(upower -e | grep BAT) | grep 'state' | grep -q 'charging\|fully-charged'
|
||||
_omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*(charging|fully-charged)'
|
||||
return $?
|
||||
elif command_exists acpi;
|
||||
then
|
||||
@ -30,7 +34,7 @@ ac_adapter_connected(){
|
||||
ac_adapter_disconnected(){
|
||||
if command_exists upower;
|
||||
then
|
||||
upower -i $(upower -e | grep BAT) | grep 'state' | grep -q 'discharging'
|
||||
_omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*discharging'
|
||||
return $?
|
||||
elif command_exists acpi;
|
||||
then
|
||||
@ -57,7 +61,7 @@ battery_percentage(){
|
||||
|
||||
if command_exists upower;
|
||||
then
|
||||
local UPOWER_OUTPUT=$(upower --show-info $(upower --enumerate | grep BAT) | grep percentage | tail --bytes 5)
|
||||
local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p')
|
||||
echo ${UPOWER_OUTPUT: : -1}
|
||||
elif command_exists acpi;
|
||||
then
|
||||
|
Reference in New Issue
Block a user