40 lines
801 B
Python
40 lines
801 B
Python
import tkinter as tk
|
|
import socket
|
|
import sys
|
|
|
|
PORT = 65432
|
|
|
|
|
|
def check_if_already_running():
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
try:
|
|
sock.bind(("127.0.0.1", PORT))
|
|
except OSError:
|
|
print("Already running.")
|
|
sys.exit(0)
|
|
return sock
|
|
|
|
|
|
def exit_app(event=None):
|
|
root.destroy()
|
|
|
|
|
|
def bind_input_events():
|
|
root.bind("<Motion>", exit_app)
|
|
root.bind("<Key>", exit_app)
|
|
root.bind("<Button>", exit_app)
|
|
|
|
|
|
lock_socket = check_if_already_running()
|
|
|
|
root = tk.Tk()
|
|
root.title("BlackScreenApp") # Needed for wmctrl or hyprctl targeting
|
|
root.configure(background="black")
|
|
root.attributes("-fullscreen", True) # Try fullscreen directly
|
|
root.config(cursor="none")
|
|
|
|
root.after(500, bind_input_events)
|
|
root.mainloop()
|
|
|
|
lock_socket.close()
|