mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-02-02 16:19:10 +00:00
add deamon mode demo
This commit is contained in:
25
example_deamon_send.py
Normal file
25
example_deamon_send.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import socket
|
||||
from aln import enums
|
||||
|
||||
SOCKET_PATH = "/tmp/airpods_daemon.sock"
|
||||
|
||||
def send_command(command):
|
||||
"""Send a command to the daemon via UNIX domain socket."""
|
||||
try:
|
||||
# Create a socket connection to the daemon
|
||||
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
client_socket.connect(SOCKET_PATH)
|
||||
|
||||
# Send the command
|
||||
client_socket.send(command)
|
||||
print(f"Sent command: {command}")
|
||||
|
||||
# Close the connection
|
||||
client_socket.close()
|
||||
except Exception as e:
|
||||
print(f"Error communicating with daemon: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Convert the command (enum) to bytes and send it to the daemon
|
||||
command = enums.SET_NOISE_CANCELLATION_OFF
|
||||
send_command(command)
|
||||
Reference in New Issue
Block a user