-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibreboot-disablebeeps.sh
66 lines (52 loc) · 1.91 KB
/
libreboot-disablebeeps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# libreboot-disablebeeps.sh
# version 1.0
# Disable battery beeps and alarm on librebooted Thinkpad laptops.
# Michael McMahon
# License: AGPLv3
# To run this script, boot a Debian based distribution on a Thinkpad laptop with
# libreboot installed, open a terminal, navigate to this directory, and run this
# script with:
# sudo bash libreboot-disablebeeps.sh
# Based on https://libreboot.org/docs/misc/#power-management-beeps-on-thinkpads
# Initialization checks
# Check for /bin/bash.
if [ "$BASH_VERSION" = '' ]; then
echo "You are not using bash."
echo "Use this syntax instead:"
echo "sudo bash bluearchive.sh"
exit 1
fi
# Check for root.
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Check networking
# https://unix.stackexchange.com/questions/190513/shell-scripting-proper-way-to-
# check-for-internet-connectivity
echo Checking network...
if ping -q -c 1 -W 1 google.com >/dev/null; then
echo "The network is up."
else
echo "The network is down."
echo "Check connection and restart script!"
exit 1
fi
echo "Installing dependencies..."
apt update
apt install -y libftdi1
wget https://www.mirrorservice.org/sites/libreboot.org/release/stable/20160907/libreboot_r20160907_util.tar.xz
tar xvf libreboot_r20160907_util.tar.xz
mkdir -p roms
echo "Extracing libreboot image..."
romfile=roms/t400-$(date +%Y%m%d-%H%M).rom
./libreboot_r20160907_util/flashrom/x86_64/flashrom -p internal -r ./$romfile
echo "Backing up libreboot image..."
cp $romfile $romfile.bak
echo "Modifying libreboot image..."
./libreboot_r20160907_util/nvramtool/x86_64/nvramtool -v
./libreboot_r20160907_util/nvramtool/x86_64/nvramtool -C ./$romfile -w power\_management\_beeps=Disable
./libreboot_r20160907_util/nvramtool/x86_64/nvramtool -C ./$romfile -w low\_battery\_beep=Disable
echo "Flashing modified libreboot image..."
./libreboot_r20160907_util/flashrom/x86_64/flashrom -p internal -w $romfile