00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 """
00013
00014 Copyright (c) 2007, Gizmo Daemon Team
00015 Licensed under the Apache License, Version 2.0 (the "License");
00016 you may not use this file except in compliance with the License.
00017 You may obtain a copy of the License at
00018
00019 http://www.apache.org/licenses/LICENSE-2.0
00020
00021 Unless required by applicable law or agreed to in writing, software
00022 distributed under the License is distributed on an "AS IS" BASIS,
00023 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024 See the License for the specific language governing permissions and
00025 limitations under the License.
00026
00027 """
00028
00029
00030
00031
00032
00033 from GizmoDaemon import *
00034 from GizmoScriptRunningApplication import *
00035 import subprocess
00036
00037 ENABLED = True
00038 VERSION_NEEDED = 3.2
00039 INTERESTED_CLASSES = [GizmoEventClass.Standard]
00040 INTERESTED_APPLICATION = "amarokapp"
00041
00042
00043
00044
00045
00046 class KeyboardAmarok(GizmoScriptRunningApplication):
00047 """
00048 Amarok Fancy Keyboard Event Mapping
00049 """
00050
00051
00052
00053
00054
00055 def onDeviceEvent(self, Event, Gizmo = None):
00056 """
00057 Called from Base Class' onEvent method.
00058 See GizmodDispatcher.onEvent documention for an explanation of this function
00059 """
00060
00061
00062 if Event.Code == GizmoKey.KEY_VOLUMEUP:
00063 Gizmod.DefaultMixerVolume.VolumePlayback = Gizmod.DefaultMixerVolume.VolumePlayback + 1
00064 return True
00065 elif Event.Code == GizmoKey.KEY_VOLUMEDOWN:
00066 Gizmod.DefaultMixerVolume.VolumePlayback = Gizmod.DefaultMixerVolume.VolumePlayback - 1
00067 return True
00068 elif Event.Code == GizmoKey.KEY_MUTE:
00069 Gizmod.toggleMuteAllCards()
00070 return True
00071 elif Event.Code == GizmoKey.KEY_NEXTSONG:
00072 subprocess.Popen(["amarok", "--next"])
00073 return True
00074 elif Event.Code == GizmoKey.KEY_NEXT:
00075 subprocess.Popen(["amarok", "--next"])
00076 return True
00077 elif Event.Code == GizmoKey.KEY_STOP:
00078 subprocess.Popen(["amarok", "--stop"])
00079 return True
00080 elif Event.Code == GizmoKey.KEY_PREVIOUSSONG:
00081 subprocess.Popen(["amarok", "--previous"])
00082 return True
00083 elif Event.Code == GizmoKey.KEY_PREVIOUS:
00084 subprocess.Popen(["amarok", "--previous"])
00085 return True
00086 elif Event.Code == GizmoKey.KEY_PAUSE:
00087 subprocess.Popen(["amarok", "--play-pause"])
00088 return True
00089 elif Event.Code == GizmoKey.KEY_PLAYPAUSE:
00090 subprocess.Popen(["amarok", "--play-pause"])
00091 return True
00092 elif Event.Code == GizmoKey.KEY_PAUSECD:
00093 subprocess.Popen(["amarok", "--play-pause"])
00094 return True
00095 elif Event.Code == GizmoKey.KEY_PLAY:
00096 subprocess.Popen(["amarok", "--play-pause"])
00097 return True
00098 elif Event.Code == GizmoKey.KEY_PLAYCD:
00099 subprocess.Popen(["amarok", "--play-pause"])
00100 return True
00101 else:
00102
00103 return False
00104
00105
00106
00107
00108
00109 def __init__(self):
00110 """
00111 Default Constructor
00112 """
00113
00114 GizmoScriptRunningApplication.__init__(self, ENABLED, VERSION_NEEDED, INTERESTED_CLASSES, INTERESTED_APPLICATION)
00115
00116
00117
00118
00119
00120
00121 KeyboardAmarok()