summaryrefslogtreecommitdiff
path: root/plugins/Shortcuts.py
blob: 99cf6d64bd25a5243fa9a9e24cc5fffba6f01446 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from PyQt4 import QtGui, QtCore

from Xlib.display import Display
from Xlib import X
from Xlib.XK import *
from thread import start_new_thread

from clPlugin import Plugin
from clSettings import settings


class pluginShortcuts(Plugin):
	display=None
	root=None
	def __init__(self, winMain):
		global keycodes
		Plugin.__init__(self, winMain, 'Shortcuts')

	def _load(self):
		self.disp=Display()
		self.root=self.disp.screen().root
		self.root.change_attributes(event_mask=X.KeyPressMask)
		#for keycode,name in enumerate(keycodes):
			#print keycode
			#self.root.grab_key(keycode, X.AnyModifier, 0, X.GrabModeAsync, X.GrabModeAsync)
		start_new_thread(self.keyHandler, (None,))
	
	def err(self,param=None,param2=None):
		print param
		print param2

	def getInfo(self):
		return "Control playing using shortcuts."

	def _getSettings(self):
		return []
		return [
			['shortcuts.playpauze', 'Play/pauze', 'Key to start playing/pauze.', QtGui.QLineEdit(settings.get('shortcuts.playpauze', 'Win+Home'))],
		]
	def afterSaveSettings(self):
		pass
	
	def keyHandler(self, emptyParam):
		while 1:
			event=self.root.display.next_event()
			keycode=event.detail
			print keycode