Run black on all Python scripts!
This commit is contained in:
parent
fb6cfce656
commit
cd9cbcaa28
30 changed files with 1027 additions and 704 deletions
|
@ -9,14 +9,16 @@ from Xlib.protocol import rq
|
|||
|
||||
KEY = XK.XK_F7
|
||||
|
||||
|
||||
def mute(state):
|
||||
with pulsectl.Pulse('list-source') as pulse:
|
||||
with pulsectl.Pulse("list-source") as pulse:
|
||||
for source in pulse.source_list():
|
||||
if source.port_active:
|
||||
if source.mute != state:
|
||||
pulse.mute(source, state)
|
||||
print(f"{source.name} {'un' if not state else ''}muted")
|
||||
|
||||
|
||||
mute(True)
|
||||
|
||||
local_dpy = display.Display()
|
||||
|
@ -36,7 +38,8 @@ def record_callback(reply):
|
|||
data = reply.data
|
||||
while len(data):
|
||||
event, data = rq.EventField(None).parse_binary_value(
|
||||
data, record_dpy.display, None, None)
|
||||
data, record_dpy.display, None, None
|
||||
)
|
||||
|
||||
if event.type in [X.KeyPress, X.KeyRelease]:
|
||||
keysym = local_dpy.keycode_to_keysym(event.detail, 0)
|
||||
|
@ -45,29 +48,32 @@ def record_callback(reply):
|
|||
if keysym == KEY:
|
||||
mute(event.type == X.KeyRelease)
|
||||
|
||||
|
||||
# Check if the extension is present
|
||||
if not record_dpy.has_extension("RECORD"):
|
||||
print("RECORD extension not found")
|
||||
sys.exit(1)
|
||||
r = record_dpy.record_get_version(0, 0)
|
||||
print("RECORD extension version %d.%d" %
|
||||
(r.major_version, r.minor_version))
|
||||
print("RECORD extension version %d.%d" % (r.major_version, r.minor_version))
|
||||
|
||||
# Create a recording context; we only want key and mouse events
|
||||
ctx = record_dpy.record_create_context(
|
||||
0,
|
||||
[record.AllClients],
|
||||
[{
|
||||
'core_requests': (0, 0),
|
||||
'core_replies': (0, 0),
|
||||
'ext_requests': (0, 0, 0, 0),
|
||||
'ext_replies': (0, 0, 0, 0),
|
||||
'delivered_events': (0, 0),
|
||||
'device_events': (X.KeyPress, X.MotionNotify),
|
||||
'errors': (0, 0),
|
||||
'client_started': False,
|
||||
'client_died': False,
|
||||
}])
|
||||
[
|
||||
{
|
||||
"core_requests": (0, 0),
|
||||
"core_replies": (0, 0),
|
||||
"ext_requests": (0, 0, 0, 0),
|
||||
"ext_replies": (0, 0, 0, 0),
|
||||
"delivered_events": (0, 0),
|
||||
"device_events": (X.KeyPress, X.MotionNotify),
|
||||
"errors": (0, 0),
|
||||
"client_started": False,
|
||||
"client_died": False,
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
# Enable the context; this only returns after a call to record_disable_context,
|
||||
# while calling the callback function in the meantime
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue