I've written an crontab entry that runs a script in my home directory as user. That notifies me if I forgot to switch the power brick on. This works fine.
BATTERY=$(upower -e | grep 'BAT')
BATTERY_PERCENTAGE=$(upower -i $BATTERY|grep percentage|awk '{ print $2 }'|sed s/'%'/''/g)
AC_STATUS=$(cat /sys/class/power_supply/AC/online)
echo "Battery: $BATTERY_PERCENTAGE %"
if [ "$BATTERY_PERCENTAGE" -lt "20" ] &&
[ "$AC_STATUS" -eq "0" ]; then
notify-send --urgency=critical "WARNING: Battery is about to die" "Plug in the power cable"
mplayer samsung_low_battery_sound.mp4 &> /dev/null
fi
My problem is that I don't want another root crontab entry, to check if the battery and AC is switched off, to automatically shutdown the laptop if it is on 5%. Rather would prefer to use the existing script. But the shutdown command needs root access. Is it possible to auto-shutdown as user via script? (The desktop allows this)
Will
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 320
تاريخ: دوشنبه
4 مرداد
1395 ساعت: 10:10