echo 255 > /sys/class/leds/pandora\:\:power/brightness #power LED bright
}
+show_message() {
+ # TODO: check if desktop is visible; maybe use layer3?
+ xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
+ cmd="DISPLAY=:0.0 zenity --info --text \"$1\""
+ su -c "$cmd" $xfceuser
+}
+
suspend_real() {
delay=0
# - cards don't unmount (running PNDs will break)
# - while charging too, since it stops on suspend?
+ if ! grep -q 'mmc_core.removable=0' /proc/cmdline; then
+ # must unmount cards because they will be "ejected" on suspend
+ # (some filesystems may even deadlock if we don't do this due to bugs)
+ mounts="$(grep "/dev/mmcblk" /proc/mounts | awk '{print $1}' | xargs echo)"
+ for mnt in $mounts; do
+ if ! umount $mnt; then
+ show_message "Could not unmount $mnt, using partial suspend only"
+ return 1
+ fi
+ done
+ swaps="$(grep "/dev/mmcblk" /proc/swaps | awk '{print $1}' | xargs echo)"
+ for swp in $swaps; do
+ if ! swapoff $swp; then
+ show_message "Could not unmount $swp, using partial suspend only"
+ return 1
+ fi
+ done
+ else
+ if [ ! -e /etc/pandora/suspend-warned ]; then
+ show_message "Pandora will now suspend.\n\n\
+Please do not remove SD cards while pandora is suspended, doing so will corrupt them."
+ touch /etc/pandora/suspend-warned
+ fi
+ fi
+
# FIXME: fix the kernel and get rid of this
suspend_net
fi
done
- # must unmount cards because they will be "ejected" on suspend
- # (some filesystems may even deadlock if we don't do this due to bugs)
- grep "/dev/mmcblk" /proc/mounts | awk '{print $1}' | xargs umount -r
-
sleep $delay
+ sync
echo mem > /sys/power/state
# if we are here, either we already resumed or the suspend failed