mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 13:32:53 -05:00
Added catch for battery level for devices without a battery
This commit is contained in:
parent
87fea9d2f0
commit
1e0e9e37d4
1 changed files with 7 additions and 5 deletions
12
welcome.sh
12
welcome.sh
|
@ -58,12 +58,14 @@ battery () {
|
||||||
batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
|
batlvl=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]]; then
|
elif [[ -a "/sys/class/power_supply/BAT1/capacity" ]]; then
|
||||||
batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
|
batlvl=$(cat /sys/class/power_supply/BAT1/capacity)
|
||||||
|
else
|
||||||
|
batlvl=-1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change color depending on level
|
# Change color depending on level
|
||||||
if [ $batlvl -ge 100 ]; then
|
if [ $batlvl -ge 100 ]; then
|
||||||
echo -en "The battery is ${FULL}fully charged${NCOL}. "
|
echo -en "The battery is ${FULL}fully charged${NCOL}. "
|
||||||
else
|
elif [ $batlvl -gt 0 ]; then
|
||||||
echo -en "The battery level is "
|
echo -en "The battery level is "
|
||||||
if [ $batlvl -le 15 ]; then
|
if [ $batlvl -le 15 ]; then
|
||||||
echo -en "${CRIT}$batlvl%${NCOL}. "
|
echo -en "${CRIT}$batlvl%${NCOL}. "
|
||||||
|
@ -86,7 +88,7 @@ updates () {
|
||||||
fedora=0
|
fedora=0
|
||||||
flatpak=0
|
flatpak=0
|
||||||
|
|
||||||
# Check for updates from different places...
|
# Check for updates from different places... wonder if there's a better way
|
||||||
|
|
||||||
# Check for APT
|
# Check for APT
|
||||||
if command -v apt &> /dev/null; then
|
if command -v apt &> /dev/null; then
|
||||||
|
@ -132,9 +134,9 @@ updates () {
|
||||||
|
|
||||||
#=====Random Color=====#
|
#=====Random Color=====#
|
||||||
randcolor() {
|
randcolor() {
|
||||||
# For random colors; this will only generate colors with sufficient
|
# For random colors; this will only generate colors with sufficient #
|
||||||
# perceptual luma to be readable on a dark background... you may have
|
# perceptual luma to be readable on a dark background... you may have #
|
||||||
# to modify it for light
|
# to modify it for a light one #
|
||||||
cluma=0
|
cluma=0
|
||||||
loops=0
|
loops=0
|
||||||
while [[ $(printf %.0f $cluma) -le 100 ]] && [[ $loops -le 10 ]];
|
while [[ $(printf %.0f $cluma) -le 100 ]] && [[ $loops -le 10 ]];
|
||||||
|
|
Loading…
Reference in a new issue