Browse Source

x230: add battery check for flashing scripts

pull/36/head
Martin Kepplinger 5 years ago
parent
commit
35a0d6cdbf
2 changed files with 54 additions and 0 deletions
  1. +27
    -0
      x230/x230_heads.sh
  2. +27
    -0
      x230/x230_skulls.sh

+ 27
- 0
x230/x230_heads.sh View File

@ -22,6 +22,32 @@ usage()
echo "Usage: $0 -i <heads_image>.rom"
}
check_battery() {
local capacity=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null || echo -ne "0")
local online=$(cat /sys/class/power_supply/AC/online 2>/dev/null || cat /sys/class/power_supply/ADP*/online 2>/dev/null || echo -ne "0")
local failed=0
if [ "${online}" == "0" ] ; then
failed=1
fi
if [ "${capacity}" -lt 25 ]; then
failed=1
fi
if [ $failed == "1" ]; then
echo -e "${YELLOW}WARNING:${NC} To prevent shutdowns, we recommend to only run this script when"
echo " your laptop is plugged in to the power supply AND"
echo " the battery is present and sufficiently charged (over 25%)."
while true; do
read -r -p "Continue anyways? (please do NOT!) y/N: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) exit;;
esac
done
fi
}
args=$(getopt -o i:h -- "$@")
if [ $? -ne 0 ] ; then
usage
@ -108,6 +134,7 @@ echo "0x00500000:0x00bfffff bios" >> ${OUTPUT_PATH}/${LAYOUT_FILENAME}
echo -e "${YELLOW}WARNING${NC}: Make sure not to power off your computer or interrupt this process in any way!"
echo -e " Interrupting this process may result in irreparable damage to your computer!"
check_battery
while true; do
read -r -p "Flash the BIOS now? y/N: " yn
case $yn in


+ 27
- 0
x230/x230_skulls.sh View File

@ -20,6 +20,32 @@ usage()
echo "Usage: $0 -i <4mb_top_image>.rom"
}
check_battery() {
local capacity=$(cat /sys/class/power_supply/BAT*/capacity 2>/dev/null || echo -ne "0")
local online=$(cat /sys/class/power_supply/AC/online 2>/dev/null || cat /sys/class/power_supply/ADP*/online 2>/dev/null || echo -ne "0")
local failed=0
if [ "${online}" == "0" ] ; then
failed=1
fi
if [ "${capacity}" -lt 25 ]; then
failed=1
fi
if [ $failed == "1" ]; then
echo -e "${YELLOW}WARNING:${NC} To prevent shutdowns, we recommend to only run this script when"
echo " your laptop is plugged in to the power supply AND"
echo " the battery is present and sufficiently charged (over 25%)."
while true; do
read -r -p "Continue anyways? (please do NOT!) y/N: " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) exit;;
esac
done
fi
}
args=$(getopt -o i:h -- "$@")
if [ $? -ne 0 ] ; then
usage
@ -106,6 +132,7 @@ echo "0x00800000:0x00bfffff bios" >> ${OUTPUT_PATH}/${LAYOUT_FILENAME}
echo -e "${YELLOW}WARNING${NC}: Make sure not to power off your computer or interrupt this process in any way!"
echo -e " Interrupting this process may result in irreparable damage to your computer!"
check_battery
while true; do
read -r -p "Flash the BIOS now? y/N: " yn
case $yn in


Loading…
Cancel
Save