DEV Community

Disha Khanapurkar
Disha Khanapurkar

Posted on

There’s a Snarky Dead Guy Trapped in My Laptop, and He Has Opinions About My Stack Trace!

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine

What I Built

Meet PolterPaste — a desktop ghost that lives rent-free in your operating system's clipboard.

Every time you copy a piece of text, code, or a messy stack trace, a snarky 19th-century aristocrat named Lord Bartholomew Blackwood pops up on your screen to judge your choices with effortless Victorian sarcasm. No old dusty English—just sharp, witty roasts delivered via a semi-transparent, gothic floating UI.


Demo

Suppose you make a small error and copy it to perhaps debug it:

No one can escape Lord Bartholomew's perfect taunt:

Well, if you try to reason out, he's got a witty replies up his sleeve!


Code

Here is the core engine behind the haunting. You can check out the full repository on GitHub: [https://github.com/tan-byte/lord_bartholomew/]

import time
import tkinter as tk
import pyperclip
from google import genai

# Initialize the Gemini client with your API key
client = genai.Client(api_key="YOUR_ACTUAL_API_KEY_HERE")

def get_ghost_commentary(copied_text):
    # The snarky Victorian persona prompt
    prompt = (
        "You are Lord Bartholomew Blackwood, a snarky Victorian ghost trapped "
        "inside this laptop. You speak with crisp, effortless aristocratic "
        "sarcasm—sharp, witty English that cuts deep. Look at what the mortal "
        "just copied and give a 1-to-2 sentence biting, theatrical roast of their "
        "code or life choices. Keep it punchy and utterly unimpressed. Text copied: "
        f"'{copied_text}'"
    )

    try:
        # The crucial AI interaction point using the official Google GenAI SDK
        response = client.models.generate_content(
            model="gemma-2-9b-it",
            contents=prompt,
        )
        return response.text.strip() if response.text else "The ghost stares in silence."
    except Exception as e:
        return f"The spirit's connection to the cloud severed: {e}"
Enter fullscreen mode Exit fullscreen mode

How I Built It

PolterPaste brings together three simple layers to create the illusion of a haunted machine:

  1. The Clipboard Watcher: Built using pyperclip running in a lightweight background while loop that polls clipboard changes every 1.5 seconds.

  2. The Intelligence Layer: Powered by the official google-genai SDK (gemini-3.8-flash), which transforms raw, boring copied text into personalized theatrical roasts using structured system instructions.

  3. The Gothic UI: A custom, borderless, semi-transparent floating window built with Python's native tkinter featuring dark styling (#0d0d0d), a scrollbar for longer rants, and a click-to-dismiss behavior so it stays until you acknowledge your digital sins.

Why Does Open Innovation Matter?

Building lightweight desktop agents like this highlights why accessible, open-developer tooling is so powerful. Being able to plug a cutting-edge cloud model directly into local system utilities like the clipboard with just a few lines of Python opens up endless possibilities for creative, whimsical, and borderline unhinged developer tools that completely change how we interact with our operating systems!

Prize Categories

Best use of Gemma
Ghost in the Machine

P.S: The best response so far:

Top comments (0)