-
-
Save hawkrives/3c0a3d2ad6bf90c74a6dfb17f41bfba2 to your computer and use it in GitHub Desktop.
Act upon media keys in a Mac under OSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import subprocess | |
| # PyObjC-related imports | |
| from AppKit import NSApplication, NSSystemDefined, NSApplicationActivationPolicyProhibited | |
| from PyObjCTools import AppHelper | |
| KEY_UP = 11 | |
| class KeySocketApp(NSApplication): | |
| repeated = False | |
| def sendEvent_(self, event): | |
| if event.type() is NSSystemDefined and event.subtype() is 8: | |
| data = event.data1() | |
| keyCode = (data & 0xFFFF0000) >> 16 | |
| keyFlags = (data & 0x0000FFFF) | |
| keyState = (keyFlags & 0xFF00) >> 8 | |
| keyRepeat = keyFlags & 0x1 | |
| if keyRepeat and keyState is not KEY_UP: | |
| if keyCode == 20: | |
| self.repeated = True | |
| print "prev" | |
| subprocess.call(['cmus-remote', '-k', '-10']) | |
| elif keyCode == 19: | |
| self.repeated = True | |
| print "forward" | |
| subprocess.call(['cmus-remote', '-k', '+10']) | |
| if keyState is KEY_UP: | |
| if self.repeated: | |
| self.repeated = False | |
| elif keyCode == 20: | |
| print "PREV" | |
| subprocess.call(['cmus-remote', '-r']) | |
| elif keyCode == 16: | |
| print "PLAY" | |
| subprocess.call(['cmus-remote', '-u']) | |
| elif keyCode == 19: | |
| print "FORWARD" | |
| subprocess.call(['cmus-remote', '-n']) | |
| if __name__ == '__main__': | |
| app = KeySocketApp.sharedApplication() | |
| app.setActivationPolicy_(NSApplicationActivationPolicyProhibited) | |
| AppHelper.runEventLoop() |
I've been on the hunt for the right payment solution and, let me tell you, it's been a journey. It felt like I was constantly running into roadblocks until I discovered this one platform. The ease it brought to my transaction management was like a breath of fresh air. The user interface? So straightforward and easy to navigate. But what sealed the deal for me was their Whit-Label Card Issuing service. It drastically improved my financial operations, delivering a level of efficiency I didn't even know I could achieve. If you find yourself in a similar situation, I highly recommend checking it out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recently, I found myself with a lot of spare time during the evenings since I started working from home. I was looking for a way to unwind that was both entertaining and could offer a little thrill. That's how I stumbled upon site with its speed au games. The site has an impressive variety of games, from slots to table games, and their promotions are really something—there are welcome bonuses, weekly free spins, and even a VIP program. What I really like is their fast withdrawal system, it's convenient and lets me access my winnings quickly.