-
Notifications
You must be signed in to change notification settings - Fork 39
/
powernow
executable file
·100 lines (77 loc) · 2.5 KB
/
powernow
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
#! /usr/bin/env bash
# powerdown - print energy usage
if [[ $EUID != 0 ]]; then
echo "[powerdown] must be run as root"
exit 1
fi
# module loaded
loaded() {
[[ $(lsmod | cut -f 1 -d " " | grep "^$1$") != "" ]]
}
display_opt () {
[[ -r $1 ]] && echo " - $1: $(cat $1)"
}
display_module() {
modinfo $1 &>/dev/null || return
echo -n " - $1 "
loaded $1 && echo "loaded" || echo "not loaded"
}
display_power() {
for bat in /sys/class/power_supply/BAT*; do
if [[ -f $bat/power_now ]]; then
watt=$(perl -e "print sprintf('%.3f', $(cat $bat/power_now) / 1000000)")
else
watt=$(perl -e "print sprintf('%.3f', $(cat $bat/current_now) * $(cat $bat/voltage_now) / 1000000)")
fi
echo "[powerdown] $bat using $watt watts"
done
}
display_readahead() {
echo " - $1 readahead: $(blockdev --getra $1)"
}
display_wireless() {
echo " - $1: $(iw dev $1 get power_save)"
}
display_power
echo
echo " Detail:"
# bus
#for i in /sys/bus/{pci,spi,i2c}/devices/*/power/control; do display_opt $i; done
# aspm
display_opt /sys/module/pcie_aspm/parameters/policy
# usb autosuspend
#display_opt /sys/module/usbcore/parameters/autosuspend
#for i in /sys/bus/usb/devices/*/power/autosuspend; do display_opt $i; done
#for i in /sys/bus/usb/devices/*/power/control; do display_opt $i; done
#for i in /sys/bus/usb/devices/*/power/level; do display_opt $i; done
# cpu
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do display_opt $i; done
# kernel write mode
display_opt /proc/sys/vm/laptop_mode
display_opt /proc/sys/vm/dirty_ratio
display_opt /proc/sys/vm/dirty_background_ratio
display_opt /proc/sys/vm/dirty_expire_centisecs
display_opt /proc/sys/vm/dirty_writeback_centisecs
# Disk powersave
for dev in "/dev/sd[a-z]"; do display_readahead $dev; done
for i in /sys/class/scsi_host/host*/link_power_management_policy; do display_opt $i; done
# noatime
# Sound card powersave
display_opt /sys/module/snd_hda_intel/parameters/power_save
display_opt /sys/module/snd_hda_intel/parameters/power_save_controller
# wifi powersave
display_wireless wlo1
# Screen powersave
for i in /sys/class/backlight/acpi_video*/brightness; do display_opt $i; done
# webcam
display_module uvcvideo
# bluetooth
display_module btusb
display_module bluetooth
# radeon power profile
display_opt /sys/class/drm/card0/device/power_method
if [[ $(cat /sys/class/drm/card0/device/power_method) == "profile" ]]; then
display_opt /sys/class/drm/card0/device/power_profile
fi
# nmi_watchdog
display_opt /proc/sys/kernel/nmi_watchdog