Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Apr 2008 11:15:11 -0400
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        freebsd-acpi@FreeBSD.org
Cc:        Marcin Nowak <marcin.nowak@simplusnet.pl>
Subject:   Re: ODP: Re: Acpli driver for FreeBSD to Asus A6F
Message-ID:  <200804171115.13132.jkim@FreeBSD.org>
In-Reply-To: <f701ace02610.48074ecd@plusnet.pl>
References:  <f70bc5fe5c9a.480745b9@plusnet.pl> <m2y77coifl.wl%funa@funa.org> <f701ace02610.48074ecd@plusnet.pl>

next in thread | previous in thread | raw e-mail | index | archive | help

--Boundary-00=_Bm2BI7yPjWYXsqC
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline

On Thursday 17 April 2008 07:21 am, Marcin Nowak wrote:
> Hi Akira!
>
> I have discovered that feature (I think about LCD Brightness), but
> I thought, there are others. Brightness works fine (that like you
> described). Is any chance for simply volume control or another acpi
> buttons?

You have to hook up devd to get extra buttons that are not handled by 
acpi_asus(4).  One night, I wrote an ugly script to do that (attached 
for your reference).  To use it, you need to add the following lines 
in the /etc/devd.conf:

# ASUS laptop notified actions.
notify 10 {
        match "system"          "ACPI";
        match "subsystem"       "ASUS";
        action                  "/etc/acpi_asus $notify";
};

and place the attached file in /etc and make it executable.  For X.org 
OSD, you need to install ports/misc/xosd.

Enjoy,

Jung-uk Kim

> Greets :)
>
> ----- Wiadomo뜻 oryginalna -----
> Od:: Akira Funahashi <funa@funa.org>
> Data:: Czwartek, 17 Kwiecie� 2008 12:59
> Temat: Re: Acpli driver for FreeBSD to Asus A6F
>
> > Hi Marcin,
> >
> > Thank you so much for your feedback!
> > Here is the complete procedure how to use & test my patch.
> > # I think you have already done step 1 to 3, but please let me
> > make # sure what you have done :-)
> >
> > 1. Apply the patch.
> >   # cd /sys/de   # patch < acpi_asus.c.diff
> >   # cd /sys/i386/compile/$YOUR_CONFIG
> >   # make modules && make instal
> >
> > 2. add following line to /boot/loader.conf
> >   acpi_asus_load="YES"
> >
> > 3. reboot
> >
> > 4. After reboot, try the following command:
> >   # sysctl hw.acpi.asus
> >   ... will shows a list of customizable values for your ASUS
> > laptop. For instance, you might see the line
> >
> >     hw.acpi.asus.lcd_brightness: 15 (or whatever a value)
> >
> >   which describes your LCD brightness (the value will be 0 to 15,
> > I guess).
> >   You can change the brightness by following command
> >
> >   # sysctl hw.acpi.asus.lcd_brightness=1
> >
> >   which will reduce the brightness.
> >
> >   Well, some laptop allows us to use hot-keys (ex. [Fn]+[F3]) to
> >   change the brightness, or use other ACPI related functions.
> >   On my EeePC, I can change the brightness through [Fn]+[F3] and
> > [F4] after appling my patch. But it depends on the implementation
> > of ACPi on each laptop, how the hot-key is treated under ACPI.
> >
> > Please let us (freebsd-acpi@freebsd.org) know whether my patch
> > worked on your A6F, so that we can go ahead and commit the patch
> > to CVS HEAD. Your comment/feedback is really important for me to
> > continue working on ASUS ACPI support.
> >
> > And the most important thing is that, I wish you could have fun
> > with this patch :-)
> >
> > Thanks,
> > --
> > Akira Funahashi/[funa@funa.org]
>
> _______________________________________________
> freebsd-acpi@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-acpi
> To unsubscribe, send any mail to
> "freebsd-acpi-unsubscribe@freebsd.org"

--Boundary-00=_Bm2BI7yPjWYXsqC
Content-Type: text/plain;
  charset="utf-8";
  name="acpi_asus"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="acpi_asus"

#!/bin/sh
#
# Copyright (c) 2008 Jung-uk Kim <jkim@FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# $FreeBSD$
#

# Application to run when 'Running Man' button is pressed.
running_man=
running_man_X="firefox"

# Application to run when 'Touchpad' button is pressed.
touchpad=
touchpad_X="xterm -bg white -rightbar -sb -sl 5000"

# Amount of volume to increase or decrease.
vol_step=20

awk=/usr/bin/awk
cat=/bin/cat
env=/usr/bin/env
grep=/usr/bin/grep
mixer=/usr/sbin/mixer
osd_cat=/usr/local/bin/osd_cat
pgrep=/bin/pgrep
ps=/bin/ps
sed=/usr/bin/sed
sysctl=/sbin/sysctl
tled=/dev/led/tled

