#!/bin/bash

# Action script ensure that the trackpoint returns after s3/s4.  Makes
# use of acpi's code to determine the X user, so xinput list will
# work.

function checkMouseAndReload ()
{
    [ -f /usr/share/acpi-support/power-funcs ] || exit 0 
    . /usr/share/acpi-support/power-funcs
    getXconsole
    sleep 3                 # at the best of times it doesn't appear
                            # for a couple of seconds

    if ! xinput list | grep -qi trackpoint; then
        echo "$(date +'%F %T') reloading psmouse" >> $LOGFILE
        rmmod psmouse
        modprobe psmouse
    fi
}

case "${1}" in
    resume|thaw)
        LOGFILE=/var/log/$(basename $0 .sh).log
        echo "$(date +'%F %T') running" >> $LOGFILE
	checkMouseAndReload &
        ;;
esac

