More Simple Bash Scripts


This is pretty close to the little bash script I use to check if I am connected to the internet and load checkgmail. This time around I have just added it to my cron jobs to check if my laptop is on battery or ac power. If I am on ac power start up distributed.net client other wise shut it down. Its a little bit of a messy way to do this, but for my needs it work for now.

This is assuming that you are using acpid for you power management.

#!/bin/bash
cat /proc/acpi/ac_adapter/AC/state | grep on-line
if [ "$?" = "0" ]; then
/etc/init.d/distributed-net start
else
/etc/init.d/distributed-net stop
fi

Leave a Reply