saving uncommitted changes in /etc prior to emerge run
This commit is contained in:
1
hprofile/profiles/power/._cfg0000_default
Normal file
1
hprofile/profiles/power/._cfg0000_default
Normal file
@@ -0,0 +1 @@
|
||||
adp
|
||||
5
hprofile/profiles/power/._cfg0000_profiles
Normal file
5
hprofile/profiles/power/._cfg0000_profiles
Normal file
@@ -0,0 +1,5 @@
|
||||
adp
|
||||
bat
|
||||
dyn
|
||||
med
|
||||
quiet
|
||||
17
hprofile/profiles/power/._cfg0000_ptest
Normal file
17
hprofile/profiles/power/._cfg0000_ptest
Normal file
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# power/ptest
|
||||
#
|
||||
|
||||
local state="$(echo /sys/class/power_supply/A*)"
|
||||
|
||||
if test -n "$state" -a -r "$state"; then
|
||||
state=$(< "$state")
|
||||
case "$state" in
|
||||
(1) echo "adp";;
|
||||
(0) echo "bat";;
|
||||
esac
|
||||
fi
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
4
hprofile/profiles/power/README
Normal file
4
hprofile/profiles/power/README
Normal file
@@ -0,0 +1,4 @@
|
||||
This is a sample power profile setup. It's different from other profiles in
|
||||
that there are no configuration files to be switched. All the magic happens
|
||||
in the start scripts, found in the scripts/ directory. ptest is still used to
|
||||
determine the current profile of course.
|
||||
1
hprofile/profiles/power/default
Normal file
1
hprofile/profiles/power/default
Normal file
@@ -0,0 +1 @@
|
||||
AC
|
||||
4
hprofile/profiles/power/profiles
Normal file
4
hprofile/profiles/power/profiles
Normal file
@@ -0,0 +1,4 @@
|
||||
AC
|
||||
Medium
|
||||
Battery
|
||||
Dynamic
|
||||
22
hprofile/profiles/power/ptest
Executable file
22
hprofile/profiles/power/ptest
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script should echo only the name of the profile that should be used
|
||||
# It should assume it is called before any other scripts. In particular, it
|
||||
# cannot rely on environment variables set in /etc/profile or elsewhere. The
|
||||
# script may assume it will be run as root.
|
||||
|
||||
profile="AC"
|
||||
|
||||
if test -f /proc/acpi/ac_adapter/AC0/state ; then
|
||||
status="$(cat /proc/acpi/ac_adapter/AC0/state)"
|
||||
case "${status}" in
|
||||
*on-line)
|
||||
profile="AC"
|
||||
;;
|
||||
*off-line)
|
||||
profile="Battery"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "${profile}"
|
||||
4
hprofile/profiles/power/scripts/AC.start
Executable file
4
hprofile/profiles/power/scripts/AC.start
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
speedfreq -p performance
|
||||
echo "15" > /proc/acpi/asus/brn
|
||||
4
hprofile/profiles/power/scripts/Battery.start
Executable file
4
hprofile/profiles/power/scripts/Battery.start
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
speedfreq -p powersave
|
||||
echo "6" > /proc/acpi/asus/brn
|
||||
4
hprofile/profiles/power/scripts/Dynamic.start
Executable file
4
hprofile/profiles/power/scripts/Dynamic.start
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
speedfreq -p dynamic
|
||||
|
||||
4
hprofile/profiles/power/scripts/Medium.start
Executable file
4
hprofile/profiles/power/scripts/Medium.start
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
speedfreq -p 1000
|
||||
echo "11" > /proc/acpi/asus/brn
|
||||
15
hprofile/profiles/power/scripts/adp.start
Normal file
15
hprofile/profiles/power/scripts/adp.start
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# power/scripts/adp.start
|
||||
#
|
||||
|
||||
start "powersave" "auto" "auto" "min_power" "1" "0" "1000" "default"
|
||||
start-profile "disk" "adp"
|
||||
|
||||
if [[ "$DISPLAY" ]]; then
|
||||
xbacklight -set 30
|
||||
xset dpms 300 400 600
|
||||
fi
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
16
hprofile/profiles/power/scripts/bat.start
Normal file
16
hprofile/profiles/power/scripts/bat.start
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# power/scripts/bat.start
|
||||
#
|
||||
#
|
||||
|
||||
start "powersave" "auto" "auto" "min_power" "1" "0" "1500" "powersave"
|
||||
start-profile "disk" "bat"
|
||||
|
||||
if [[ "$DISPLAY" ]]; then
|
||||
xbacklight -set 30
|
||||
xset dpms 300 400 600
|
||||
fi
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
15
hprofile/profiles/power/scripts/dyn.start
Normal file
15
hprofile/profiles/power/scripts/dyn.start
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# power/scripts/dyn.start
|
||||
#
|
||||
|
||||
start "performance" "on" "on" "mix_power" "0" "1" "500" "performance"
|
||||
start-profile "disk" "dyn"
|
||||
|
||||
if [[ "$DISPLAY" ]]; then
|
||||
xbacklight -set 30
|
||||
xset dpms 300 400 600
|
||||
fi
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
15
hprofile/profiles/power/scripts/med.start
Normal file
15
hprofile/profiles/power/scripts/med.start
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# power/scripts/med.start
|
||||
#
|
||||
|
||||
start "performance" "on" "on" "min_power" "0" "1" "500" "performance"
|
||||
start-profile "disk" "adp"
|
||||
|
||||
if [[ "$DISPLAY" ]]; then
|
||||
xbacklight -set 30
|
||||
xset dpms 300 400 600
|
||||
fi
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
15
hprofile/profiles/power/scripts/quiet.start
Normal file
15
hprofile/profiles/power/scripts/quiet.start
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# power/scripts/quiet.start
|
||||
#
|
||||
|
||||
start "powersave" "auto" "auto" "min_power" "1" "0" "2500" "powersave"
|
||||
start-profile "disk" "quiet"
|
||||
|
||||
if [[ "$DISPLAY" ]]; then
|
||||
xbacklight -set 30
|
||||
xset dpms 300 400 600
|
||||
fi
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
67
hprofile/profiles/power/start
Normal file
67
hprofile/profiles/power/start
Normal file
@@ -0,0 +1,67 @@
|
||||
#
|
||||
# $Header: profiles/power/start Exp $
|
||||
#
|
||||
|
||||
local cpu pci usb hda nmi vmw aspm scsi
|
||||
declare -A opt
|
||||
opt=(
|
||||
[cpu]=${1:-powersave}
|
||||
[pci]=${2:-auto}
|
||||
[usb]=${3:-auto}
|
||||
[hda]=${5:-1}
|
||||
[nmi]=${6:-0}
|
||||
[vmw]=${7:-1000}
|
||||
[aspm]=${8:-default}
|
||||
[scsi]=${4:-min_power}
|
||||
)
|
||||
|
||||
for cpu in /sys/devices/system/cpu/cpu[0-9]*; do
|
||||
echo ${opt[cpu]} >$cpu/cpufreq/scaling_governor
|
||||
done
|
||||
|
||||
[ -e /sys/module/pcie_aspm/parameters/policy ] &&
|
||||
echo ${opt[aspm]} >/sys/module/pcie_aspm/parameters/policy >/dev/null 2>&1
|
||||
for scsi in /sys/class/scsi_host/host[0-9]*; do
|
||||
[ -e $scsi/link_power_management_policy ] || continue
|
||||
case "$(< $scsi/proc_name)" in
|
||||
(ahci|usb-storage)
|
||||
echo ${opt[scsi]} >$scsi/link_power_management_policy;;
|
||||
(*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# set usb host to auto powersave
|
||||
for usb in /sys/bus/usb/devices/{usb[0-9],[0-9]-[0-9]}; do
|
||||
echo ${opt[usb]} >$usb/power/control
|
||||
done
|
||||
|
||||
# pci power control
|
||||
for pci in /sys/bus/pci/devices/0000:0*; do
|
||||
echo ${opt[pci]} >$pci/power/control
|
||||
done
|
||||
|
||||
# snd-hda-intel powersave
|
||||
[ -e /sys/module/snd_hda_intel/parameters/power_save ] &&
|
||||
echo ${opt[hda]} >/sys/module/snd_hda_intel/parameters/power_save
|
||||
|
||||
# turn off NMI watchdog
|
||||
[ -e /proc/sys/kernel/nmi_watchdog ] &&
|
||||
echo ${opt[nmi]} >/proc/sys/kernel/nmi_watchdog
|
||||
|
||||
# VM write back timeout
|
||||
[ -e /proc/sys/vm/dirty_writeback_centisecs ] &&
|
||||
echo ${opt[vmw]} >/proc/sys/vm/dirty_writeback_centisecs
|
||||
|
||||
unset opt
|
||||
|
||||
[[ "${HPROFILE[power]}" == "network" ]] || return
|
||||
local iface running
|
||||
|
||||
for iface in $(ifconfig | sed -nre 's/(^[ew].*[0-9]{1}):.*/\1/p'); do
|
||||
running="$(ifconfig $iface | sed -nre /$iface/'s/.*(RUNNING).*/\1/p')"
|
||||
[[ "$running" ]] || ifconfig "$iface" down
|
||||
done
|
||||
|
||||
#
|
||||
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
|
||||
#
|
||||
Reference in New Issue
Block a user