-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathfinder.sh
More file actions
102 lines (87 loc) · 2.9 KB
/
pathfinder.sh
File metadata and controls
102 lines (87 loc) · 2.9 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
echo ""
echo "PATHFINDER"
echo "Silly script created by https://hackerdude.tech"
echo "Part of the KindleModding/random.sh collection"
echo ""
echo ""
echo "Searching for battery"
battery_path=""
for battery_capacity_path in /sys/class/power_supply/*/capacity; do
battery=$(dirname "$battery_capacity_path")
echo " - Checking if $battery is a valid battery"
if [ -f "$battery/capacity" ] && [ -f "$battery/charging" ] && [ -f "$battery/status" ]; then
echo "Found battery!"
echo "Capacity: $(cat "$battery/capacity")"
echo "Charging: $(cat "$battery/charging")"
echo "Status: $(cat "$battery/status")"
battery_path="$battery"
break
fi
done
if [ -z $battery_path ]; then
echo "ERORR: Could not find valid battery!"
fi
echo ""
echo "Searching for hall sensor"
hall_enable_path=""
i=0
for hall_file in /sys/devices/platform/*hall*/*enable; do
hall_enable_path=$hall_file
echo " - Found hall sensor at: $hall_file"
done
if [ -z $hall_enable_path ]; then
echo "WARN: Could not find hall sensor!"
fi
echo ""
echo "Identifying backlight(s)"
max_intensity=$(lipc-get-prop com.lab126.powerd flMaxIntensity)
amber_backlight=""
main_backlight=""
for potential_backlight in /sys/class/backlight/*/brightness; do
echo "Testing $potential_backlight"
lipc-set-prop -i com.lab126.powerd flIntensity 0
lipc-set-prop -i com.lab126.powerd currentAmberLevel 0
sleep 1
if [ "$(cat "$potential_backlight")" -eq 0 ]; then
lipc-set-prop -i com.lab126.powerd flIntensity $max_intensity
sleep 1
if [ "$(cat "$potential_backlight")" -eq 0 ]; then
lipc-set-prop -i com.lab126.powerd currentAmberLevel $max_intensity
sleep 1
if [ "$(cat "$potential_backlight")" -eq 0 ]; then
echo "Unknown backlight! (Reason: No change when BL state altered)"
else
echo "Backlight is used for amber"
amber_backlight=$potential_backlight
fi
else
echo "Backlight is used for main light"
main_backlight=$potential_backlight
fi
else
echo "Unknown backlight! (Reason: Non-zero when BL turned off)"
fi
done
lipc-set-prop -i com.lab126.powerd flIntensity 0
lipc-set-prop -i com.lab126.powerd currentAmberLevel 0
if [ -z $amber_backlight ]; then
echo "WARN: Amber backlight could not be found!"
fi
if [ -z $main_backlight ]; then
echo "ERROR: Main backlight could not be found!"
exit 1
fi
echo "Discovered Paths:"
echo ""
echo "Main Backlight: $main_backlight"
echo "Amber Backlight: $amber_backlight"
echo "Battery capacity: $battery_path/capacity"
echo "Battery charging: $battery_path/charging"
echo "Battery status: $battery_path/status"
echo "Hall: $hall_enable_path"
if [ -f "/dev/input/touch" ]; then
echo "/dev/input/touch EXISTS"
else
echo "/dev/input/touch DOES NOT EXIST"
fi