15 lines
462 B
Python
15 lines
462 B
Python
import asyncio
|
|
import os
|
|
from evdev import InputDevice, categorize, ecodes
|
|
|
|
dev = InputDevice('/dev/input/event0')
|
|
|
|
async def scanner(dev):
|
|
async for ev in dev.async_read_loop():
|
|
if ev.type == ecodes.EV_KEY:
|
|
if ev.code in [ecodes.KEY_PLAYCD, ecodes.KEY_PAUSECD] and ev.value == 0:
|
|
print("Play/Pause Pressed")
|
|
os.system("pactl set-sink-mute @DEFAULT_SINK@ toggle")
|
|
|
|
loop = asyncio.get_event_loop()
|
|
loop.run_until_complete(scanner(dev)) |