#!/bin/sh
. "${PM_FUNCTIONS}"
do_add_quirks()
{
local quirks="$(lshal | \
awk -F '[. ]' \
'/ power_management.quirk.[0-9a-z_]+ = true/ \
{gsub(/_/, "-", $5); printf("--quirk-%s ", $5)}')"
echo "Adding quirks from HAL: $quirks"
add_parameters $quirks
}
do_save_quirks()
{
# better to gather too much information than not enough
hgp="hal-get-property --udi /org/freedesktop/Hal/devices/computer --key"
vendor=$($hgp system.hardware.vendor)
product=$($hgp system.hardware.product)
firmware=$($hgp system.firmware.version)
video_vendor=$($hgp system.hardware.primary_video.vendor --hex)
video_card=$($hgp system.hardware.primary_video.product --hex)
(
exec >"/etc/hal/fdi/information/99local-pm-utils-quirks.fdi"
echo ' '
echo ''
echo ''
echo ' '
echo " "
echo " "
echo " "
echo " "
echo " "
for p in ${PM_CMDLINE}; do
quirk="${p#--quirk-}"
[ "$p" = "$quirk" ] && continue
echo " true" |tr - _
done
echo " "
echo " "
echo " "
echo " "
echo " "
echo " "
echo ""
)
echo "FDI file created as /etc/hal/fdi/information/99local-pm-utils-quirks.fdi"
}
maybe_add_quirks()
{
[ -z "$PM_CMDLINE" ] && {
command_exists lshal || return $NA
do_add_quirks
return 0
}
command_exists lshal || {
echo "--auto-quirks requires HAL. Aborting"
return 1
}
has_parameter --auto-quirks || return 0
do_add_quirks
remove_parameters --auto-quirks
}
maybe_save_quirks()
{
inhibited && return 0
has_parameter --store-quirks-as-fdi && do_save_quirks
return 0
}
help()
{
echo
echo "Auto quirk handler option:"
echo
echo " --auto-quirks"
echo " Running without any options will also invoke auto quirk."
echo
echo " --store-quirks-as-fdi"
}
case $1 in
suspend|hibernate) maybe_add_quirks ;;
thaw|resume) maybe_save_quirks ;;
help) help ;;
*) exit $NA ;;
esac