Subversion Repositories mmkeyboard2k

Compare Revisions

Ignore whitespace Rev 9 → Rev 10

/trunk/plugins/gtkosd.py
67,6 → 67,9
else:
text = str(self.text)
if text is None:
return
glib.idle_add(self.other, text, self.type)
@classmethod
/trunk/plugins/acpi.py
New file
0,0 → 1,66
# MMKeyboard2k ACPI Control Plugin
# Copyright (C) 2011 Jan Janech
 
# 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 <http://www.gnu.org/licenses/>.
 
import os
import os.path
import subprocess
 
class Plugin:
options = ('property', 'value')
MIN_BRIGHTNESS=0
try:
MAX_BRIGHTNESS=int(file('/sys/class/backlight/acpi_video0/max_brightness', 'r').read())
except:
MAX_BRIGHTNESS=0
def __init__(self, property, value, text = 'brightness'):
self.property = property.lower()
self.text = text
if value[0] == '+':
self.value = ('+', int(value[1:]))
elif value[0] == '-':
self.value = ('-', int(value[1:]))
else:
self.value = ('=', int(value))
def __repr__(self):
return '<acpi.Plugin %s=%r>'%(self.property, self.value)
def __call__(self):
if self.property == 'brightness':
if self.MAX_BRIGHTNESS <= self.MIN_BRIGHTNESS:
return None
val = old_val = int(file('/sys/class/backlight/acpi_video0/brightness', 'r').read())
if self.value[0] == '+':
val += self.value[1]
elif self.value[0] == '-':
val -= self.value[1]
else:
val = self.value[1]
if val < self.MIN_BRIGHTNESS:
val = self.MIN_BRIGHTNESS
if val > self.MAX_BRIGHTNESS:
val = self.MAX_BRIGHTNESS
if val != old_val:
file('/sys/class/backlight/acpi_video0/brightness', 'w').write(str(val))
return self.text + '\n' + str(val)
/trunk/plugins/osd.py
73,6 → 73,9
else:
text = str(self.text)
if text is None:
return
if self.type == 'text':
for id, line in enumerate([""]*(self.maxlines-self.linecount)+([""]*self.linecount+text.splitlines())[-self.linecount:]):
self.osd.display(line, line = id)
/trunk/config/keyboard.conf
7,3 → 7,5
KeySym VolumeSub = 122
KeySym Media = 242
KeySym DVD = 241
KeySym BrightnessDown = 232
KeySym BrightnessUp = 233
/trunk/config/categories/brightness.conf
New file
0,0 → 1,15
[Key BrightnessDown]
[Plugin Acpi]
# Alsa.Text = {mute.png}Mute/{volume.png}Unmute
Property = brightness
Value = -6
[End]
[End]
 
[Key BrightnessUp]
[Plugin Acpi]
# Alsa.Text = {mute.png}Mute/{volume.png}Unmute
Property = brightness
Value = +6
[End]
[End]
/trunk/config/config.conf
6,3 → 6,4
#[Include categories/mpd.conf]
[Include categories/volume.conf]
[Include categories/mplayer.conf]
[Include categories/brightness.conf]
/trunk/shortcuts.py
44,6 → 44,7
self.roots = [display.screen(no).root for no in xrange(display.screen_count())]
self.display = self.roots[0].display
self.origDisplay = display
# self.root = display.screen().root
# self.display = self.root.display
58,7 → 59,9
elif key.isdigit():
key = int(key)
else:
key = self.display.keysym_to_keycode(XK.string_to_keysym(key))
key = self.origDisplay.keysym_to_keycode(XK.string_to_keysym(key))
if key == 0:
raise Exception
return (modifier, key)
def __get_active_app(self):