find_xorg() {
	local pid
	local cmd
	local user

	if [ -f /tmp/.X0-lock ]; then
		pid=`${cat} /tmp/.X0-lock`
		cmd=`${ps} -o command -p ${pid} | ${grep} ^X`
		if [ $? -eq 0 ]; then
			pid=`echo ${cmd} |				\
			    ${sed} -e 's/^X.*\.serverauth\.//g' -e 's/ .*//g'`
			user=`${ps} -o user -p ${pid} | grep -v ^USER`
			if [ $? -eq 0 ]; then
				echo ${user}
				return 0
			fi
		fi
	fi
	return 1
}

osd_cat() {
	local user
	local title
	local osd_args="	\
	    --font=-adobe-helvetica-bold-r-normal--24-240-75-75-p-138-iso8859-1\
	    -c black -s 3 -S lightyellow -p middle -A center -d 1"

	user=$1
	shift

	if [ $# -gt 2 -a $1 = '-T' ]; then
		title=$2
		shift 2
		osd_args="${osd_args} -b percentage -T \"${title}: $*\" -P $*"
		${env} DISPLAY=:0 su ${user} -c	"${osd_cat} ${osd_args}" &
	else
		(echo "$*" | ${env} DISPLAY=:0 su ${user} -c	\
		    "${osd_cat} ${osd_args}") &
	fi
}

cons_cat() {
	local title
	local message

	if [ $# -gt 2 -a $1 = '-T' ]; then
		title=$2
		shift 2
		echo "${title} set to $*" > /dev/console
	else
		echo "$*" > /dev/console
	fi
}

log() {
	local user

	user=`find_xorg`
	if [ $? -eq 0 ]; then
		osd_cat ${user} $*
	else
		cons_cat $*
	fi
}

get_volume() {
	local vol

	vol=`${mixer} -S vol | ${awk} -F : '{ print ($2 + $3) / 2 }'`

	return ${vol}
}

change_volume() {
	local cmd=$1
	local vol

	get_volume
	vol=$?
	if [ ${cmd} = 'increase' ]; then
		if [ ${vol} -ge 100 ]; then
			return
		elif [ ${vol} -ge $(( 100 - ${vol_step} )) ]; then
			vol=100
		else
			vol=$(( ${vol} + ${vol_step} ))
		fi
		${mixer} -S ${vol}
	elif [ ${cmd} = 'decrease' ]; then
		if [ ${vol} -le 0 ]; then
			return
		elif [ ${vol} -le ${vol_step} ]; then
			vol=0
		else
			vol=$(( ${vol} - ${vol_step} ))
		fi
		${mixer} -S ${vol}
	elif [ ${cmd} = 'mute' ]; then
		if [ ${vol} -gt 0 ]; then
			sh /etc/rc.d/mixer quietstop
			${mixer} -S 0
			vol=0
		else
			sh /etc/rc.d/mixer quietstart
			get_volume
			vol=$?
		fi
	fi
	log -T Volume ${vol}
}

run_application() {
	local cmd=$1
	local app
	local app_X
	local user

	case ${cmd} in
	running_man)
		app="${running_man}"
		app_X="${running_man_X}"
		;;
	touchpad)
		app="${touchpad}"
		app_X="${touchpad_X}"
		;;
	*)
		return
		;;
	esac

	user=`find_xorg`
	if [ $? -eq 0 ]; then
		su - ${user} -c "env DISPLAY=:0 ${app_X}" &
	else
		${app} &
	fi
}

change_video_output() {
	local output

	user=`find_xorg`
	if [ $? -eq 0 ]; then
		# XXX Bad, very bad. RadeonHD hangs system if you do that.
		# Use XRandR if/when it works.
	else
		output=`${sysctl} -n hw.acpi.asus.video_output`
		if [ ${output} -ge 7 ]; then
			output=0
		else
			output=$(( ${output} + 1 ))
		fi
		${sysctl} -q hw.acpi.asus.video_output=${output} > /dev/null
		log "Video output changed to ${output}"
	fi
}

if [ $# -lt 1 ]; then
	echo "Usage: $0 <event>"
	exit 1
fi

case $1 in
0x30)
	change_volume increase
	;;

0x31)
	change_volume decrease
	;;
0x32)
	change_volume mute
	;;
0x57)
	log "Battery discharging"
	;;
0x58)
	log "Battery charging"
	;;
0x5c)
	run_application running_man
	;;
0x61)
	change_video_output
	;;
0x6b)
	run_application touchpad
	;;
*)
	log "unknown event $1"
	;;
esac

exit 0

--Boundary-00=_Bm2BI7yPjWYXsqC--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804171115.13132.jkim>