[Bug 222324] Re: Support for panasonic hotkeys missing
linuxrules
222324 at bugs.launchpad.net
Tue Oct 5 23:28:54 UTC 2010
here is some code I wrote (I own a CF-51)
first try this:
# modprobe panasonic_laptop
save the below as: /etc/acpi/events/hotkey
event=HKEY\ 00000080\ 000000(8[1-689]|0[37a])
action=/etc/acpi/hotkey.pl %e
save the below as: /etc/acpi/hotkeys.pl
then chmod +x /etc/acpi/hotkeys.pl
#!/usr/bin/perl
=begin comment
Copyright (C) 2010 Mitchell Lafferty (coolspeedy6 at gmail.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see L<"http://www.gnu.org/licenses/">.
=end comment
=cut
use feature ":5.10";
use strict;
use warnings;
# 00000081 dn b
# 00000082 up b
# 00000084 mute
# 00000085 v dn
# 00000086 v up
# 00000007 ram sleep
# 00000089 batt
# 0000000a hdd sleep
#use YAML qw(DumpFile);
#$hash = {'BRIGHT_DN_STEPS' => 10,'BRIGHT_UP_STEPS' => 10};
#print DumpFile('/home/mitch/.acpi_config', $hash);
use constant {
ACPI_BRIGHT_DN => '00000081',
ACPI_BRIGHT_UP => '00000082',
ACPI_SND_MUTE => '00000084',
ACPI_SND_DN => '00000085',
ACPI_SND_UP => '00000086',
ACPI_CRT_OUT => '00000088',
ACPI_BATT_KEY => '00000089',
ACPI_SLEEP_RAM => '00000007',
ACPI_SLEEP_HDD => '0000000a',
ACPI_PCC_BRIGHT => '/sys/devices/virtual/backlight/panasonic'
};
my $BRIGHT_UP_STEPS = 10;
my $BRIGHT_DN_STEPS = $BRIGHT_UP_STEPS;
my $SND_UP_STEPS = 1;
my $SND_DN_STEPS = $SND_UP_STEPS;
my ( $max_bright, $new_bright, $now_bright );
given ( $ARGV[3] ) {
when (undef) {
exit 0;
}
when (ACPI_BRIGHT_DN) {
$max_bright = QuickOpen( ACPI_PCC_BRIGHT . '/max_brightness' );
$now_bright = QuickOpen( ACPI_PCC_BRIGHT . '/brightness' );
chomp($max_bright);
chomp($now_bright);
$new_bright = $now_bright - $BRIGHT_UP_STEPS;
$new_bright = 0 if ( $new_bright < 0 );
#~ print $max_bright," ", $now_bright," ", $new_bright, "\n";
QuickWrite( ACPI_PCC_BRIGHT . '/brightness', "$new_bright\n" );
}
when (ACPI_BRIGHT_UP) {
$max_bright = QuickOpen( ACPI_PCC_BRIGHT . '/max_brightness' );
$now_bright = QuickOpen( ACPI_PCC_BRIGHT . '/brightness' );
chomp($max_bright);
chomp($now_bright);
$new_bright = $now_bright + $BRIGHT_UP_STEPS;
$new_bright = $max_bright if ( $new_bright > $max_bright );
#~ print $max_bright," ", $now_bright," ", $new_bright, "\n";
QuickWrite( ACPI_PCC_BRIGHT . '/brightness', "$new_bright\n" );
}
when (ACPI_SND_MUTE) {
# don't care
...;
}
when (ACPI_SND_DN) {
# don't care
#~ system("amixer -q sset PCM,0 $SND_DN_STEPS-");
...;
}
when (ACPI_SND_UP) {
# don't care
#~ system("amixer -q sset PCM,0 $SND_UP_STEPS+");
...;
}
when (ACPI_CRT_OUT) {
# don't care
...;
}
when (ACPI_BATT_KEY) {
# don't care
...;
}
when (ACPI_SLEEP_RAM) {
system('pm-suspend &');
}
when (ACPI_SLEEP_HDD) {
system('pm-hibernate &');
}
default {
die "What?: $ARGV[3]\n";
}
}
sub QuickOpen {
my $data;
open( DAT, "<", shift ) || die "Err: read: $!\n";
while (<DAT>) {
$data .= $_;
}
close(DAT);
return $data;
}
sub QuickWrite {
open( DAT, ">", shift ) || die "Err: write: $!\n";
print DAT shift;
close(DAT);
}
--
Support for panasonic hotkeys missing
https://bugs.launchpad.net/bugs/222324
You received this bug notification because you are a member of Kernel
Bugs, which is subscribed to linux in ubuntu.
More information about the kernel-bugs
mailing list