50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
import socket
|
|
import getopt
|
|
import sys
|
|
import subprocess
|
|
|
|
def connect(host, port = 5000):
|
|
|
|
# instantiate
|
|
client_socket.connect((host, port)) # connect to the server
|
|
|
|
def disconnect():
|
|
client_socket.close() # close the connection
|
|
|
|
def send(data):
|
|
client_socket.send(data.encode()) # send message
|
|
|
|
def helpmenu():
|
|
print("Options:")
|
|
print("-h show help")
|
|
print("-s <color> set static color in hex")
|
|
print("-v visualizer()")
|
|
|
|
def visualizer():
|
|
with subprocess.Popen(["cava", "-p", "./config"], stdout=subprocess.PIPE) as cava:
|
|
print(cava.stdout.readlines())
|
|
|
|
|
|
|
|
def main(argv):
|
|
try:
|
|
opts, args = getopt.getopt(argv, "s:vh")
|
|
except getopt.GetoptError:
|
|
print(sys.argv[0], "invalid option")
|
|
print("Try", sys.argv[0], "-h for help")
|
|
sys.exit(1)
|
|
|
|
for opt, arg in opts:
|
|
if opt == "-h":
|
|
helpmenu()
|
|
sys.exit()
|
|
elif opt == "-s":
|
|
send(arg)
|
|
elif opt == "-v":
|
|
visualizer()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
client_socket = socket.socket()
|
|
connect("192.168.188.61")
|
|
main(sys.argv[1:]) |