#!/bin/bash
if [ -s /run/power.save ]; then
t=save
t1=restore
a=restore
else
t=performance
t1=save
# keep min sockets, then min cores per max cache
a='sockets - cores - save'
fi
ask(){
echo "- $1$2
"
}
orsudo(){
ask "$1" "bash -c "$2 || sudo -A -- $2 ""
}
echo "
- sudo -n -- /usr/sbin/ya-nrg force $a
"
orsudo Reboot /sbin/reboot
orsudo Off '/sbin/poweroff -i -h'
[ -w '/sys/power/state' ] && for i in $(< /sys/power/state); do
ask "Suspend to $i" "/bin/bash -c "echo $i >/sys/power/state""
done
echo ""