Add 16x16 titlebar app icons, XP Desktop icons & Recycle Bin, Screen Savers, and ClipBook Viewer

This commit is contained in:
Carsten
2026-11-27 20:33:47 +01:00
parent 9735f28386
commit 697b7daff5
11 changed files with 845 additions and 12 deletions
+126
View File
@@ -0,0 +1,126 @@
#!/usr/bin/env python3
"""Native Windows XP ClipBook Viewer (cliphist clipboard history)."""
import os
import subprocess
import sys
os.environ.setdefault("DCONF_PROFILE", "/home/carsten/.config/hypr/dconf/profile")
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
from gi.repository import Gtk, Gdk
class XPClipBook(Gtk.Window):
def __init__(self):
super().__init__(title="ClipBook Viewer")
self.set_wmclass("xp-clipbook", "xp-clipbook")
self.set_default_size(450, 360)
self.set_border_width(8)
root = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
self.add(root)
lbl = Gtk.Label(label="Clipboard History (double-click or press Enter to copy):", xalign=0)
root.pack_start(lbl, False, False, 0)
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
self.store = Gtk.ListStore(str, str) # display_text, raw_line
self.tv = Gtk.TreeView(model=self.store)
self.tv.set_headers_visible(False)
r = Gtk.CellRendererText()
r.set_property("ellipsize", 3) # END
col = Gtk.TreeViewColumn("Entry", r, text=0)
self.tv.append_column(col)
self.tv.connect("row-activated", lambda *_: self.on_copy(None))
sw.add(self.tv)
root.pack_start(sw, True, True, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
clear_btn = Gtk.Button.new_with_label("Clear All")
clear_btn.connect("clicked", self.on_clear)
row.pack_start(clear_btn, False, False, 0)
del_btn = Gtk.Button.new_with_label("Delete")
del_btn.connect("clicked", self.on_delete)
row.pack_start(del_btn, False, False, 0)
close_btn = Gtk.Button.new_with_label("Close")
close_btn.set_size_request(76, 24)
close_btn.connect("clicked", lambda *_: Gtk.main_quit())
row.pack_end(close_btn, False, False, 0)
copy_btn = Gtk.Button.new_with_label("Copy")
copy_btn.set_size_request(76, 24)
copy_btn.connect("clicked", self.on_copy)
row.pack_end(copy_btn, False, False, 0)
root.pack_end(row, False, False, 0)
self.load_entries()
self.connect("key-press-event", self.on_key)
self.connect("destroy", Gtk.main_quit)
def load_entries(self):
self.store.clear()
try:
out = subprocess.check_output(["cliphist", "list"], text=True, timeout=2.0)
for line in out.splitlines()[:80]:
if "\t" in line:
_, preview = line.split("\t", 1)
else:
preview = line
self.store.append([preview.strip()[:140], line])
if len(self.store) > 0:
self.tv.get_selection().select_path(Gtk.TreePath.new_first())
except Exception:
pass
def on_key(self, _w, ev):
if ev.keyval == Gdk.KEY_Escape:
Gtk.main_quit()
return True
if ev.keyval in (Gdk.KEY_Return, Gdk.KEY_KP_Enter):
self.on_copy(None)
return True
if ev.keyval == Gdk.KEY_Delete:
self.on_delete(None)
return True
return False
def on_copy(self, _btn):
m, it = self.tv.get_selection().get_selected()
if not it:
return
raw = m[it][1]
p1 = subprocess.Popen(["cliphist", "decode"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
decoded, _ = p1.communicate(raw.encode("utf-8"))
p2 = subprocess.Popen(["wl-copy"], stdin=subprocess.PIPE)
p2.communicate(decoded)
Gtk.main_quit()
def on_delete(self, _btn):
m, it = self.tv.get_selection().get_selected()
if not it:
return
raw = m[it][1]
p = subprocess.Popen(["cliphist", "delete"], stdin=subprocess.PIPE)
p.communicate(raw.encode("utf-8"))
self.load_entries()
def on_clear(self, _btn):
subprocess.run(["cliphist", "wipe"], check=False)
self.load_entries()
def main():
win = XPClipBook()
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Executable
+339
View File
@@ -0,0 +1,339 @@
#!/usr/bin/env python3
"""Authentic Windows XP Desktop Icons + Recycle Bin + Right-Click Menu daemon (BACKGROUND layer)."""
import fcntl
import os
import shutil
import signal
import subprocess
import sys
import time
from pathlib import Path
os.environ.setdefault("DCONF_PROFILE", "/home/carsten/.config/hypr/dconf/profile")
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
gi.require_version("GdkPixbuf", "2.0")
gi.require_version("GtkLayerShell", "0.1")
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GtkLayerShell, Pango
LOCK_PATH = f"/run/user/{os.getuid()}/xp-desktop.lock"
TRASH_FILES = Path.home() / ".local/share/Trash/files"
TRASH_INFO = Path.home() / ".local/share/Trash/info"
DESKTOP_DIR = Path.home() / "Desktop"
SOUND_SCRIPT = "/home/carsten/.config/hypr/scripts/xp-sound.sh"
DESKTOP_CSS = b"""
window#xp-desktop-win {
background-color: transparent;
}
.xp-desk-item {
background-color: transparent;
border: 1px solid transparent;
border-radius: 2px;
padding: 5px 4px 4px 4px;
min-width: 74px;
}
.xp-desk-item.selected {
background-color: rgba(49, 106, 197, 0.55);
border: 1px dotted rgba(255, 255, 255, 0.85);
}
.xp-desk-label {
font-family: "Tahoma", sans-serif;
font-size: 8.5pt;
color: #FFFFFF;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.92), 0px 1px 2px rgba(0, 0, 0, 0.85);
}
.xp-desk-item.selected .xp-desk-label {
background-color: #316AC5;
color: #FFFFFF;
text-shadow: none;
padding: 0px 2px;
}
"""
def launch(cmd):
subprocess.Popen(["hyprctl", "dispatch", "exec", cmd],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def trash_has_items():
try:
return TRASH_FILES.is_dir() and any(TRASH_FILES.iterdir())
except OSError:
return False
def empty_recycle_bin(on_done=None):
if not trash_has_items():
return
for d in (TRASH_FILES, TRASH_INFO):
if d.is_dir():
for p in d.iterdir():
try:
if p.is_dir() and not p.is_symlink():
shutil.rmtree(p)
else:
p.unlink()
except OSError:
pass
subprocess.Popen([SOUND_SCRIPT, "recycle"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if on_done:
on_done()
def load_icon_32(path_list):
for p in path_list:
if p and os.path.exists(p):
try:
return GdkPixbuf.Pixbuf.new_from_file_at_scale(p, 32, 32, True)
except Exception:
continue
return None
class XPDesktop(Gtk.Window):
def __init__(self):
super().__init__(type=Gtk.WindowType.TOPLEVEL)
self.set_name("xp-desktop-win")
self.set_decorated(False)
self.set_app_paintable(True)
visual = self.get_screen().get_rgba_visual()
if visual:
self.set_visual(visual)
GtkLayerShell.init_for_window(self)
GtkLayerShell.set_layer(self, GtkLayerShell.Layer.BACKGROUND)
GtkLayerShell.set_namespace(self, "xp-desktop")
for edge in (GtkLayerShell.Edge.TOP, GtkLayerShell.Edge.BOTTOM, GtkLayerShell.Edge.LEFT, GtkLayerShell.Edge.RIGHT):
GtkLayerShell.set_anchor(self, edge, True)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.BOTTOM, 30)
GtkLayerShell.set_exclusive_zone(self, -1)
GtkLayerShell.set_keyboard_mode(self, GtkLayerShell.KeyboardMode.NONE)
prov = Gtk.CssProvider()
prov.load_from_data(DESKTOP_CSS)
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), prov, Gtk.STYLE_PROVIDER_PRIORITY_USER)
self.bg_eb = Gtk.EventBox()
self.bg_eb.set_visible_window(False)
self.bg_eb.connect("button-press-event", self._on_bg_click)
self.add(self.bg_eb)
self.grid = Gtk.Grid()
self.grid.set_row_spacing(10)
self.grid.set_column_spacing(12)
self.grid.set_margin_top(14)
self.grid.set_margin_start(14)
self.grid.set_halign(Gtk.Align.START)
self.grid.set_valign(Gtk.Align.START)
self.bg_eb.add(self.grid)
self.item_boxes = []
self.selected_idx = -1
self.last_click = (-1, 0.0)
self.last_trash_state = None
self.active_menu = None
self.rebuild()
GLib.timeout_add(3000, self._poll_trash)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, lambda: (Gtk.main_quit(), False)[1])
def _build_items(self):
home = str(Path.home())
full = trash_has_items()
self.last_trash_state = full
trash_icon = (
"/usr/local/share/icons/luna/32x32/status/user-trash-full.png"
if full else
"/usr/local/share/icons/luna/32x32/places/user-trash.png"
)
items = [
{
"label": "My Documents",
"icons": ["/usr/local/share/icons/luna/32x32/places/folder-documents.png"],
"cmd": f"thunar {home}/Documents",
"kind": "system",
},
{
"label": "My Computer",
"icons": ["/usr/local/share/icons/luna/32x32/devices/computer.png"],
"cmd": f"thunar {home}",
"kind": "system",
},
{
"label": "My Network\nPlaces",
"icons": ["/usr/local/share/icons/luna/32x32/places/network-workgroup.png"],
"cmd": "nm-connection-editor",
"kind": "system",
},
{
"label": "Recycle Bin",
"icons": [trash_icon, "/usr/local/share/icons/luna/32x32/places/user-trash.png"],
"cmd": "thunar trash:///",
"kind": "trash",
},
{
"label": "Firefox",
"icons": [
"/snap/firefox/current/usr/lib/firefox/browser/chrome/icons/default/default32.png",
"/usr/local/share/icons/luna/32x32/apps/internet-web-browser.png",
],
"cmd": "firefox",
"kind": "app",
},
{
"label": "Command\nPrompt",
"icons": ["/usr/local/share/icons/luna/32x32/apps/utilities-terminal.png"],
"cmd": "ghostty",
"kind": "app",
},
]
# Append real user files/folders from ~/Desktop
if DESKTOP_DIR.is_dir():
for p in sorted(DESKTOP_DIR.iterdir()):
if p.name.startswith("."):
continue
is_dir = p.is_dir()
ic = (
"/usr/local/share/icons/luna/32x32/places/folder.png"
if is_dir else
"/usr/local/share/icons/luna/32x32/mimetypes/text-x-generic.png"
)
items.append({
"label": p.name,
"icons": [ic, "/usr/local/share/icons/luna/32x32/mimetypes/application-x-executable.png"],
"cmd": f"thunar '{p}'" if is_dir else f"xdg-open '{p}'",
"kind": "file",
})
return items
def rebuild(self):
for ch in self.grid.get_children():
self.grid.remove(ch)
self.item_boxes = []
self.items = self._build_items()
rows_per_col = 9
for idx, item in enumerate(self.items):
col = idx // rows_per_col
row = idx % rows_per_col
eb = Gtk.EventBox()
eb.set_visible_window(False)
eb.connect("button-press-event", self._on_item_click, idx)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
box.get_style_context().add_class("xp-desk-item")
pb = load_icon_32(item["icons"])
img = Gtk.Image.new_from_pixbuf(pb) if pb else Gtk.Image.new_from_icon_name("folder", Gtk.IconSize.DND)
box.pack_start(img, False, False, 0)
lbl = Gtk.Label(label=item["label"])
lbl.set_justify(Gtk.Justification.CENTER)
lbl.set_line_wrap(True)
lbl.set_max_width_chars(12)
lbl.set_ellipsize(Pango.EllipsizeMode.END)
lbl.set_lines(2)
lbl.get_style_context().add_class("xp-desk-label")
box.pack_start(lbl, False, False, 0)
eb.add(box)
self.grid.attach(eb, col, row, 1, 1)
self.item_boxes.append(box)
self.grid.show_all()
self._update_sel()
def _poll_trash(self):
cur = trash_has_items()
if cur != self.last_trash_state:
self.rebuild()
return True
def _update_sel(self):
for i, box in enumerate(self.item_boxes):
sc = box.get_style_context()
if i == self.selected_idx:
sc.add_class("selected")
else:
sc.remove_class("selected")
def _on_item_click(self, _w, ev, idx):
self.selected_idx = idx
self._update_sel()
item = self.items[idx]
if ev.button == 1:
now = time.monotonic()
if ev.type == Gdk.EventType._2BUTTON_PRESS or (self.last_click[0] == idx and now - self.last_click[1] < 0.42):
self.last_click = (-1, 0.0)
launch(item["cmd"])
else:
self.last_click = (idx, now)
return True
if ev.button == 3:
self._popup_item_menu(ev, item)
return True
return False
def _on_bg_click(self, _w, ev):
self.selected_idx = -1
self._update_sel()
if ev.button == 3:
self._popup_desktop_menu(ev)
return True
return False
def _add_mi(self, menu, text, cb=None, sensitive=True):
mi = Gtk.MenuItem(label=text)
mi.set_sensitive(sensitive)
if cb:
mi.connect("activate", lambda *_: cb())
menu.append(mi)
def _popup_item_menu(self, ev, item):
m = Gtk.Menu()
self._add_mi(m, "Open", lambda: launch(item["cmd"]))
if item["kind"] == "trash":
self._add_mi(m, "Empty Recycle Bin", lambda: empty_recycle_bin(self.rebuild), sensitive=trash_has_items())
m.append(Gtk.SeparatorMenuItem())
self._add_mi(m, "Properties", lambda: launch("/home/carsten/.local/bin/xp-display-properties"))
m.show_all()
self.active_menu = m
m.popup_at_pointer(ev)
def _popup_desktop_menu(self, ev):
m = Gtk.Menu()
self._add_mi(m, "Refresh", self.rebuild)
m.append(Gtk.SeparatorMenuItem())
self._add_mi(m, "Open File Manager (My Computer)", lambda: launch("thunar"))
self._add_mi(m, "Open Command Prompt", lambda: launch("ghostty"))
m.append(Gtk.SeparatorMenuItem())
self._add_mi(m, "Run...", lambda: launch("/home/carsten/.local/bin/xp-run"))
self._add_mi(m, "Task Manager", lambda: launch("/home/carsten/.local/bin/xp-taskmgr"))
self._add_mi(m, "Control Panel", lambda: launch("/home/carsten/.local/bin/xp-control-panel"))
m.append(Gtk.SeparatorMenuItem())
self._add_mi(m, "Properties", lambda: launch("/home/carsten/.local/bin/xp-display-properties"))
m.show_all()
self.active_menu = m
m.popup_at_pointer(ev)
def main():
lock_fd = open(LOCK_PATH, "w")
try:
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except BlockingIOError:
sys.exit(0)
win = XPDesktop()
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
+50
View File
@@ -218,6 +218,7 @@ class XPDisplayProperties(Gtk.Window):
self.previews = [] self.previews = []
self._build_themes_tab() self._build_themes_tab()
self._build_desktop_tab() self._build_desktop_tab()
self._build_screensaver_tab()
self._build_appearance_tab() self._build_appearance_tab()
self.notebook.set_current_page(initial_tab) self.notebook.set_current_page(initial_tab)
@@ -325,6 +326,50 @@ class XPDisplayProperties(Gtk.Window):
box.pack_start(row, True, True, 0) box.pack_start(row, True, True, 0)
self.notebook.append_page(box, Gtk.Label(label="Desktop")) self.notebook.append_page(box, Gtk.Label(label="Desktop"))
def _build_screensaver_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
box.set_border_width(12)
ss_conf = Path("/home/carsten/.config/hypr/xp-screensaver.conf")
cur_ss = ss_conf.read_text(encoding="utf-8").strip() if ss_conf.exists() else "xp-logo"
if cur_ss not in ("none", "xp-logo", "starfield", "mystify"):
cur_ss = "xp-logo"
prev = CRTMonitorPreview()
self.previews.append(prev)
box.pack_start(prev, False, False, 0)
frame = Gtk.Frame(label=" Screen saver ")
inner = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
inner.set_border_width(10)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
self.ss_combo = Gtk.ComboBoxText()
for sid, label in [
("none", "(None)"),
("xp-logo", "Windows XP"),
("starfield", "Starfield"),
("mystify", "Mystify"),
]:
self.ss_combo.append(sid, label)
self.ss_combo.set_active_id(cur_ss)
row.pack_start(self.ss_combo, True, True, 0)
prev_btn = Gtk.Button.new_with_label("Preview")
prev_btn.set_size_request(76, 24)
prev_btn.connect("clicked", lambda *_: subprocess.Popen(
["/home/carsten/.local/bin/xp-screensaver", "--mode", self.ss_combo.get_active_id() or "xp-logo"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
))
row.pack_start(prev_btn, False, False, 0)
inner.pack_start(row, False, False, 0)
note = Gtk.Label(label="Activates automatically after 4 minutes of idle (before lock).", xalign=0)
inner.pack_start(note, False, False, 0)
frame.add(inner)
box.pack_start(frame, False, False, 0)
self.notebook.append_page(box, Gtk.Label(label="Screen Saver"))
def _build_appearance_tab(self): def _build_appearance_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
box.set_border_width(12) box.set_border_width(12)
@@ -437,6 +482,11 @@ class XPDisplayProperties(Gtk.Window):
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False,
) )
# 4. Persist screen saver choice
if hasattr(self, "ss_combo"):
ss_val = self.ss_combo.get_active_id() or "xp-logo"
Path("/home/carsten/.config/hypr/xp-screensaver.conf").write_text(ss_val + "\n", encoding="utf-8")
# Persist wallpaper & cursor in xp-theme.env # Persist wallpaper & cursor in xp-theme.env
if THEME_ENV.exists(): if THEME_ENV.exists():
lines = [] lines = []
+198
View File
@@ -0,0 +1,198 @@
#!/usr/bin/env python3
"""Classic Windows XP Screen Savers: Windows XP Logo (logon.scr), Starfield, Mystify."""
import collections
import math
import os
import random
import signal
import sys
import time
from pathlib import Path
os.environ.setdefault("DCONF_PROFILE", "/home/carsten/.config/hypr/dconf/profile")
import cairo
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
gi.require_version("GdkPixbuf", "2.0")
gi.require_version("GtkLayerShell", "0.1")
from gi.repository import Gtk, Gdk, GdkPixbuf, GLib, GtkLayerShell
CONF_PATH = Path("/home/carsten/.config/hypr/xp-screensaver.conf")
LOGO_PATH = "/usr/local/share/wintc/logonui/logo.png"
def read_saved_mode():
if CONF_PATH.exists():
val = CONF_PATH.read_text(encoding="utf-8").strip().lower()
if val in ("none", "xp-logo", "starfield", "mystify"):
return val
return "xp-logo"
class XPScreenSaver(Gtk.Window):
def __init__(self, mode):
super().__init__(type=Gtk.WindowType.TOPLEVEL)
self.mode = mode
self.start_time = time.monotonic()
self.init_pointer = None
self.set_decorated(False)
GtkLayerShell.init_for_window(self)
GtkLayerShell.set_layer(self, GtkLayerShell.Layer.OVERLAY)
GtkLayerShell.set_namespace(self, "xp-screensaver")
for edge in (GtkLayerShell.Edge.TOP, GtkLayerShell.Edge.BOTTOM, GtkLayerShell.Edge.LEFT, GtkLayerShell.Edge.RIGHT):
GtkLayerShell.set_anchor(self, edge, True)
GtkLayerShell.set_exclusive_zone(self, -1)
GtkLayerShell.set_keyboard_mode(self, GtkLayerShell.KeyboardMode.EXCLUSIVE)
self.da = Gtk.DrawingArea()
self.da.add_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK)
self.da.connect("draw", self.on_draw)
self.da.connect("motion-notify-event", self.on_motion)
self.da.connect("button-press-event", lambda *_: Gtk.main_quit())
self.add(self.da)
self.connect("key-press-event", lambda *_: Gtk.main_quit())
self.connect("realize", self._hide_cursor)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, lambda: (Gtk.main_quit(), False)[1])
# Mode state
self.logo_pb = None
if os.path.exists(LOGO_PATH):
try:
self.logo_pb = GdkPixbuf.Pixbuf.new_from_file(LOGO_PATH)
except Exception:
pass
self.logo_pos = (0.42, 0.42)
self.last_jump = 0.0
self.stars = [[random.uniform(-1, 1), random.uniform(-1, 1), random.uniform(0.05, 1.0)] for _ in range(180)]
# Two Mystify polygons (4 vertices each)
self.polys = []
for col in ((0.0, 0.85, 1.0), (1.0, 0.35, 0.85)):
pts = [[random.uniform(0.1, 0.9), random.uniform(0.1, 0.9),
random.choice((-1, 1)) * random.uniform(0.004, 0.009),
random.choice((-1, 1)) * random.uniform(0.004, 0.009)] for _ in range(4)]
self.polys.append({"color": col, "pts": pts, "trail": collections.deque(maxlen=10)})
interval = 33 if mode in ("starfield", "mystify") else 250
GLib.timeout_add(interval, self.on_tick)
def _hide_cursor(self, _w):
w = self.get_window()
if w:
blank = Gdk.Cursor.new_for_display(w.get_display(), Gdk.CursorType.BLANK_CURSOR)
w.set_cursor(blank)
def on_motion(self, _w, ev):
if time.monotonic() - self.start_time < 0.6:
self.init_pointer = (ev.x, ev.y)
return False
if self.init_pointer is None:
self.init_pointer = (ev.x, ev.y)
return False
dx = ev.x - self.init_pointer[0]
dy = ev.y - self.init_pointer[1]
if dx * dx + dy * dy > 144:
Gtk.main_quit()
return False
def on_tick(self):
if self.mode == "xp-logo":
now = time.monotonic()
if now - self.last_jump >= 4.5:
self.last_jump = now
self.logo_pos = (random.uniform(0.08, 0.78), random.uniform(0.08, 0.78))
self.da.queue_draw()
elif self.mode == "starfield":
for s in self.stars:
s[2] -= 0.018
if s[2] <= 0.02:
s[0] = random.uniform(-1, 1)
s[1] = random.uniform(-1, 1)
s[2] = 1.0
self.da.queue_draw()
elif self.mode == "mystify":
for poly in self.polys:
snap = []
for p in poly["pts"]:
p[0] += p[2]
p[1] += p[3]
if p[0] <= 0.01 or p[0] >= 0.99:
p[2] = -p[2]
p[0] = max(0.01, min(0.99, p[0]))
if p[1] <= 0.01 or p[1] >= 0.99:
p[3] = -p[3]
p[1] = max(0.01, min(0.99, p[1]))
snap.append((p[0], p[1]))
poly["trail"].append(snap)
self.da.queue_draw()
return True
def on_draw(self, _w, cr):
a = self.da.get_allocation()
w, h = a.width, a.height
cr.set_source_rgb(0.0, 0.0, 0.0)
cr.rectangle(0, 0, w, h)
cr.fill()
if self.mode == "xp-logo":
lx = int(self.logo_pos[0] * w)
ly = int(self.logo_pos[1] * h)
if self.logo_pb:
Gdk.cairo_set_source_pixbuf(cr, self.logo_pb, lx, ly)
cr.paint()
cr.set_source_rgb(0.85, 0.88, 0.95)
cr.select_font_face("Tahoma", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(14)
cr.move_to(lx + 18, ly + 104)
cr.show_text("Professional")
elif self.mode == "starfield":
cx, cy = w / 2.0, h / 2.0
for x, y, z in self.stars:
sx = cx + (x / z) * cx * 0.7
sy = cy + (y / z) * cy * 0.7
if 0 <= sx < w and 0 <= sy < h:
b = max(0.25, 1.0 - z)
sz = max(1.2, (1.0 - z) * 3.4)
cr.set_source_rgb(b, b, b)
cr.rectangle(sx, sy, sz, sz)
cr.fill()
elif self.mode == "mystify":
cr.set_line_width(1.4)
for poly in self.polys:
r, g, b = poly["color"]
tr = poly["trail"]
n = len(tr)
for idx, snap in enumerate(tr):
alpha = (idx + 1) / float(max(1, n))
cr.set_source_rgba(r, g, b, alpha * 0.9)
for i, (px, py) in enumerate(snap):
if i == 0:
cr.move_to(px * w, py * h)
else:
cr.line_to(px * w, py * h)
cr.close_path()
cr.stroke()
def main():
mode = read_saved_mode()
for i, arg in enumerate(sys.argv[1:]):
if arg == "--mode" and i + 2 < len(sys.argv):
mode = sys.argv[i + 2].lower()
if mode == "none":
return
win = XPScreenSaver(mode)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
+4 -4
View File
@@ -5,14 +5,14 @@ general {
} }
listener { listener {
timeout = 300 timeout = 240
on-timeout = brightnessctl -s set 20% on-timeout = /home/carsten/.local/bin/xp-screensaver
on-resume = brightnessctl -r on-resume = pkill -f "[x]p-screensaver" 2>/dev/null || true
} }
listener { listener {
timeout = 600 timeout = 600
on-timeout = loginctl lock-session on-timeout = pkill -f "[x]p-screensaver" 2>/dev/null || true; loginctl lock-session
} }
listener { listener {
+2 -1
View File
@@ -19,7 +19,7 @@ exec-once = swaync
exec-once = /home/carsten/.local/bin/xp-start-menu --daemon exec-once = /home/carsten/.local/bin/xp-start-menu --daemon
exec-once = /home/carsten/.local/bin/xp-alttab --daemon exec-once = /home/carsten/.local/bin/xp-alttab --daemon
exec-once = /home/carsten/.local/bin/xp-sound-daemon exec-once = /home/carsten/.local/bin/xp-sound-daemon
exec-once = /home/carsten/.local/bin/xp-context-menu --desktop-daemon exec-once = /home/carsten/.local/bin/xp-desktop
exec-once = hypridle exec-once = hypridle
exec-once = /usr/libexec/hyprpolkitagent exec-once = /usr/libexec/hyprpolkitagent
exec-once = nm-applet --indicator exec-once = nm-applet --indicator
@@ -75,6 +75,7 @@ windowrule = match:class ^(xp-run)$, float on, move 12 100%-204, size 368 152
windowrule = match:class ^(xp-display-properties)$, float on, center on, size 404 468 windowrule = match:class ^(xp-display-properties)$, float on, center on, size 404 468
windowrule = match:class ^(xp-control-panel)$, float on, center on, size 740 480 windowrule = match:class ^(xp-control-panel)$, float on, center on, size 740 480
windowrule = match:class ^(xp-taskmgr)$, float on, center on, size 450 500 windowrule = match:class ^(xp-taskmgr)$, float on, center on, size 450 500
windowrule = match:class ^(xp-clipbook)$, float on, center on, size 450 360
windowrule = match:title ^(Open|Save|Select|Choose|File Operation Progress)(.*)$, float on, center on windowrule = match:title ^(Open|Save|Select|Choose|File Operation Progress)(.*)$, float on, center on
# Keybindings # Keybindings
+1 -5
View File
@@ -1,6 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if pkill -x rofi; then exec /home/carsten/.local/bin/xp-clipbook
exit 0
fi
SEL=$(cliphist list | rofi -dmenu -p "Clipboard" -theme /home/carsten/.config/rofi/xp-dialog.rasi) || exit 0
[ -n "$SEL" ] && printf '%s\n' "$SEL" | cliphist decode | wl-copy
+1
View File
@@ -0,0 +1 @@
xp-logo
+2 -1
View File
@@ -62,7 +62,8 @@ ln -sfn "/usr/local/share/themes/Windows XP style (Blue)/gtk-4.0/gtk.css" "${HOM
for f in xp-start-menu xp-alttab xp-shutdown-dialog xp-theme-switch xp-generate-logon-bg \ for f in xp-start-menu xp-alttab xp-shutdown-dialog xp-theme-switch xp-generate-logon-bg \
xp-run xp-display-properties xp-control-panel xp-taskmgr \ xp-run xp-display-properties xp-control-panel xp-taskmgr \
xp-volume-popup xp-calendar-popup xp-sound-daemon xp-context-menu; do xp-volume-popup xp-calendar-popup xp-sound-daemon xp-context-menu \
xp-desktop xp-screensaver xp-clipbook; do
install -Dm755 "${REPO_DIR}/bin/${f}" "${HOME}/.local/bin/${f}" install -Dm755 "${REPO_DIR}/bin/${f}" "${HOME}/.local/bin/${f}"
done done
+19 -1
View File
@@ -248,6 +248,13 @@ void CHyprBar::handleDownEvent(SCallbackInfo& info, std::optional<ITouch::SDownE
m_bCancelledDown = true; m_bCancelledDown = true;
if (g_pGlobalState->theme.loaded) { if (g_pGlobalState->theme.loaded) {
// Clicking the 16x16 XP window app icon opens the classic XP Window System Menu
const double iconLeft = g_pGlobalState->theme.topLeftActive ? cairo_image_surface_get_width(g_pGlobalState->theme.topLeftActive) : 4.0;
if (VECINRECT(COORDS, iconLeft, 2.0, iconLeft + 18.0, BARH - 2.0)) {
g_pKeybindManager->m_dispatchers["exec"]("/home/carsten/.local/bin/xp-context-menu --window");
m_bDragPending = false;
return;
}
for (size_t i = 0; i < m_buttonBoxes.size(); ++i) { for (size_t i = 0; i < m_buttonBoxes.size(); ++i) {
const auto& b = m_buttonBoxes[i]; const auto& b = m_buttonBoxes[i];
if (VECINRECT(COORDS, b.x, b.y, b.x + b.w, b.y + b.h)) { if (VECINRECT(COORDS, b.x, b.y, b.x + b.w, b.y + b.h)) {
@@ -736,8 +743,19 @@ void CHyprBar::renderXPBar(const Vector2D& bufferSize, const float scale) {
curX = bx - theme.buttonSpacing; curX = bx - theme.buttonSpacing;
} }
// Draw authentic 16x16 XP app icon (Window.SysButton) on far left of titlebar
const auto PWINDOW = m_pWindow.lock();
cairo_surface_t* appIcon = PWINDOW ? g_pGlobalState->getAppIcon(PWINDOW->m_class) : nullptr;
double textX = lw + theme.titleHorzOffset;
if (appIcon && curX > lw + 26.0) {
const double iconX = lw + 2.0;
const double iconY = std::floor((H - 16.0) / 2.0) + 1.0;
cairo_set_source_surface(cr, appIcon, iconX, iconY);
cairo_paint(cr);
textX = iconX + 16.0 + 4.0;
}
// Draw XP title text with drop shadow // Draw XP title text with drop shadow
const double textX = lw + theme.titleHorzOffset;
const double maxTextW = std::max(0.0, curX - textX - 6.0); const double maxTextW = std::max(0.0, curX - textX - 6.0);
if (maxTextW > 4.0 && !m_szLastTitle.empty()) { if (maxTextW > 4.0 && !m_szLastTitle.empty()) {
+103
View File
@@ -10,6 +10,7 @@
#include <hyprland/src/plugins/PluginAPI.hpp> #include <hyprland/src/plugins/PluginAPI.hpp>
#include <hyprland/src/render/Texture.hpp> #include <hyprland/src/render/Texture.hpp>
#include <string> #include <string>
#include <unordered_map>
#include <vector> #include <vector>
inline HANDLE PHANDLE = nullptr; inline HANDLE PHANDLE = nullptr;
@@ -382,8 +383,110 @@ struct SGlobalState {
uint32_t barColorRuleIdx = 0; uint32_t barColorRuleIdx = 0;
uint32_t titleColorRuleIdx = 0; uint32_t titleColorRuleIdx = 0;
SXPThemeAssets theme; SXPThemeAssets theme;
std::unordered_map<std::string, cairo_surface_t*> iconCache;
static cairo_surface_t* loadScaledIcon16(const std::filesystem::path& p) {
std::error_code ec;
if (!std::filesystem::exists(p, ec))
return nullptr;
cairo_surface_t* raw = cairo_image_surface_create_from_png(p.c_str());
if (!raw || cairo_surface_status(raw) != CAIRO_STATUS_SUCCESS) {
if (raw)
cairo_surface_destroy(raw);
return nullptr;
}
int rw = cairo_image_surface_get_width(raw);
int rh = cairo_image_surface_get_height(raw);
if (rw == 16 && rh == 16)
return raw;
cairo_surface_t* dst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 16, 16);
cairo_t* cr = cairo_create(dst);
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_scale(cr, 16.0 / std::max(1, rw), 16.0 / std::max(1, rh));
cairo_set_source_surface(cr, raw, 0, 0);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_BILINEAR);
cairo_paint(cr);
cairo_destroy(cr);
cairo_surface_destroy(raw);
return dst;
}
cairo_surface_t* getAppIcon(const std::string& winClass) {
std::string key = winClass;
std::transform(key.begin(), key.end(), key.begin(), [](unsigned char c) { return std::tolower(c); });
auto it = iconCache.find(key);
if (it != iconCache.end())
return it->second;
namespace fs = std::filesystem;
std::vector<fs::path> candidates;
auto pushLuna = [&](const std::string& rel) {
candidates.push_back(fs::path("/usr/local/share/icons/luna/16x16") / rel);
candidates.push_back(fs::path("/usr/local/share/icons/luna/32x32") / rel);
};
if (key == "com.mitchellh.ghostty" || key == "ghostty")
pushLuna("apps/utilities-terminal.png");
else if (key == "thunar")
pushLuna("places/folder.png");
else if (key.find("firefox") != std::string::npos) {
candidates.push_back("/snap/firefox/current/usr/lib/firefox/browser/chrome/icons/default/default16.png");
candidates.push_back("/snap/firefox/current/usr/lib/firefox/browser/chrome/icons/default/default32.png");
pushLuna("apps/internet-web-browser.png");
} else if (key == "xp-run")
pushLuna("actions/system-run.png");
else if (key == "xp-control-panel")
pushLuna("apps/preferences-other.png");
else if (key == "xp-display-properties")
pushLuna("apps/preferences-desktop-display.png");
else if (key == "xp-taskmgr")
pushLuna("apps/preferences-system.png");
else if (key == "xp-clipbook")
pushLuna("actions/edit-copy.png");
else if (key == "swappy") {
pushLuna("mimetypes/image-x-generic.png");
pushLuna("apps/preferences-desktop-display.png");
} else if (key == "mousepad")
pushLuna("mimetypes/text-x-generic.png");
else if (key == "ristretto")
pushLuna("mimetypes/image-x-generic.png");
else if (key == "engrampa")
pushLuna("mimetypes/package-x-generic.png");
else if (key.find("pavucontrol") != std::string::npos)
pushLuna("devices/audio-speakers.png");
else if (key.find("blueman") != std::string::npos)
pushLuna("apps/preferences-desktop-peripherals.png");
else if (key.find("nm-connection") != std::string::npos)
pushLuna("apps/preferences-system-network.png");
// Generic lookups by class name
if (!key.empty()) {
pushLuna("apps/" + key + ".png");
candidates.push_back(fs::path("/usr/share/icons/hicolor/16x16/apps") / (key + ".png"));
candidates.push_back(fs::path("/usr/share/icons/hicolor/32x32/apps") / (key + ".png"));
candidates.push_back(fs::path("/usr/share/icons/hicolor/48x48/apps") / (key + ".png"));
}
// Fallback authentic XP application icon
pushLuna("mimetypes/application-x-executable.png");
cairo_surface_t* result = nullptr;
for (const auto& p : candidates) {
result = loadScaledIcon16(p);
if (result)
break;
}
iconCache[key] = result;
return result;
}
~SGlobalState() { ~SGlobalState() {
for (auto& kv : iconCache) {
if (kv.second)
cairo_surface_destroy(kv.second);
}
iconCache.clear();
theme.unload(); theme.unload();
} }
}; };