View previous topic :: View next topic |
Author |
Message |
nunopedrosilva Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/5482055964388871f80cd6.jpg)
Joined: 24 Oct 2004 Posts: 132 Location: Corroios, Portugal
|
Posted: Sat Nov 05, 2005 7:16 pm Post subject: toshiba laptop extra keys |
|
|
Hi, I have a toshiba satellite laptop, with multimedia keys, wich I'd like to configure them when I'm using xmms.
can anyone tell me how to configure them? and with wich software?
thanks |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
JPMRaptor Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/518942103409c3fbe53c05.jpg)
Joined: 04 Oct 2002 Posts: 410 Location: Maryland
|
Posted: Sun Nov 06, 2005 12:03 am Post subject: |
|
|
I found a script to handle LCD level changes via the toshiba hotkeys that you could modify to work with the additional keys:
Code: | #!/usr/bin/env python
#
# Poll hotkeys of Libretto L1 series laptop and trigger appropriate events.
#
# Copyright (C) 2002 John Belmonte
#
# $Date: 2002/08/26 $
# $Change: 157 $
#
#
# TODO
#
# cleanup pid file upon termination
# support video out key
#
#
# NOTES
#
# Supporting the video out key would require a way to reset the X server
# if X were running.
#
import time
import re
import sys
import os
#
### config
#
polls_per_sec = 4
proc_dir = '/proc/acpi/toshiba/'
pid_filename = '/var/run/%s.pid' % os.path.basename(sys.argv[0])
#
### key assignments
#
brightness_down = 0x0140 # F6 push
brightness_up = 0x0141 # F7 push
#force_fan_toggle = 0x0142 # F8 push
#processor_speed = 0x013C # F2 push
#
### general utils
#
# convert string to int, guessing number base
def toint(s):
return int(s, 0)
# clamp x to range [a, b]
def clamp(x, a, b):
if x < a: return a
if x > b: return b
return x
def error(msg):
if msg: sys.exit('ERROR: ' + msg)
else: sys.exit(1)
#
### app-specific funcs
#
## Nicolas Code
def aread_val(file, key):
file_name = file
file_h = open(file_name)
text = file_h.read()
file_h.close()
match = re.search('%s:\s*(\S+)' % key, text)
if not match:
error('search for key "%s" in file "%s" failed.\nFile text was:\n%s' %
(key, file, text))
return match.group(1)
def awrite_val(file, key, val):
file_name = file
file = open(file_name, 'w')
file.write('%s:%s' % (key, val))
file.close()
## Native Code
def read_val(file, key):
file_name = proc_dir + file
file_h = open(file_name)
text = file_h.read()
file_h.close()
match = re.search('%s:\s*(\S+)' % key, text)
if not match:
error('search for key "%s" in file "%s" failed.\nFile text was:\n%s' %
(key, file, text))
return match.group(1)
def write_val(file, key, val):
file_name = proc_dir + file
file = open(file_name, 'w')
file.write('%s:%s' % (key, val))
file.close()
def is_hotkey_ready():
return toint(read_val('keys', 'hotkey_ready'))
def get_hotkey():
code = toint(read_val('keys', 'hotkey'))
write_val('keys', 'hotkey_ready', 0)
return code
#
### main
#
# check version
assert(toint(read_val('version', 'proc_interface')) == 1)
# fork to background and write out pid file
pid = os.fork()
if pid != 0:
file = open(pid_filename, 'w')
file.write('%d\n' % pid)
file.close()
sys.exit(0)
# flush hotkey queue
while is_hotkey_ready():
get_hotkey()
# polling loop
while 1:
while is_hotkey_ready():
code = get_hotkey()
#print('0x%04x' % code)
if code == brightness_down or code == brightness_up:
num_levels = toint(read_val('lcd', 'brightness_levels'))
current_level = toint(read_val('lcd', 'brightness'))
increment = (code == brightness_down) and -1 or 1
new_level = clamp(current_level + increment, 0, num_levels-1)
write_val('lcd', 'brightness', new_level)
#elif code == force_fan_toggle:
# current_val = toint(read_val('fan', 'force_on'))
# write_val('fan', 'force_on', not current_val)
#elif code == processor_speed:
# cpu = '/proc/acpi/processor/CPU0/performance'
# act = aread_val(cpu,'active state')
# if act == 'P0' : new_act = 1
# if act == 'P1' : new_act = 0
# awrite_val(cpu,new_act,'')
time.sleep(1.0/polls_per_sec)
|
You can figure out what the hex code is for the hotkey you want to bind to by doing a watch on /proc/acpi/toshiba/keys and hitting the key you care about. Beyond that you'll need to learn some python basics and maybe some xmms command line tools to get it to do what you want. _________________ Underwater photo gallery
New pictures, Oct 2005 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
TL_Amitola n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/1092829614043bf4f92442.jpg)
Joined: 25 Jan 2004 Posts: 69 Location: Utah, USA
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|