Here’s a /etc/acpi/default.sh script for Gentoo (should work on other distros though) that handles some power management features of Sony VAIO VGN-series. It handles dimming the screen, switching cpufreq to powersave governor and turning on WiFi powersave on AC Adapter plug-out, and restoring previous settings on plug-in back. It also handles manual screen dimming (via Fn-F5 and Fn-F6) with XOSD feedback and hibernating via Fn-F12 key.
You need the following packages installed:
- sys-power/acpid
- sys-power/cpufrequtils
- media-video/nvclock
- x11-libs/xosd
- sys-power/hibernate-script
- net-wireless/wireless-tools
#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/acpid/files/acpid-1.0.4-default.sh,v 1.1 2005/03/15 19:15:53 ciaranm Exp $
# Default acpi script that takes an entry for all actions
set $*
export DISPLAY=:0.0
group=${1//*/}
action=${1/*//}
case “$group” in
button)
case “$action” in
# power)
# /usr/sbin/hibernate
# ;;
*)
logger “ACPI power action $action is not defined”
;;
esac
;;
ac_adapter)
if [ "$4" == "00000000" ]; then
nvclock -S 15% 2>/dev/null | grep -o ‘from [0-9]*% to’ | cut -d’ ‘ -f2 >/var/state/smartdimmer
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor > /var/state/governor
cpufreq-set -g powersave
iwconfig eth1 power on
else
if [ -r /var/state/smartdimmer ]; then
nvclock -S `cat /var/state/smartdimmer` >/dev/null 2>&1
else
nvclock -S 100% >/dev/null 2>&1
fi
if [ -r /var/state/governor ]; then
cpufreq-set -g `cat /var/state/governor`
else
. /etc/conf.d/cpufrequtils
cpufreq-set -g $GOVERNOR
fi
iwconfig eth1 power off
fi
;;
sony)
case “$action” in
hotkey)
case “$4″ in
00000010) # F5
BRIGHTNESS=`nvclock -i 2>/dev/null | grep -o ‘Backlight level: [0-9]+’ | cut -d’ ‘ -f3`
BRIGHTNESS=`nvclock -S $(( BRIGHTNESS – 10 )) 2>/dev/null | grep -o ‘from [0-9]*% to [0-9]*%’ | cut -d’ ‘ -f4`
if [ -n "$BRIGHTNESS" ]; then
osd_cat -p bottom -o 32 -A center -c white -d 1 -b percentage -P $BRIGHTNESS &
fi
;;
00000011) # F6
BRIGHTNESS=`nvclock -i 2>/dev/null | grep -o ‘Backlight level: [0-9]+’ | cut -d’ ‘ -f3`
BRIGHTNESS=`nvclock -S $(( BRIGHTNESS + 10 )) 2>/dev/null | grep -o ‘from [0-9]*% to [0-9]*%’ | cut -d’ ‘ -f4`
if [ -n "$BRIGHTNESS" ]; then
osd_cat -p bottom -o 32 -A center -c white -d 1 -b percentage -P $BRIGHTNESS &
fi
;;
00000017) # F12
/usr/sbin/hibernate
;;
*)
logger “ACPI sony button $4 is not defined”
;;
esac
;;
*)
logger “ACPI sony action $action is not defined”
;;
esac
;;
*)
logger “ACPI group $group / action $action is not defined: $*”
;;
esac
You may need to tweak the DISPLAY variable. The Power Button and Lid events are handled via GNOME Power Manager, thus handling via acpid is commented out.

0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.