The Following 51 Users Say Thank You to wolke For This Useful Post: | ||
AB3S, afaq, Arie, aRTee, banong, captainofiron, cddiede, Crabstick, DA5, Dousan, elemental, et3rnal, eviloar, ezameht, F2thaK, flopjoke, guillermorojaz, Hacker, HtheB, ibrakalifa, imaginaryenemy, Iryus, jhwan, Jordi, Kejml, ladoga, late88, leoniedelt, lorenzo, Maj3stic, MaKenZi, MFaroTusino, mpy, OVK, pelago, psychEinside, ranbaxy, RIscRIpt, Roth, Schturman, shanttu, Soppa, toebaer, tonyhuynh, trompkins, ujwalsoni, Wikiwide, wokawoka, wook_sf, YavkatA |
|
2012-02-23
, 20:16
|
Posts: 986 |
Thanked: 1,526 times |
Joined on Jul 2010
|
#2
|
def getActions(): return [ Action(volup, cond=appOnTop("camera-ui"), action=cmd("xresponse -d 820x240,820x240 -w 1")), Action(volup, cond=screenLocked, action=cmd( "killall mplayer || " + "find ~/MyDocs/Music -iname *.mp3 -print0 | " + "xargs -0 mplayer")) ])
The Following 5 Users Say Thank You to wolke For This Useful Post: | ||
|
2012-02-23
, 20:18
|
Posts: 986 |
Thanked: 1,526 times |
Joined on Jul 2010
|
#3
|
#!/usr/bin/python #n9-button-monitor v0.1 #Copyright 2012 Elliot Wolk #based on: ##### # Ye Olde Camerra Hack - Another fine Harmattan Hack Powered by Python(tm)! # 2012-01-12; Thomas Perl <thp.io/about> ##### # 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. # from QmSystem import * from PySide.QtGui import * from PySide.QtDeclarative import * import sys import os import subprocess import re ############### ############### ############### def getActions(): return ([ None , Action(volup, cond=appOnTop("camera-ui"), action=cmd("camera-click")) , Action(volup, cond=screenLocked, action=cmd("klomp-cmd pause")) , Action(voldn, cond=screenLocked, action=cmd("klomp-cmd next")) ]) def readProc(cmdarr): out, err = subprocess.Popen(cmdarr, stdout=subprocess.PIPE).communicate() return out def screenLocked(): return "locked\n" == readProc(['lock', '-g']) def screenUnlocked(): return not screenLocked() def appOnTop(app): return lambda: isAppOnTop(app) def isAppOnTop(app): winId = readProc(["xprop", "-root", "_NET_ACTIVE_WINDOW"]) [40:] winCmd = readProc(["xprop", "-id", winId, "WM_COMMAND"]) [24:-4] return app in winCmd def cmd(cmd): return lambda: runcmd(cmd) def runcmd(cmd): print 'running cmd: "' + cmd + '"' subprocess.Popen(['bash', '-c', cmd]) ############### ############### ############### evtPressed = 'pressed' evtRepeated = 'repeated' evtReleased = 'released' stateOn = 2 stateOff = 0 power = 20 volup = 2 voldn = 3 class Action(): def __init__(self, key, event=evtPressed, action=None, cond=None, stop=True): self.key = key self.event = event self.action = action self.cond = cond self.stop = stop keysPressed = set() actions = getActions() def keyEvent(key, state): event = None if state == stateOn: if key not in keysPressed: event = evtPressed else: event = evtRepeated elif state == stateOff: event = evtReleased if state == stateOn: keysPressed.add(key) elif state == stateOff: keysPressed.discard(key) for action in actions: if action != None and action.key == key and action.event == event: if action.cond == None or action.cond(): action.action() if action.stop: return def main(): app = QApplication(sys.argv) keys = QmKeys() keys.keyEvent.connect(keyEvent) app.exec_() if __name__ == "__main__": sys.exit(main())
|
2012-02-23
, 20:22
|
Posts: 986 |
Thanked: 1,526 times |
Joined on Jul 2010
|
#4
|
# Description of the script, mandatory description "Startup script for n9-button-monitor" # Author e-mail address, mandatory author "elliot.wolk@gmail.com" start on filesystem or runlevel [2345] stop on runlevel [!2345] #none: stdout to /dev/null #output: direct stdout to console console output #if application exits, restart max 3 times within 300 secs respawn #respawn limit 3 300 exec /usr/bin/aegis-exec -s -u user bash -c 'DISPLAY=:0 n9-button-monitor'
The Following 3 Users Say Thank You to wolke For This Useful Post: | ||
|
2012-02-24
, 09:21
|
Posts: 188 |
Thanked: 90 times |
Joined on Sep 2006
|
#5
|
|
2012-02-24
, 10:02
|
|
Posts: 4,365 |
Thanked: 2,467 times |
Joined on Jan 2010
@ Australia Mate
|
#6
|
The Following User Says Thank You to F2thaK For This Useful Post: | ||
|
2012-02-24
, 18:45
|
Posts: 986 |
Thanked: 1,526 times |
Joined on Jul 2010
|
#7
|
|
2012-02-24
, 18:51
|
Posts: 986 |
Thanked: 1,526 times |
Joined on Jul 2010
|
#8
|
Thanks for sharing, I have to think on how I can used this for my wife's N9.
|
2012-03-27
, 02:00
|
Posts: 1,539 |
Thanked: 1,604 times |
Joined on Oct 2011
@ With my N9
|
#10
|
Tags |
harmattan, nokia n9 |
|
N9 Button Monitor | mt-toggle for n9bm
Highlights:
Features:
Installation:
dpkg --force-depends -i n9-button-monitor_*.deb
#force-depends installs dependencies, like apt-get -f install
https://github.com/teleshoes/n9-button-monitor
config file is located at /home/user/.config/n9-button-monitor.conf
Default Config {this gets created if there is no file}
feel generous?
{or send money via paypal to elliot.wolk@gmail.com}
Last edited by wolke; 2013-08-20 at 03:06. Reason: sourceforge => openrepos