mirror of
https://github.com/TECHNOFAB11/tmux2k.git
synced 2025-12-11 23:50:08 +01:00
feat: enhance battery segment
This commit is contained in:
parent
416d0a1151
commit
f4c81ed798
1 changed files with 22 additions and 12 deletions
|
|
@ -97,27 +97,37 @@ battery_status() {
|
||||||
echo ''
|
echo ''
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
### Old if statements didn't work on BSD, they're probably not POSIX compliant, not sure
|
}
|
||||||
# if [ $status = 'discharging' ] || [ $status = 'Discharging' ]; then
|
|
||||||
# echo ''
|
battery_label() {
|
||||||
# # elif [ $status = 'charging' ]; then # This is needed for FreeBSD AC checking support
|
bat_perc=$1
|
||||||
# # echo 'AC'
|
|
||||||
# else
|
if [ "$bat_perc" -gt 90 ]; then
|
||||||
# echo 'AC'
|
echo " "
|
||||||
# fi
|
elif [ "$bat_perc" -gt 75 ]; then
|
||||||
|
echo " "
|
||||||
|
elif [ "$bat_perc" -gt 50 ]; then
|
||||||
|
echo " "
|
||||||
|
elif [ "$bat_perc" -gt 25 ]; then
|
||||||
|
echo " "
|
||||||
|
elif [ "$bat_perc" -gt 10 ]; then
|
||||||
|
echo " "
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
bat_label=$(get_tmux_option "@tmux2k-battery-label" "")
|
|
||||||
bat_stat=$(battery_status)
|
bat_stat=$(battery_status)
|
||||||
bat_perc=$(battery_percent)
|
bat_perc=$(battery_percent)
|
||||||
|
bat_label=$(get_tmux_option "@tmux2k-battery-label" "$(battery_label "$bat_perc")")
|
||||||
|
|
||||||
if [ -z "$bat_stat" ]; then # Test if status is empty or not
|
if [ -z "$bat_stat" ]; then # Test if status is empty or not
|
||||||
echo "$bat_label$bat_perc"
|
echo "$bat_label $bat_perc%"
|
||||||
elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
|
elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
|
||||||
echo "$bat_label $bat_stat"
|
echo "$bat_stat $bat_label"
|
||||||
else
|
else
|
||||||
echo "$bat_label $bat_stat$bat_perc"
|
echo "$bat_stat $bat_label $bat_perc%"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue