Skip to content

Instantly share code, notes, and snippets.

@kolbanidze
Created January 8, 2024 14:58
Show Gist options
  • Select an option

  • Save kolbanidze/ec9bf0c7383e869fb62674e10806107a to your computer and use it in GitHub Desktop.

Select an option

Save kolbanidze/ec9bf0c7383e869fb62674e10806107a to your computer and use it in GitHub Desktop.
Stupid wake on lan for Linux with GUI
# Stupid Wake On Lan
# Linux only. Requires package 'wol' to be installed (path to WOL binary can be configured in WOL_PATH)
from customtkinter import CTk, CTkButton, CTkLabel, CTkEntry
from dotenv import load_dotenv, set_key
from os import getenv, system
WOL_PATH = "/usr/bin/wol"
class App(CTk):
def __init__(self):
super().__init__()
self.title("Stupid WOL")
load_dotenv()
mac = getenv("MAC")
if mac is None:
mac = ''
mac_title = CTkLabel(self, text="Enter MAC:")
mac_title.pack(padx=10, pady=3)
mac_entry = CTkEntry(self)
mac_entry.insert(0, mac)
mac_entry.pack(padx=10, pady=3)
save = CTkButton(self, text="Save", command=lambda: self.save(mac_entry.get()))
save.pack(padx=10, pady=3)
wake = CTkButton(self, text="WAKE", height=100, command=lambda: self.wake(mac_entry.get()))
wake.pack(padx=10, pady=(30, 5))
def save(self, mac):
set_key('.env', "MAC", mac)
def wake(self, mac):
"""Using /usr/bin/wol instead of using WOL from PATH for security reasons :)"""
system(f"{WOL_PATH} {mac}")
if __name__ == "__main__":
App().mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment