ClipSync/client.py

50 lines
1.1 KiB
Python

import pyperclip
import socketio
import reauests
import os
import sys
import subprocess
import zc.lockfile
# standard Python
# to put in a conf file
ip = 'simailadjalim.fr'
port = "9564"
hostname = "WarMachine"
username = "neotaku67"
password = "un bon mot de passe de prefererance mais en sah tant qu'il est hashe ca passe"
"""
This script is a daemon that, on event, send and sync the clipboard with a distant one
"""
ip = f"http://{ip}:{port}/"
sio = socketio.Client()
sio.connect(ip)
print("[Debug] Connected to Server .w.")
def sendSystemNotification(title:str,content:str):
"""
Une fonction pour 1. rendre le truc plus secure et
eviter que thomas face des rce sur mon pc .w. lmao
"""
subprocess.run(["notify-send",title,content])
@sio.event
def NotificationUpdate(data):
content = data["content"]
clipCmd = f'echo {content} | xclip'
print(f"[ClipEvent] received data from ")
os.system(clipCmd)
@sio.event
def ClipboardUpdate(data):
title, content = data["title"], data["content"]
command = f'notify-send "{title}" "{content}"'
print(command)
os.system(command)
sio.wait()