import gradio as gr import psutil import datetime # ─────────────────────────────── # LocalDesk Web Prototype # Author: Justin Strange # License: Commons Clause + MIT # ─────────────────────────────── clipboard_history = [] def add_to_clipboard(text): """Simulate a clipboard manager""" if text.strip(): clipboard_history.append(f"{datetime.datetime.now():%H:%M:%S} {text}") return "\n".join(clipboard_history[-10:]) def get_system_stats(): """Return simple system info""" cpu = psutil.cpu_percent(interval=0.2) mem = psutil.virtual_memory() return f"CPU Usage: {cpu}%\nMemory Usage: {mem.percent}%" def write_note(title, content): """Pretend-save a note""" if not title: title = f"Untitled-{datetime.datetime.now():%H%M%S}" return f"🗒️ Saved: {title}\n\n{content}" with gr.Blocks(theme=gr.themes.Soft(primary_hue="green")) as demo: gr.Markdown( "# 🖥️ LocalDesk (Web Prototype)\n" "### Created by Justin Strange\n" "Offline-first utility suite prototype built with Gradio" ) with gr.Tab("Clipboard Manager"): clip_in = gr.Textbox(label="Copy text here") clip_out = gr.Textbox(label="Clipboard History", lines=10) clip_btn = gr.Button("Add to Clipboard") clip_btn.click(add_to_clipboard, inputs=clip_in, outputs=clip_out) with gr.Tab("Notes"): note_title = gr.Textbox(label="Note Title") note_body = gr.Textbox(label="Note Content", lines=8) note_out = gr.Textbox(label="Saved Note") save_btn = gr.Button("Save Note") save_btn.click(write_note, inputs=[note_title, note_body], outputs=note_out) with gr.Tab("System Monitor"): sys_box = gr.Textbox(label="System Stats", lines=3) refresh = gr.Button("Refresh") refresh.click(get_system_stats, outputs=sys_box) demo.launch()