File size: 2,012 Bytes
1db9199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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()