Add native XP Run, Control Panel, Display Properties, Task Manager, Tray Popups, Sound Daemon, and Context Menus

This commit is contained in:
Carsten
2026-11-27 20:08:39 +01:00
parent 4bc6a84a16
commit 9735f28386
14 changed files with 2311 additions and 42 deletions
+234
View File
@@ -0,0 +1,234 @@
#!/usr/bin/env python3
"""Classic Windows XP Date & Time tray Calendar + Analog Clock popup."""
import datetime
import math
import os
import signal
import sys
import time
os.environ.setdefault("DCONF_PROFILE", "/home/carsten/.config/hypr/dconf/profile")
PID_FILE = f"/run/user/{os.getuid()}/xp-calendar-popup.pid"
if os.path.exists(PID_FILE):
try:
old_pid = int(open(PID_FILE).read().strip())
if old_pid != os.getpid():
os.kill(old_pid, signal.SIGTERM)
os.unlink(PID_FILE)
sys.exit(0)
except (OSError, ValueError):
pass
open(PID_FILE, "w").write(str(os.getpid()))
import cairo
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
gi.require_version("GtkLayerShell", "0.1")
from gi.repository import Gtk, Gdk, GLib, GtkLayerShell
CAL_CSS = b"""
window#xp-cal-win {
background-color: transparent;
}
.xp-cal-outer {
background-color: #ECE9D8;
border: 1px solid #003C74;
border-radius: 3px;
box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.38);
margin: 4px;
}
.xp-cal-bevel {
background-color: #ECE9D8;
border-top: 1px solid #FFFFFF;
border-left: 1px solid #FFFFFF;
border-right: 1px solid #ACA899;
border-bottom: 1px solid #ACA899;
padding: 10px 12px;
}
.xp-cal-hdr {
font-family: "Tahoma", sans-serif;
font-size: 9pt;
font-weight: bold;
color: #003399;
}
.xp-cal-time {
font-family: "Tahoma", sans-serif;
font-size: 10pt;
font-weight: bold;
color: #000000;
background-color: #FFFFFF;
border: 1px solid #7F9DB9;
padding: 3px 10px;
}
.xp-cal-tz {
font-family: "Tahoma", sans-serif;
font-size: 8pt;
color: #444444;
}
"""
class XPAnalogClock(Gtk.DrawingArea):
"""Authentic Windows XP Date & Time Properties teal-marker analog clock."""
def __init__(self):
super().__init__()
self.set_size_request(132, 132)
self.connect("draw", self.on_draw)
def on_draw(self, _w, cr):
a = self.get_allocation()
cx, cy = a.width / 2.0, a.height / 2.0
r = min(cx, cy) - 8
# Subtle face shadow
cr.set_source_rgb(0.92, 0.91, 0.85)
cr.arc(cx, cy, r + 3, 0, 2 * math.pi)
cr.fill()
# Hour/minute tick markers (iconic XP teal squares at 12/3/6/9, dots elsewhere)
for i in range(60):
ang = (i / 60.0) * 2 * math.pi - math.pi / 2.0
mx = cx + math.cos(ang) * (r - 2)
my = cy + math.sin(ang) * (r - 2)
if i % 15 == 0:
cr.set_source_rgb(0.0, 0.48, 0.50)
cr.rectangle(mx - 3, my - 3, 6, 6)
cr.fill()
elif i % 5 == 0:
cr.set_source_rgb(0.0, 0.48, 0.50)
cr.rectangle(mx - 2, my - 2, 4, 4)
cr.fill()
else:
cr.set_source_rgb(0.50, 0.50, 0.50)
cr.rectangle(mx - 0.7, my - 0.7, 1.4, 1.4)
cr.fill()
now = datetime.datetime.now()
sec_ang = (now.second / 60.0) * 2 * math.pi - math.pi / 2.0
min_ang = ((now.minute + now.second / 60.0) / 60.0) * 2 * math.pi - math.pi / 2.0
hr_ang = (((now.hour % 12) + now.minute / 60.0) / 12.0) * 2 * math.pi - math.pi / 2.0
# Hour hand (teal-black)
cr.set_source_rgb(0.0, 0.42, 0.44)
cr.set_line_width(3.2)
cr.set_line_cap(cairo.LINE_CAP_ROUND)
cr.move_to(cx, cy)
cr.line_to(cx + math.cos(hr_ang) * (r * 0.52), cy + math.sin(hr_ang) * (r * 0.52))
cr.stroke()
# Minute hand
cr.set_source_rgb(0.0, 0.42, 0.44)
cr.set_line_width(2.2)
cr.move_to(cx, cy)
cr.line_to(cx + math.cos(min_ang) * (r * 0.74), cy + math.sin(min_ang) * (r * 0.74))
cr.stroke()
# Second hand (crisp red/dark thin needle)
cr.set_source_rgb(0.75, 0.12, 0.12)
cr.set_line_width(1.0)
cr.move_to(cx - math.cos(sec_ang) * 8, cy - math.sin(sec_ang) * 8)
cr.line_to(cx + math.cos(sec_ang) * (r * 0.80), cy + math.sin(sec_ang) * (r * 0.80))
cr.stroke()
# Center hub
cr.set_source_rgb(0.0, 0.35, 0.37)
cr.arc(cx, cy, 3.0, 0, 2 * math.pi)
cr.fill()
class XPCalendarPopup(Gtk.Window):
def __init__(self):
super().__init__(type=Gtk.WindowType.TOPLEVEL)
self.set_name("xp-cal-win")
self.set_decorated(False)
self.set_resizable(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.OVERLAY)
GtkLayerShell.set_namespace(self, "xp-calendar-popup")
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.BOTTOM, True)
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.RIGHT, True)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.BOTTOM, 32)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.RIGHT, 4)
GtkLayerShell.set_keyboard_mode(self, GtkLayerShell.KeyboardMode.ON_DEMAND)
prov = Gtk.CssProvider()
prov.load_from_data(CAL_CSS)
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), prov, Gtk.STYLE_PROVIDER_PRIORITY_USER)
outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
outer.get_style_context().add_class("xp-cal-outer")
bevel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
bevel.get_style_context().add_class("xp-cal-bevel")
outer.pack_start(bevel, True, True, 0)
now = datetime.datetime.now()
hdr = Gtk.Label(label=now.strftime("%A, %B %d, %Y"), xalign=0)
hdr.get_style_context().add_class("xp-cal-hdr")
bevel.pack_start(hdr, False, False, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
cal_frame = Gtk.Frame(label=" Date ")
cal = Gtk.Calendar()
cal.set_margin_top(4); cal.set_margin_bottom(6)
cal.set_margin_start(6); cal.set_margin_end(6)
cal_frame.add(cal)
row.pack_start(cal_frame, False, False, 0)
clk_frame = Gtk.Frame(label=" Time ")
clk_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
clk_box.set_border_width(8)
self.analog = XPAnalogClock()
clk_box.pack_start(self.analog, False, False, 0)
self.digital = Gtk.Label(label=now.strftime("%H:%M:%S"))
self.digital.get_style_context().add_class("xp-cal-time")
clk_box.pack_start(self.digital, False, False, 0)
clk_frame.add(clk_box)
row.pack_start(clk_frame, False, False, 0)
bevel.pack_start(row, False, False, 0)
tz_name = time.tzname[time.daylight] if time.daylight else time.tzname[0]
tz = Gtk.Label(label=f"Current time zone: {tz_name}", xalign=0)
tz.get_style_context().add_class("xp-cal-tz")
bevel.pack_start(tz, False, False, 0)
self.add(outer)
GLib.timeout_add(1000, self._tick)
self.connect("key-press-event", lambda _w, ev: self.quit() if ev.keyval == Gdk.KEY_Escape else False)
self.connect("focus-out-event", lambda *_: self.quit())
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, lambda: (self.quit(), False)[1])
def _tick(self):
self.digital.set_text(datetime.datetime.now().strftime("%H:%M:%S"))
self.analog.queue_draw()
return True
def quit(self):
try:
os.unlink(PID_FILE)
except OSError:
pass
Gtk.main_quit()
return False
def main():
win = XPCalendarPopup()
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
+211
View File
@@ -0,0 +1,211 @@
#!/usr/bin/env python3
"""Windows XP Right-Click Context Menus (Desktop, Taskbar, and Active Window)."""
import fcntl
import json
import os
import signal
import subprocess
import sys
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("GtkLayerShell", "0.1")
from gi.repository import Gtk, Gdk, GLib, GtkLayerShell
def launch(cmd):
subprocess.Popen(["hyprctl", "dispatch", "exec", cmd],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def hypr(*args):
subprocess.Popen(["hyprctl", "dispatch", *args],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def add_item(menu, label, cb=None, sensitive=True, submenu=None):
mi = Gtk.MenuItem(label=label)
mi.set_sensitive(sensitive)
if submenu is not None:
mi.set_submenu(submenu)
elif cb is not None:
mi.connect("activate", lambda *_: cb())
menu.append(mi)
return mi
def build_desktop_menu():
m = Gtk.Menu()
add_item(m, "Open File Manager (My Computer)", lambda: launch("thunar"))
add_item(m, "Open Command Prompt", lambda: launch("ghostty"))
m.append(Gtk.SeparatorMenuItem())
add_item(m, "Refresh", lambda: subprocess.Popen(["hyprctl", "reload"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL))
m.append(Gtk.SeparatorMenuItem())
add_item(m, "Run...", lambda: launch("/home/carsten/.local/bin/xp-run"))
add_item(m, "Task Manager", lambda: launch("/home/carsten/.local/bin/xp-taskmgr"))
add_item(m, "Control Panel", lambda: launch("/home/carsten/.local/bin/xp-control-panel"))
m.append(Gtk.SeparatorMenuItem())
add_item(m, "Properties", lambda: launch("/home/carsten/.local/bin/xp-display-properties"))
m.show_all()
return m
def build_taskbar_menu():
m = Gtk.Menu()
add_item(m, "Task Manager", lambda: launch("/home/carsten/.local/bin/xp-taskmgr"))
add_item(m, "Control Panel", lambda: launch("/home/carsten/.local/bin/xp-control-panel"))
add_item(m, "Display Properties", lambda: launch("/home/carsten/.local/bin/xp-display-properties"))
add_item(m, "Run...", lambda: launch("/home/carsten/.local/bin/xp-run"))
m.append(Gtk.SeparatorMenuItem())
add_item(m, "Show the Desktop", lambda: launch("/home/carsten/.config/hypr/scripts/show-desktop.sh"))
add_item(m, "Adjust Date/Time", lambda: launch("/home/carsten/.local/bin/xp-calendar-popup"))
add_item(m, "Volume Control", lambda: launch("pavucontrol"))
m.append(Gtk.SeparatorMenuItem())
add_item(m, "Turn Off Computer...", lambda: launch("/home/carsten/.config/hypr/scripts/xp-power-menu.sh"))
m.show_all()
return m
def build_window_menu():
m = Gtk.Menu()
active = {}
try:
out = subprocess.check_output(["hyprctl", "activewindow", "-j"], text=True, timeout=0.8)
active = json.loads(out)
except Exception:
pass
has_win = bool(active.get("address"))
is_float = bool(active.get("floating", False))
is_full = bool(active.get("fullscreen", 0))
add_item(m, "Restore", lambda: hypr("fullscreen", "1") if is_full else None, sensitive=has_win and is_full)
add_item(m, "Maximize", lambda: hypr("fullscreen", "1"), sensitive=has_win and not is_full)
add_item(m, "Toggle Floating" if not is_float else "Tile Window", lambda: hypr("togglefloating"), sensitive=has_win)
ws_sub = Gtk.Menu()
for i in range(1, 10):
add_item(ws_sub, f"Desktop {i}", lambda n=i: hypr("movetoworkspace", str(n)))
add_item(m, "Move to Desktop", submenu=ws_sub, sensitive=has_win)
m.append(Gtk.SeparatorMenuItem())
add_item(m, "Close\tAlt+F4", lambda: hypr("killactive"), sensitive=has_win)
m.show_all()
return m
def run_desktop_daemon():
"""Invisible BACKGROUND-layer surface that catches right-clicks on empty Bliss desktop."""
lock_path = f"/run/user/{os.getuid()}/xp-desktop-ctx.lock"
lock_fd = open(lock_path, "w")
try:
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except BlockingIOError:
sys.exit(0)
win = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
win.set_decorated(False)
win.set_app_paintable(True)
visual = win.get_screen().get_rgba_visual()
if visual:
win.set_visual(visual)
prov = Gtk.CssProvider()
prov.load_from_data(b"window { background-color: transparent; }")
win.get_style_context().add_provider(prov, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
GtkLayerShell.init_for_window(win)
GtkLayerShell.set_layer(win, GtkLayerShell.Layer.BACKGROUND)
GtkLayerShell.set_namespace(win, "xp-desktop-ctx")
for edge in (GtkLayerShell.Edge.TOP, GtkLayerShell.Edge.BOTTOM, GtkLayerShell.Edge.LEFT, GtkLayerShell.Edge.RIGHT):
GtkLayerShell.set_anchor(win, edge, True)
GtkLayerShell.set_exclusive_zone(win, -1)
GtkLayerShell.set_keyboard_mode(win, GtkLayerShell.KeyboardMode.NONE)
eb = Gtk.EventBox()
eb.set_visible_window(False)
win.add(eb)
active_menu = [None]
def on_press(_w, ev):
if ev.button == 3:
menu = build_desktop_menu()
active_menu[0] = menu
menu.popup_at_pointer(ev)
return True
return False
eb.connect("button-press-event", on_press)
win.show_all()
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, lambda: (Gtk.main_quit(), False)[1])
Gtk.main()
def run_oneshot_popup(mode):
"""Pop up a context menu at the current cursor position via a tiny OVERLAY anchor."""
cx, cy = 960, 540
try:
out = subprocess.check_output(["hyprctl", "cursorpos"], text=True, timeout=0.5).strip()
px, py = out.split(",")
cx, cy = int(px.strip()), int(py.strip())
except Exception:
pass
win = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
win.set_decorated(False)
win.set_default_size(1, 1)
win.set_app_paintable(True)
visual = win.get_screen().get_rgba_visual()
if visual:
win.set_visual(visual)
prov = Gtk.CssProvider()
prov.load_from_data(b"window { background-color: transparent; }")
win.get_style_context().add_provider(prov, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
GtkLayerShell.init_for_window(win)
GtkLayerShell.set_layer(win, GtkLayerShell.Layer.OVERLAY)
GtkLayerShell.set_namespace(win, "xp-context-menu")
GtkLayerShell.set_anchor(win, GtkLayerShell.Edge.LEFT, True)
GtkLayerShell.set_anchor(win, GtkLayerShell.Edge.TOP, True)
GtkLayerShell.set_margin(win, GtkLayerShell.Edge.LEFT, max(0, cx))
GtkLayerShell.set_margin(win, GtkLayerShell.Edge.TOP, max(0, cy - 8))
GtkLayerShell.set_keyboard_mode(win, GtkLayerShell.KeyboardMode.ON_DEMAND)
menu = build_window_menu() if mode == "window" else (build_taskbar_menu() if mode == "taskbar" else build_desktop_menu())
menu.connect("deactivate", lambda *_: GLib.timeout_add(80, Gtk.main_quit))
def show_menu():
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = 0, 0, 1, 1
menu.popup_at_rect(
win.get_window(), rect,
Gdk.Gravity.SOUTH_WEST if mode == "taskbar" else Gdk.Gravity.NORTH_WEST,
Gdk.Gravity.SOUTH_WEST if mode == "taskbar" else Gdk.Gravity.NORTH_WEST,
None,
)
return False
win.show_all()
GLib.idle_add(show_menu)
Gtk.main()
def main():
if "--desktop-daemon" in sys.argv:
run_desktop_daemon()
elif "--window" in sys.argv:
run_oneshot_popup("window")
elif "--taskbar" in sys.argv:
run_oneshot_popup("taskbar")
else:
run_oneshot_popup("desktop")
if __name__ == "__main__":
main()
+403
View File
@@ -0,0 +1,403 @@
#!/usr/bin/env python3
"""Native Windows XP Control Panel with Luna Task Sidebar + Sounds/User/Power applets."""
import os
import platform
import shutil
import subprocess
import sys
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")
from gi.repository import Gtk, Gdk, GdkPixbuf, Pango
LUNA_32 = "/usr/local/share/icons/luna/32x32"
MUTE_FLAG = Path("/home/carsten/.config/hypr/mute-xp-sounds")
SOUND_DIR = Path("/usr/local/share/sounds/Windows XP Default/stereo/res")
USERPICS_DIR = Path("/usr/local/share/wintc/userpics")
USERPIC_DEST = Path("/home/carsten/.config/hypr/assets/userpic.png")
CP_CSS = b"""
.xp-cp-sidebar {
background-image: linear-gradient(180deg, #7BA2E7 0%, #6375D6 100%);
padding: 12px 10px;
}
.xp-cp-card {
background-color: #D6DFF7;
border: 1px solid #FFFFFF;
border-radius: 3px;
}
.xp-cp-card-hdr {
background-image: linear-gradient(90deg, #FFFFFF 0%, #C6D3F7 100%);
color: #215DC6;
font-family: "Tahoma", sans-serif;
font-weight: bold;
font-size: 8.5pt;
padding: 4px 10px;
border-radius: 3px 3px 0 0;
}
.xp-cp-card-body {
padding: 8px 10px;
}
.xp-cp-link {
background: transparent;
background-image: none;
border: none;
border-image-source: none;
box-shadow: none;
color: #215DC6;
font-family: "Tahoma", sans-serif;
font-size: 8.5pt;
padding: 2px 0px;
}
.xp-cp-link:hover {
color: #428EFF;
text-decoration: underline;
background: transparent;
border-image-source: none;
}
.xp-cp-main {
background-color: #FFFFFF;
padding: 14px 16px;
}
.xp-cp-tile {
background: transparent;
background-image: none;
border: 1px solid transparent;
border-image-source: none;
box-shadow: none;
padding: 8px 6px;
border-radius: 3px;
}
.xp-cp-tile:hover {
background-color: #E8F1FD;
border-color: #99BFE8;
border-image-source: none;
}
.xp-cp-tile-title {
font-family: "Tahoma", sans-serif;
font-size: 8.5pt;
font-weight: bold;
color: #000000;
}
.xp-cp-tile-desc {
font-family: "Tahoma", sans-serif;
font-size: 8pt;
color: #555555;
}
"""
def load_luna_icon(rel_path, size=32):
p = os.path.join(LUNA_32, rel_path)
if os.path.exists(p):
try:
pb = GdkPixbuf.Pixbuf.new_from_file_at_scale(p, size, size, True)
return Gtk.Image.new_from_pixbuf(pb)
except Exception:
pass
return Gtk.Image.new_from_icon_name("preferences-system", Gtk.IconSize.DND)
def open_sounds_dialog(parent=None):
dlg = Gtk.Dialog(title="Sounds and Audio Devices Properties", transient_for=parent)
dlg.set_default_size(390, 340)
dlg.set_resizable(False)
area = dlg.get_content_area()
area.set_border_width(12)
area.set_spacing(10)
mute_cb = Gtk.CheckButton(label="Enable Windows XP system event sounds")
mute_cb.set_active(not MUTE_FLAG.exists())
area.pack_start(mute_cb, False, False, 0)
lbl = Gtk.Label(label="Program events (select a sound and click Test):")
lbl.set_xalign(0.0)
area.pack_start(lbl, False, False, 0)
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.set_size_request(-1, 175)
store = Gtk.ListStore(str, str)
for wav in sorted(SOUND_DIR.glob("*.wav")):
store.append([wav.stem.replace("-", " ").title(), str(wav)])
tv = Gtk.TreeView(model=store)
tv.set_headers_visible(False)
tv.append_column(Gtk.TreeViewColumn("Sound", Gtk.CellRendererText(), text=0))
sw.add(tv)
area.pack_start(sw, True, True, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
play_btn = Gtk.Button.new_with_label("Test Sound")
def on_play(_b):
model, it = tv.get_selection().get_selected()
if it:
subprocess.Popen(["paplay", model[it][1]], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
play_btn.connect("clicked", on_play)
row.pack_start(play_btn, False, False, 0)
mixer_btn = Gtk.Button.new_with_label("Open Volume Mixer...")
mixer_btn.connect("clicked", lambda *_: subprocess.Popen(["hyprctl", "dispatch", "exec", "pavucontrol"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL))
row.pack_end(mixer_btn, False, False, 0)
area.pack_start(row, False, False, 0)
dlg.add_buttons("OK", Gtk.ResponseType.OK, "Cancel", Gtk.ResponseType.CANCEL)
dlg.show_all()
if dlg.run() == Gtk.ResponseType.OK:
if mute_cb.get_active():
MUTE_FLAG.unlink(missing_ok=True)
else:
MUTE_FLAG.touch()
dlg.destroy()
def open_user_accounts_dialog(parent=None):
dlg = Gtk.Dialog(title="User Accounts — Change Picture", transient_for=parent)
dlg.set_default_size(440, 360)
area = dlg.get_content_area()
area.set_border_width(12)
area.set_spacing(8)
area.pack_start(Gtk.Label(label="Pick a new picture for your Start Menu and Lock Screen:", xalign=0), False, False, 0)
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
fb = Gtk.FlowBox()
fb.set_max_children_per_line(6)
fb.set_selection_mode(Gtk.SelectionMode.SINGLE)
fb.set_row_spacing(6)
fb.set_column_spacing(6)
fb.set_border_width(8)
pics = sorted(USERPICS_DIR.glob("*.png")) if USERPICS_DIR.exists() else []
for p in pics:
pb = GdkPixbuf.Pixbuf.new_from_file_at_scale(str(p), 48, 48, True)
img = Gtk.Image.new_from_pixbuf(pb)
img.set_tooltip_text(p.stem)
child = Gtk.FlowBoxChild()
child.pic_path = str(p)
child.add(img)
fb.add(child)
sw.add(fb)
area.pack_start(sw, True, True, 0)
dlg.add_buttons("Change Picture", Gtk.ResponseType.OK, "Cancel", Gtk.ResponseType.CANCEL)
dlg.show_all()
if dlg.run() == Gtk.ResponseType.OK:
sel = fb.get_selected_children()
if sel:
chosen = sel[0].pic_path
shutil.copyfile(chosen, USERPIC_DEST)
# Also update xp-generate-logon-bg & regenerate lockscreen
gen = Path("/home/carsten/.local/bin/xp-generate-logon-bg")
if gen.exists():
txt = gen.read_text(encoding="utf-8")
import re
txt = re.sub(r'pic_path = ".*?"', f'pic_path = "{chosen}"', txt, count=1)
gen.write_text(txt, encoding="utf-8")
subprocess.Popen([str(gen)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.Popen(["pkill", "-HUP", "-f", "xp-start-menu"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
dlg.destroy()
def open_system_props_dialog(parent=None):
dlg = Gtk.Dialog(title="System Properties", transient_for=parent)
dlg.set_default_size(390, 290)
dlg.set_resizable(False)
area = dlg.get_content_area()
area.set_border_width(14)
area.set_spacing(10)
# Read CPU & RAM
cpu = "Intel Processor"
try:
for line in Path("/proc/cpuinfo").read_text().splitlines():
if line.startswith("model name"):
cpu = line.split(":", 1)[1].strip()
break
except Exception:
pass
mem_gb = "?"
try:
for line in Path("/proc/meminfo").read_text().splitlines():
if line.startswith("MemTotal:"):
kb = int(line.split()[1])
mem_gb = f"{kb / (1024*1024):.1f} GB of RAM"
break
except Exception:
pass
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=16)
row.pack_start(load_luna_icon("devices/system.png", 48), False, False, 4)
info = Gtk.Label(
label=(
f"System:\n"
f" Microsoft Windows XP (Hyprland Edition)\n"
f" Ubuntu 26.04 LTS — Kernel {platform.release()}\n\n"
f"Registered to:\n"
f" {os.environ.get('USER', 'carsten')}\n\n"
f"Computer:\n"
f" {cpu}\n"
f" {mem_gb}"
)
)
info.set_xalign(0.0)
info.set_line_wrap(True)
row.pack_start(info, True, True, 0)
area.pack_start(row, True, True, 0)
dlg.add_buttons("OK", Gtk.ResponseType.OK)
dlg.show_all()
dlg.run()
dlg.destroy()
class XPControlPanel(Gtk.Window):
def __init__(self):
super().__init__(title="Control Panel")
self.set_wmclass("xp-control-panel", "xp-control-panel")
self.set_default_size(740, 480)
prov = Gtk.CssProvider()
prov.load_from_data(CP_CSS)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), prov, Gtk.STYLE_PROVIDER_PRIORITY_USER
)
root = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
self.add(root)
# Left Luna Task Sidebar
sidebar = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
sidebar.set_size_request(198, -1)
sidebar.get_style_context().add_class("xp-cp-sidebar")
sidebar.pack_start(self._make_card("Control Panel", [
("Display Properties", lambda: self._launch("/home/carsten/.local/bin/xp-display-properties")),
("Change Wallpaper", lambda: self._launch("/home/carsten/.local/bin/xp-display-properties --desktop")),
("Sounds and Audio", lambda: open_sounds_dialog(self)),
("User Account Picture", lambda: open_user_accounts_dialog(self)),
]), False, False, 0)
sidebar.pack_start(self._make_card("See Also", [
("Windows Task Manager", lambda: self._launch("/home/carsten/.local/bin/xp-taskmgr")),
("Run Command...", lambda: self._launch("/home/carsten/.local/bin/xp-run")),
("System Information", lambda: open_system_props_dialog(self)),
]), False, False, 0)
root.pack_start(sidebar, False, False, 0)
# Right White Main Applet Grid
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
main_box.get_style_context().add_class("xp-cp-main")
fb = Gtk.FlowBox()
fb.set_valign(Gtk.Align.START)
fb.set_max_children_per_line(3)
fb.set_min_children_per_line(2)
fb.set_selection_mode(Gtk.SelectionMode.NONE)
fb.set_row_spacing(10)
fb.set_column_spacing(12)
fb.set_homogeneous(True)
applets = [
("apps/preferences-desktop-display.png", "Display", "Themes, wallpaper & cursors",
lambda: self._launch("/home/carsten/.local/bin/xp-display-properties")),
("devices/audio-speakers.png", "Sounds and Audio", "XP sounds & volume mixer",
lambda: open_sounds_dialog(self)),
("apps/preferences-system-network.png", "Network Connections", "Wi-Fi, Ethernet & VPN",
lambda: self._launch("nm-connection-editor")),
("apps/preferences-desktop-peripherals.png", "Bluetooth Devices", "Pair & manage Bluetooth",
lambda: self._launch("blueman-manager")),
("devices/video-display.png", "Monitor Layout", "Resolution & displays",
lambda: self._launch("nwg-displays")),
("apps/preferences-desktop-personal.png", "User Accounts", "Change user picture",
lambda: open_user_accounts_dialog(self)),
("apps/preferences-system.png", "Task Manager", "Apps, processes & CPU",
lambda: self._launch("/home/carsten/.local/bin/xp-taskmgr")),
("devices/system.png", "System", "Hardware & OS info",
lambda: open_system_props_dialog(self)),
("apps/preferences-desktop-theme.png", "Date and Time", "Clock & calendar",
lambda: self._launch("/home/carsten/.local/bin/xp-calendar-popup")),
("apps/preferences-other.png", "GTK Look & Feel", "Advanced widget settings",
lambda: self._launch("nwg-look")),
("apps/preferences-desktop-font.png", "Qt6 Appearance", "Qt app theme & fonts",
lambda: self._launch("qt6ct")),
("actions/system-run.png", "Run...", "Launch a command",
lambda: self._launch("/home/carsten/.local/bin/xp-run")),
]
for icon_rel, title, desc, cb in applets:
btn = Gtk.Button()
btn.get_style_context().add_class("xp-cp-tile")
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
row.pack_start(load_luna_icon(icon_rel, 32), False, False, 0)
col = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
col.set_valign(Gtk.Align.CENTER)
t_lbl = Gtk.Label(label=title, xalign=0)
t_lbl.get_style_context().add_class("xp-cp-tile-title")
d_lbl = Gtk.Label(label=desc, xalign=0)
d_lbl.set_ellipsize(Pango.EllipsizeMode.END)
d_lbl.get_style_context().add_class("xp-cp-tile-desc")
col.pack_start(t_lbl, False, False, 0)
col.pack_start(d_lbl, False, False, 0)
row.pack_start(col, True, True, 0)
btn.add(row)
btn.connect("clicked", lambda _b, fn=cb: fn())
fb.add(btn)
main_box.pack_start(fb, True, True, 0)
sw.add(main_box)
root.pack_start(sw, True, True, 0)
self.connect("key-press-event", lambda _w, ev: Gtk.main_quit() if ev.keyval == Gdk.KEY_Escape else False)
self.connect("destroy", Gtk.main_quit)
def _make_card(self, title, links):
card = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
card.get_style_context().add_class("xp-cp-card")
hdr = Gtk.Label(label=title, xalign=0)
hdr.get_style_context().add_class("xp-cp-card-hdr")
card.pack_start(hdr, False, False, 0)
body = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
body.get_style_context().add_class("xp-cp-card-body")
for text, cb in links:
b = Gtk.Button()
b.get_style_context().add_class("xp-cp-link")
lbl = Gtk.Label(label=text, xalign=0)
b.add(lbl)
b.connect("clicked", lambda _b, fn=cb: fn())
body.pack_start(b, False, False, 0)
card.pack_start(body, False, False, 0)
return card
def _launch(self, cmd):
subprocess.Popen(["hyprctl", "dispatch", "exec", cmd],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def main():
if "--sounds" in sys.argv:
open_sounds_dialog()
return
if "--users" in sys.argv:
open_user_accounts_dialog()
return
win = XPControlPanel()
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
+474
View File
@@ -0,0 +1,474 @@
#!/usr/bin/env python3
"""Native Windows XP Display Properties (Themes, Desktop Wallpaper, Appearance)."""
import os
import subprocess
import sys
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")
from gi.repository import Gtk, Gdk, GdkPixbuf
THEME_ENV = Path("/home/carsten/.config/hypr/xp-theme.env")
HYPRPAPER_CONF = Path("/home/carsten/.config/hypr/hyprpaper.conf")
WALL_DIR = Path("/usr/local/share/backgrounds/wintc")
THEME_SWITCH = "/home/carsten/.local/bin/xp-theme-switch"
THEMES = [
("luna-blue", "Windows XP (Default Blue)", "#0053E3", "#3D94FF", "#ECE9D8", "#2257D5", "#3C9E3E", "#7A97DF"),
("luna-homestead", "Windows XP (Olive Green)", "#8BA169", "#C6D2A2", "#ECE9D8", "#8EA46C", "#C76C23", "#D4D6BA"),
("luna-metallic", "Windows XP (Silver)", "#808391", "#C8C8C8", "#E0DFE3", "#B2B4C2", "#3C9E3E", "#D8D9E0"),
("royale", "Media Center style (Royale)", "#335EA8", "#70B1EB", "#EBE9ED", "#2B5CA8", "#3C9E3E", "#6FA1D9"),
("royale-noir", "Media Center style (Royale Noir)","#272F42","#5C6976", "#EBE9ED", "#1F2636", "#2A3244", "#5F6772"),
("zune", "Zune style", "#343434", "#747474", "#E2E2E2", "#282828", "#E36B14", "#747474"),
("embedded", "Embedded style", "#3E9DE8", "#70B1EB", "#EBE9ED", "#246EAE", "#2C7EC4", "#6FA1D9"),
("professional", "Professional", "#5298F9", "#3573D6", "#ECE9D8", "#3573D6", "#3C9E3E", "#2C60B2"),
("classic", "Windows Classic", "#0A246A", "#A6CAF0", "#D4D0C8", "#D4D0C8", "#D4D0C8", "#808080"),
]
def hex_rgb(h):
h = h.lstrip("#")
return tuple(int(h[i:i+2], 16) / 255.0 for i in (0, 2, 4))
def read_current_env():
vals = {
"XP_THEME_KEY": "luna-blue",
"XP_WALLPAPER": "/usr/local/share/backgrounds/wintc/bliss.jpg",
"XP_CURSOR_THEME": "standard-with-shadow",
"XP_CURSOR_SIZE": "24",
}
if THEME_ENV.exists():
for line in THEME_ENV.read_text(encoding="utf-8").splitlines():
if "=" in line and not line.strip().startswith("#"):
k, v = line.split("=", 1)
vals[k.strip()] = v.strip().strip('"').strip("'")
return vals
class CRTMonitorPreview(Gtk.DrawingArea):
"""Iconic Windows XP Display Properties CRT monitor preview."""
def __init__(self):
super().__init__()
self.set_size_request(260, 178)
self.theme_info = THEMES[0]
self.wall_path = "/usr/local/share/backgrounds/wintc/bliss.jpg"
self.wall_pb = None
self.connect("draw", self.on_draw)
self._load_wall()
def set_theme(self, theme_tuple):
self.theme_info = theme_tuple
self.queue_draw()
def set_wallpaper(self, path):
if path != self.wall_path:
self.wall_path = path
self._load_wall()
self.queue_draw()
def _load_wall(self):
self.wall_pb = None
if self.wall_path and os.path.exists(self.wall_path):
try:
self.wall_pb = GdkPixbuf.Pixbuf.new_from_file_at_scale(self.wall_path, 184, 114, False)
except Exception:
self.wall_pb = None
def on_draw(self, _widget, cr):
alloc = self.get_allocation()
cx = alloc.width / 2.0
# Monitor outer bezel (classic beige/gray CRT frame)
mw, mh = 208, 138
mx, my = cx - mw / 2.0, 6
cr.set_source_rgb(0.78, 0.77, 0.72)
cr.rectangle(mx, my, mw, mh)
cr.fill()
cr.set_source_rgb(0.95, 0.94, 0.90)
cr.set_line_width(1.5)
cr.move_to(mx, my + mh)
cr.line_to(mx, my)
cr.line_to(mx + mw, my)
cr.stroke()
cr.set_source_rgb(0.45, 0.44, 0.40)
cr.move_to(mx + mw, my)
cr.line_to(mx + mw, my + mh)
cr.line_to(mx, my + mh)
cr.stroke()
# Monitor stand neck & base
cr.set_source_rgb(0.68, 0.67, 0.63)
cr.rectangle(cx - 26, my + mh, 52, 14)
cr.fill()
cr.set_source_rgb(0.78, 0.77, 0.72)
cr.rectangle(cx - 56, my + mh + 14, 112, 10)
cr.fill()
cr.set_source_rgb(0.45, 0.44, 0.40)
cr.rectangle(cx - 56, my + mh + 14, 112, 10)
cr.stroke()
# Power LED
cr.set_source_rgb(0.15, 0.80, 0.25)
cr.arc(mx + mw - 14, my + mh - 6, 2.2, 0, 6.283)
cr.fill()
# Inner screen viewport (184x114)
sx, sy, sw, sh = int(mx + 12), int(my + 10), 184, 114
cr.save()
cr.rectangle(sx, sy, sw, sh)
cr.clip()
# Wallpaper
if self.wall_pb:
Gdk.cairo_set_source_pixbuf(cr, self.wall_pb, sx, sy)
cr.paint()
else:
cr.set_source_rgb(0.23, 0.43, 0.65)
cr.rectangle(sx, sy, sw, sh)
cr.fill()
_, _, hdr1, hdr2, bg, bar_c, start_c, ihdr = self.theme_info
# Mini inactive window
ix, iy, iw, ih = sx + 10, sy + 10, 104, 62
cr.set_source_rgb(*hex_rgb(bg))
cr.rectangle(ix, iy, iw, ih)
cr.fill()
cr.set_source_rgb(*hex_rgb(ihdr))
cr.rectangle(ix, iy, iw, 13)
cr.fill()
cr.set_source_rgb(*hex_rgb(ihdr))
cr.set_line_width(1)
cr.rectangle(ix + 0.5, iy + 0.5, iw - 1, ih - 1)
cr.stroke()
# Mini active window
ax, ay, aw, ah = sx + 38, sy + 28, 128, 66
cr.set_source_rgb(*hex_rgb(bg))
cr.rectangle(ax, ay, aw, ah)
cr.fill()
pat = cairo.LinearGradient(ax, ay, ax, ay + 15)
pat.add_color_stop_rgb(0.0, *hex_rgb(hdr2))
pat.add_color_stop_rgb(1.0, *hex_rgb(hdr1))
cr.set_source(pat)
cr.rectangle(ax, ay, aw, 15)
cr.fill()
# Mini close button
cr.set_source_rgb(0.87, 0.28, 0.15)
cr.rectangle(ax + aw - 12, ay + 3, 9, 9)
cr.fill()
# Mini white content box & OK button
cr.set_source_rgb(1, 1, 1)
cr.rectangle(ax + 6, ay + 20, aw - 12, 26)
cr.fill()
cr.set_source_rgb(0.95, 0.94, 0.91)
cr.rectangle(ax + aw - 38, ay + ah - 15, 32, 11)
cr.fill()
cr.set_source_rgb(*hex_rgb(hdr1))
cr.rectangle(ax + 0.5, ay + 0.5, aw - 1, ah - 1)
cr.stroke()
# Mini Taskbar + Start button
tb_h = 13
cr.set_source_rgb(*hex_rgb(bar_c))
cr.rectangle(sx, sy + sh - tb_h, sw, tb_h)
cr.fill()
cr.set_source_rgb(*hex_rgb(start_c))
cr.rectangle(sx, sy + sh - tb_h, 30, tb_h)
cr.fill()
cr.restore()
# Screen inset border
cr.set_source_rgb(0.25, 0.25, 0.25)
cr.set_line_width(1)
cr.rectangle(sx - 0.5, sy - 0.5, sw + 1, sh + 1)
cr.stroke()
class XPDisplayProperties(Gtk.Window):
def __init__(self, initial_tab=0):
super().__init__(title="Display Properties")
self.set_wmclass("xp-display-properties", "xp-display-properties")
self.set_resizable(False)
self.set_default_size(404, 468)
self.set_border_width(8)
self.env = read_current_env()
self.selected_theme_key = self.env["XP_THEME_KEY"]
self.selected_wallpaper = self.env["XP_WALLPAPER"]
self.selected_cursor = self.env["XP_CURSOR_THEME"]
self.selected_cursor_size = int(self.env.get("XP_CURSOR_SIZE", "24") or 24)
root = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
self.add(root)
self.notebook = Gtk.Notebook()
root.pack_start(self.notebook, True, True, 0)
self.previews = []
self._build_themes_tab()
self._build_desktop_tab()
self._build_appearance_tab()
self.notebook.set_current_page(initial_tab)
# Bottom OK / Cancel / Apply
btns = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
btns.set_halign(Gtk.Align.END)
for lbl, cb in [("OK", self.on_ok), ("Cancel", lambda *_: Gtk.main_quit()), ("Apply", self.on_apply)]:
b = Gtk.Button.new_with_label(lbl)
b.set_size_request(76, 24)
b.connect("clicked", cb)
btns.pack_start(b, False, False, 0)
root.pack_end(btns, False, False, 0)
self.sync_previews()
self.connect("key-press-event", lambda _w, ev: Gtk.main_quit() if ev.keyval == Gdk.KEY_Escape else False)
self.connect("destroy", Gtk.main_quit)
def sync_previews(self):
tinfo = next((t for t in THEMES if t[0] == self.selected_theme_key), THEMES[0])
for p in self.previews:
p.set_theme(tinfo)
p.set_wallpaper(self.selected_wallpaper)
def _build_themes_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
box.set_border_width(12)
desc = Gtk.Label(label="A theme is a background plus a set of sounds, icons, and other elements to help you personalize your computer with one click.")
desc.set_line_wrap(True)
desc.set_max_width_chars(52)
desc.set_xalign(0.0)
box.pack_start(desc, False, False, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
lbl = Gtk.Label(label="Theme:")
row.pack_start(lbl, False, False, 0)
self.theme_combo = Gtk.ComboBoxText()
active_idx = 0
for idx, t in enumerate(THEMES):
self.theme_combo.append(t[0], t[1])
if t[0] == self.selected_theme_key:
active_idx = idx
self.theme_combo.set_active(active_idx)
self.theme_combo.connect("changed", self._on_theme_changed)
row.pack_start(self.theme_combo, True, True, 0)
box.pack_start(row, False, False, 0)
frame = Gtk.Frame(label=" Sample: ")
prev = CRTMonitorPreview()
prev.set_margin_top(6)
prev.set_margin_bottom(6)
frame.add(prev)
self.previews.append(prev)
box.pack_start(frame, True, True, 0)
self.notebook.append_page(box, Gtk.Label(label="Themes"))
def _build_desktop_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
box.set_border_width(12)
prev = CRTMonitorPreview()
self.previews.append(prev)
box.pack_start(prev, False, False, 0)
lbl = Gtk.Label(label="Background:")
lbl.set_xalign(0.0)
box.pack_start(lbl, False, False, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
sw = Gtk.ScrolledWindow()
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
sw.set_shadow_type(Gtk.ShadowType.IN)
sw.set_size_request(260, 145)
self.wall_store = Gtk.ListStore(str, str)
walls = sorted(WALL_DIR.glob("*")) if WALL_DIR.exists() else []
sel_iter = None
for wp in walls:
if wp.suffix.lower() in (".jpg", ".jpeg", ".png", ".bmp"):
it = self.wall_store.append([wp.stem.capitalize(), str(wp)])
if str(wp) == self.selected_wallpaper:
sel_iter = it
self.wall_view = Gtk.TreeView(model=self.wall_store)
self.wall_view.set_headers_visible(False)
col = Gtk.TreeViewColumn("Wallpaper", Gtk.CellRendererText(), text=0)
self.wall_view.append_column(col)
sel = self.wall_view.get_selection()
if sel_iter:
sel.select_iter(sel_iter)
self.wall_view.scroll_to_cell(self.wall_store.get_path(sel_iter))
sel.connect("changed", self._on_wall_selected)
sw.add(self.wall_view)
row.pack_start(sw, True, True, 0)
side = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
browse = Gtk.Button.new_with_label("Browse...")
browse.set_size_request(82, 24)
browse.connect("clicked", self._on_browse_wall)
side.pack_start(browse, False, False, 0)
row.pack_start(side, False, False, 0)
box.pack_start(row, True, True, 0)
self.notebook.append_page(box, Gtk.Label(label="Desktop"))
def _build_appearance_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
box.set_border_width(12)
prev = CRTMonitorPreview()
self.previews.append(prev)
box.pack_start(prev, False, False, 0)
grid = Gtk.Grid()
grid.set_row_spacing(8)
grid.set_column_spacing(10)
grid.attach(Gtk.Label(label="Color scheme:", xalign=0), 0, 0, 1, 1)
self.scheme_combo = Gtk.ComboBoxText()
active_idx = 0
for idx, t in enumerate(THEMES):
self.scheme_combo.append(t[0], t[1])
if t[0] == self.selected_theme_key:
active_idx = idx
self.scheme_combo.set_active(active_idx)
self.scheme_combo.connect("changed", self._on_scheme_changed)
grid.attach(self.scheme_combo, 1, 0, 1, 1)
grid.attach(Gtk.Label(label="Mouse pointer:", xalign=0), 0, 1, 1, 1)
self.cursor_combo = Gtk.ComboBoxText()
self.cursor_combo.append("standard-with-shadow", "Windows XP Standard (with shadow)")
self.cursor_combo.append("standard-no-shadow", "Windows XP Standard (no shadow)")
self.cursor_combo.set_active_id(self.selected_cursor)
grid.attach(self.cursor_combo, 1, 1, 1, 1)
grid.attach(Gtk.Label(label="Pointer size:", xalign=0), 0, 2, 1, 1)
self.csize_combo = Gtk.ComboBoxText()
for sz in ("24", "32"):
self.csize_combo.append(sz, f"{sz} px")
self.csize_combo.set_active_id(str(self.selected_cursor_size))
grid.attach(self.csize_combo, 1, 2, 1, 1)
box.pack_start(grid, False, False, 4)
self.notebook.append_page(box, Gtk.Label(label="Appearance"))
def _on_theme_changed(self, combo):
tid = combo.get_active_id()
if tid and tid != self.selected_theme_key:
self.selected_theme_key = tid
if hasattr(self, "scheme_combo"):
self.scheme_combo.set_active_id(tid)
self.sync_previews()
def _on_scheme_changed(self, combo):
tid = combo.get_active_id()
if tid and tid != self.selected_theme_key:
self.selected_theme_key = tid
self.theme_combo.set_active_id(tid)
self.sync_previews()
def _on_wall_selected(self, selection):
model, it = selection.get_selected()
if it:
self.selected_wallpaper = model[it][1]
self.sync_previews()
def _on_browse_wall(self, _btn):
dlg = Gtk.FileChooserDialog(
title="Select Wallpaper",
parent=self,
action=Gtk.FileChooserAction.OPEN,
buttons=("Cancel", Gtk.ResponseType.CANCEL, "Open", Gtk.ResponseType.OK),
)
flt = Gtk.FileFilter()
flt.set_name("Images")
for pat in ("*.png", "*.jpg", "*.jpeg", "*.bmp", "*.webp"):
flt.add_pattern(pat)
dlg.add_filter(flt)
if dlg.run() == Gtk.ResponseType.OK:
fn = dlg.get_filename()
if fn:
self.selected_wallpaper = fn
self.sync_previews()
dlg.destroy()
def apply_changes(self):
# 1. Apply visual style if changed
if self.selected_theme_key != self.env["XP_THEME_KEY"]:
subprocess.run([THEME_SWITCH, self.selected_theme_key], check=False)
self.env["XP_THEME_KEY"] = self.selected_theme_key
# 2. Apply wallpaper via hyprpaper + persist to hyprpaper.conf & xp-theme.env
if self.selected_wallpaper and os.path.exists(self.selected_wallpaper):
HYPRPAPER_CONF.write_text(
f"splash = false\nwallpaper {{\n monitor =\n path = {self.selected_wallpaper}\n fit_mode = cover\n}}\n",
encoding="utf-8",
)
subprocess.run(["hyprctl", "hyprpaper", "wallpaper", f",{self.selected_wallpaper},cover"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False)
self.env["XP_WALLPAPER"] = self.selected_wallpaper
# 3. Apply cursor theme & size
ctheme = self.cursor_combo.get_active_id() or "standard-with-shadow"
csize = self.csize_combo.get_active_id() or "24"
subprocess.run(["hyprctl", "setcursor", ctheme, csize],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False)
subprocess.run(
["gsettings", "set", "org.gnome.desktop.interface", "cursor-theme", ctheme],
env={**os.environ, "DCONF_PROFILE": "/home/carsten/.config/hypr/dconf/profile"},
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False,
)
subprocess.run(
["gsettings", "set", "org.gnome.desktop.interface", "cursor-size", csize],
env={**os.environ, "DCONF_PROFILE": "/home/carsten/.config/hypr/dconf/profile"},
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=False,
)
# Persist wallpaper & cursor in xp-theme.env
if THEME_ENV.exists():
lines = []
for line in THEME_ENV.read_text(encoding="utf-8").splitlines():
if line.startswith("XP_WALLPAPER="):
lines.append(f'XP_WALLPAPER="{self.selected_wallpaper}"')
elif line.startswith("XP_CURSOR_THEME="):
lines.append(f'XP_CURSOR_THEME="{ctheme}"')
elif line.startswith("XP_CURSOR_SIZE="):
lines.append(f'XP_CURSOR_SIZE="{csize}"')
else:
lines.append(line)
THEME_ENV.write_text("\n".join(lines) + "\n", encoding="utf-8")
def on_apply(self, _btn):
self.apply_changes()
def on_ok(self, _btn):
self.apply_changes()
Gtk.main_quit()
def main():
tab = 0
if "--desktop" in sys.argv:
tab = 1
elif "--appearance" in sys.argv:
tab = 2
win = XPDisplayProperties(initial_tab=tab)
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
Executable
+204
View File
@@ -0,0 +1,204 @@
#!/usr/bin/env python3
"""Native Windows XP Run dialog (shell32.dll style) for Hyprland."""
import json
import os
import shlex
import subprocess
import sys
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")
from gi.repository import Gtk, Gdk, GdkPixbuf
HISTORY_PATH = Path("/home/carsten/.local/share/xp-run/history.json")
RUN_ICON = "/usr/local/share/icons/luna/32x32/actions/system-run.png"
SOUND_SCRIPT = "/home/carsten/.config/hypr/scripts/xp-sound.sh"
XP_ALIASES = {
"cmd": "ghostty",
"cmd.exe": "ghostty",
"explorer": "thunar",
"explorer.exe": "thunar",
"notepad": "mousepad",
"notepad.exe": "mousepad",
"control": "/home/carsten/.local/bin/xp-control-panel",
"control.exe": "/home/carsten/.local/bin/xp-control-panel",
"desk.cpl": "/home/carsten/.local/bin/xp-display-properties",
"mmsys.cpl": "/home/carsten/.local/bin/xp-control-panel --sounds",
"timedate.cpl": "/home/carsten/.local/bin/xp-calendar-popup",
"taskmgr": "/home/carsten/.local/bin/xp-taskmgr",
"taskmgr.exe": "/home/carsten/.local/bin/xp-taskmgr",
"sndvol32": "pavucontrol",
"sndvol32.exe": "pavucontrol",
"mspaint": "swappy",
"mspaint.exe": "swappy",
}
def load_history():
try:
if HISTORY_PATH.exists():
data = json.loads(HISTORY_PATH.read_text(encoding="utf-8"))
if isinstance(data, list):
return [str(x) for x in data[:25]]
except Exception:
pass
return ["cmd", "control", "taskmgr", "desk.cpl", "thunar", "firefox"]
def save_history(cmd, hist):
cleaned = [cmd] + [x for x in hist if x != cmd]
HISTORY_PATH.parent.mkdir(parents=True, exist_ok=True)
HISTORY_PATH.write_text(json.dumps(cleaned[:25], indent=2), encoding="utf-8")
class XPRunDialog(Gtk.Window):
def __init__(self):
super().__init__(title="Run")
self.set_wmclass("xp-run", "xp-run")
self.set_role("xp-run")
self.set_resizable(False)
self.set_default_size(368, 152)
self.set_border_width(12)
self.history = load_history()
root = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
self.add(root)
# Top row: 32x32 Run icon + classic XP description
top = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
if os.path.exists(RUN_ICON):
pb = GdkPixbuf.Pixbuf.new_from_file_at_scale(RUN_ICON, 32, 32, True)
icon = Gtk.Image.new_from_pixbuf(pb)
else:
icon = Gtk.Image.new_from_icon_name("system-run", Gtk.IconSize.DND)
icon.set_valign(Gtk.Align.START)
top.pack_start(icon, False, False, 0)
desc = Gtk.Label(
label="Type the name of a program, folder, document, or\nInternet resource, and Windows will open it for you."
)
desc.set_xalign(0.0)
desc.set_yalign(0.0)
top.pack_start(desc, True, True, 0)
root.pack_start(top, False, False, 0)
# Middle row: "Open:" label + editable combobox with MRU history
mid = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
lbl = Gtk.Label.new_with_mnemonic("_Open:")
lbl.set_xalign(0.0)
mid.pack_start(lbl, False, False, 0)
self.combo = Gtk.ComboBoxText.new_with_entry()
for item in self.history:
self.combo.append_text(item)
self.entry = self.combo.get_child()
self.entry.set_activates_default(True)
if self.history:
self.entry.set_text(self.history[0])
self.entry.select_region(0, -1)
lbl.set_mnemonic_widget(self.entry)
mid.pack_start(self.combo, True, True, 0)
root.pack_start(mid, False, False, 2)
# Bottom row: OK / Cancel / Browse...
btns = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
btns.set_halign(Gtk.Align.END)
ok_btn = Gtk.Button.new_with_label("OK")
ok_btn.set_size_request(76, 24)
ok_btn.set_can_default(True)
ok_btn.connect("clicked", self.on_ok)
btns.pack_start(ok_btn, False, False, 0)
cancel_btn = Gtk.Button.new_with_label("Cancel")
cancel_btn.set_size_request(76, 24)
cancel_btn.connect("clicked", lambda *_: Gtk.main_quit())
btns.pack_start(cancel_btn, False, False, 0)
browse_btn = Gtk.Button.new_with_mnemonic("_Browse...")
browse_btn.set_size_request(76, 24)
browse_btn.connect("clicked", self.on_browse)
btns.pack_start(browse_btn, False, False, 0)
root.pack_end(btns, False, False, 0)
self.set_default(ok_btn)
self.connect("key-press-event", self.on_key)
self.connect("destroy", Gtk.main_quit)
def on_key(self, _w, ev):
if ev.keyval == Gdk.KEY_Escape:
Gtk.main_quit()
return True
return False
def on_browse(self, _btn):
dlg = Gtk.FileChooserDialog(
title="Browse",
parent=self,
action=Gtk.FileChooserAction.OPEN,
buttons=("Cancel", Gtk.ResponseType.CANCEL, "Open", Gtk.ResponseType.OK),
)
dlg.set_current_folder(str(Path.home()))
if dlg.run() == Gtk.ResponseType.OK:
path = dlg.get_filename()
if path:
self.entry.set_text(shlex.quote(path))
dlg.destroy()
def on_ok(self, _btn):
raw = self.entry.get_text().strip()
if not raw:
return
save_history(raw, self.history)
low = raw.lower()
expanded = os.path.expanduser(raw)
if low in XP_ALIASES:
cmd = XP_ALIASES[low]
elif raw.startswith(("http://", "https://", "www.")):
url = raw if raw.startswith("http") else f"https://{raw}"
cmd = f"firefox {shlex.quote(url)}"
elif os.path.isdir(expanded):
cmd = f"thunar {shlex.quote(expanded)}"
elif os.path.isfile(expanded) and not os.access(expanded, os.X_OK):
cmd = f"xdg-open {shlex.quote(expanded)}"
else:
cmd = raw
try:
subprocess.Popen(["hyprctl", "dispatch", "exec", cmd],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
except Exception as exc:
subprocess.Popen([SOUND_SCRIPT, "error"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
err = Gtk.MessageDialog(
transient_for=self,
message_type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.OK,
text=f"Windows cannot find '{raw}'.",
)
err.format_secondary_text(str(exc))
err.run()
err.destroy()
return
Gtk.main_quit()
def main():
win = XPRunDialog()
win.show_all()
win.entry.grab_focus()
Gtk.main()
if __name__ == "__main__":
main()
+90
View File
@@ -0,0 +1,90 @@
#!/usr/bin/env python3
"""Windows XP System Event Sound Daemon (USB insert/remove & battery warnings)."""
import fcntl
import os
import subprocess
import sys
import threading
import time
from pathlib import Path
LOCK_PATH = f"/run/user/{os.getuid()}/xp-sound-daemon.lock"
SOUND_SCRIPT = "/home/carsten/.config/hypr/scripts/xp-sound.sh"
def play(name):
subprocess.Popen([SOUND_SCRIPT, name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def usb_monitor():
last_event = {"add": 0.0, "remove": 0.0}
while True:
try:
proc = subprocess.Popen(
["udevadm", "monitor", "--udev", "--subsystem-match=usb"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
text=True,
bufsize=1,
)
for line in proc.stdout:
if "(usb)" not in line:
continue
# Filter to top-level USB devices (avoid firing multiple times for sub-interfaces like 1-2:1.0)
if ":" in line.rsplit("/", 1)[-1]:
continue
now = time.monotonic()
if " add " in line and now - last_event["add"] > 1.0:
last_event["add"] = now
play("hardware-insert")
elif " remove " in line and now - last_event["remove"] > 1.0:
last_event["remove"] = now
play("hardware-removed")
proc.wait()
except Exception:
time.sleep(5)
def battery_monitor():
warned_low = False
warned_crit = False
while True:
try:
bats = list(Path("/sys/class/power_supply").glob("BAT*"))
if bats:
bat = bats[0]
status = (bat / "status").read_text().strip().lower()
cap = int((bat / "capacity").read_text().strip())
if status == "discharging":
if cap <= 7 and not warned_crit:
warned_crit = True
warned_low = True
play("battery-critical")
elif cap <= 15 and not warned_low:
warned_low = True
play("battery-low")
else:
warned_low = False
warned_crit = False
except Exception:
pass
time.sleep(30)
def main():
lock_fd = open(LOCK_PATH, "w")
try:
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except BlockingIOError:
sys.exit(0)
t_usb = threading.Thread(target=usb_monitor, daemon=True)
t_bat = threading.Thread(target=battery_monitor, daemon=True)
t_usb.start()
t_bat.start()
t_usb.join()
if __name__ == "__main__":
main()
+3 -4
View File
@@ -727,10 +727,9 @@ class XPStartMenuDaemon:
self.menubar_places.append(Gtk.SeparatorMenuItem())
tools_mid = [
("preferences-other", "Control Panel", "Configure GTK appearance, widgets, and icons.", ["nwg-look"]),
("preferences-desktop-display", "Display Properties", "Configure monitor resolution and layout.", ["nwg-displays"]),
("preferences-desktop-theme", "Visual Style...", "Switch between all 9 Windows XP visual styles.", [THEME_SWITCH_BIN, "--menu"]),
("preferences-desktop", "Wallpaper...", "Choose a desktop background wallpaper.", [WALLPAPER_SCRIPT]),
("preferences-other", "Control Panel", "Open Windows XP Control Panel and system settings.", ["/home/carsten/.local/bin/xp-control-panel"]),
("preferences-desktop-display", "Display Properties", "Change visual styles, desktop wallpaper, and cursors.", ["/home/carsten/.local/bin/xp-display-properties"]),
("preferences-system", "Task Manager", "View running applications, processes, and CPU/RAM performance.", ["/home/carsten/.local/bin/xp-taskmgr"]),
("audio-volume-high", "Volume Control", "Adjust audio output and input volume levels.", ["pavucontrol"]),
]
for icon_name, label_text, tip, cmd in tools_mid:
Executable
+494
View File
@@ -0,0 +1,494 @@
#!/usr/bin/env python3
"""Native Windows XP Task Manager (Applications, Processes, Performance)."""
import collections
import json
import os
import pwd
import signal
import subprocess
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")
from gi.repository import Gtk, Gdk, GLib
def read_cpu_times():
try:
parts = Path("/proc/stat").read_text().splitlines()[0].split()[1:]
vals = [int(x) for x in parts[:8]]
idle = vals[3] + vals[4]
total = sum(vals)
return idle, total
except Exception:
return 0, 1
def read_meminfo():
info = {}
try:
for line in Path("/proc/meminfo").read_text().splitlines():
k, v = line.split(":", 1)
info[k.strip()] = int(v.strip().split()[0])
except Exception:
pass
return info
def read_processes(prev_proc_ticks, total_delta, ncpu):
procs = []
new_ticks = {}
uid_cache = {}
clk_tck = os.sysconf("SC_CLK_TCK")
page_kb = os.sysconf("SC_PAGE_SIZE") // 1024
for entry in os.scandir("/proc"):
if not entry.name.isdigit():
continue
pid = int(entry.name)
try:
stat_txt = Path(f"/proc/{pid}/stat").read_text()
rp = stat_txt.rfind(")")
comm = stat_txt[stat_txt.find("(") + 1:rp]
fields = stat_txt[rp + 2:].split()
utime, stime = int(fields[11]), int(fields[12])
rss_kb = int(fields[21]) * page_kb
ticks = utime + stime
new_ticks[pid] = ticks
cpu_pct = 0.0
if pid in prev_proc_ticks and total_delta > 0:
cpu_pct = 100.0 * (ticks - prev_proc_ticks[pid]) * ncpu / float(total_delta)
cpu_pct = max(0.0, min(99.9, cpu_pct))
uid = os.stat(entry.path).st_uid
if uid not in uid_cache:
try:
uid_cache[uid] = pwd.getpwuid(uid).pw_name
except KeyError:
uid_cache[uid] = str(uid)
procs.append((comm, uid_cache[uid], int(round(cpu_pct)), rss_kb, pid))
except Exception:
continue
procs.sort(key=lambda r: (r[2], r[3]), reverse=True)
return procs, new_ticks
class XPGraph(Gtk.DrawingArea):
"""Iconic Windows XP Task Manager green-on-black oscilloscope graph."""
def __init__(self, history_len=60):
super().__init__()
self.set_size_request(240, 86)
self.values = collections.deque([0.0] * history_len, maxlen=history_len)
self.grid_offset = 0
self.connect("draw", self.on_draw)
def push(self, pct):
self.values.append(max(0.0, min(100.0, pct)))
self.grid_offset = (self.grid_offset + 4) % 12
self.queue_draw()
def on_draw(self, _w, cr):
a = self.get_allocation()
w, h = a.width, a.height
# Pitch black oscilloscope background
cr.set_source_rgb(0.0, 0.0, 0.0)
cr.rectangle(0, 0, w, h)
cr.fill()
# Classic #008040 dark-green 12x12 grid
cr.set_source_rgb(0.0, 0.45, 0.22)
cr.set_line_width(1.0)
for x in range(w - self.grid_offset, 0, -12):
cr.move_to(x + 0.5, 0)
cr.line_to(x + 0.5, h)
for y in range(12, h, 12):
cr.move_to(0, y + 0.5)
cr.line_to(w, y + 0.5)
cr.stroke()
# Bright #00FF00 trace
n = len(self.values)
if n > 1:
cr.set_source_rgb(0.0, 1.0, 0.0)
cr.set_line_width(1.3)
for i, val in enumerate(self.values):
x = (i / float(n - 1)) * (w - 2) + 1
y = (h - 2) - (val / 100.0) * (h - 4)
if i == 0:
cr.move_to(x, y)
else:
cr.line_to(x, y)
cr.stroke()
# Sunken 1px inset border
cr.set_source_rgb(0.5, 0.5, 0.5)
cr.set_line_width(1.0)
cr.rectangle(0.5, 0.5, w - 1, h - 1)
cr.stroke()
class XPMeter(Gtk.DrawingArea):
"""Iconic Windows XP vertical LED bar meter."""
def __init__(self):
super().__init__()
self.set_size_request(76, 86)
self.pct = 0.0
self.connect("draw", self.on_draw)
def set_value(self, pct):
self.pct = max(0.0, min(100.0, pct))
self.queue_draw()
def on_draw(self, _w, cr):
a = self.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()
bar_top, bar_bot = 8, h - 22
bar_h = max(10, bar_bot - bar_top)
lit_y = bar_bot - int((self.pct / 100.0) * bar_h)
# Dual green LED columns
col_w = 14
x1 = w // 2 - col_w - 2
x2 = w // 2 + 2
for y in range(bar_bot - 3, bar_top, -3):
if y >= lit_y:
cr.set_source_rgb(0.0, 1.0, 0.0)
else:
cr.set_source_rgb(0.0, 0.35, 0.16)
cr.rectangle(x1, y, col_w, 2)
cr.rectangle(x2, y, col_w, 2)
cr.fill()
# Percentage readout
cr.set_source_rgb(0.0, 1.0, 0.0)
cr.select_font_face("Tahoma", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(11)
txt = f"{int(round(self.pct))}%"
ext = cr.text_extents(txt)
cr.move_to((w - ext.width) / 2.0, h - 7)
cr.show_text(txt)
cr.set_source_rgb(0.5, 0.5, 0.5)
cr.set_line_width(1.0)
cr.rectangle(0.5, 0.5, w - 1, h - 1)
cr.stroke()
class XPTaskManager(Gtk.Window):
def __init__(self):
super().__init__(title="Windows Task Manager")
self.set_wmclass("xp-taskmgr", "xp-taskmgr")
self.set_default_size(450, 500)
self.ncpu = os.cpu_count() or 1
self.prev_idle, self.prev_total = read_cpu_times()
self.prev_proc_ticks = {}
root = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
self.add(root)
# Menubar
mb = Gtk.MenuBar()
file_m = Gtk.MenuItem(label="File")
fm = Gtk.Menu()
mi_run = Gtk.MenuItem(label="New Task (Run...)")
mi_run.connect("activate", lambda *_: subprocess.Popen(["/home/carsten/.local/bin/xp-run"]))
mi_exit = Gtk.MenuItem(label="Exit Task Manager")
mi_exit.connect("activate", lambda *_: Gtk.main_quit())
fm.append(mi_run)
fm.append(Gtk.SeparatorMenuItem())
fm.append(mi_exit)
file_m.set_submenu(fm)
mb.append(file_m)
view_m = Gtk.MenuItem(label="View")
vm = Gtk.Menu()
mi_ref = Gtk.MenuItem(label="Refresh Now")
mi_ref.connect("activate", lambda *_: self.refresh())
vm.append(mi_ref)
view_m.set_submenu(vm)
mb.append(view_m)
root.pack_start(mb, False, False, 0)
# Tabs
self.nb = Gtk.Notebook()
self.nb.set_border_width(6)
root.pack_start(self.nb, True, True, 0)
self._build_apps_tab()
self._build_procs_tab()
self._build_perf_tab()
# Classic XP Statusbar
sb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
sb.set_border_width(4)
self.sb_procs = Gtk.Label(label="Processes: 0", xalign=0)
self.sb_cpu = Gtk.Label(label="CPU Usage: 0%", xalign=0)
self.sb_mem = Gtk.Label(label="Commit Charge: 0M / 0M", xalign=0)
sb.pack_start(self.sb_procs, False, False, 4)
sb.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0)
sb.pack_start(self.sb_cpu, False, False, 4)
sb.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), False, False, 0)
sb.pack_start(self.sb_mem, True, True, 4)
root.pack_end(sb, False, False, 0)
self.refresh()
GLib.timeout_add(1000, self.refresh)
self.connect("key-press-event", lambda _w, ev: Gtk.main_quit() if ev.keyval == Gdk.KEY_Escape else False)
self.connect("destroy", Gtk.main_quit)
def _build_apps_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
box.set_border_width(8)
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
self.apps_store = Gtk.ListStore(str, str, str) # title, status, address
self.apps_tv = Gtk.TreeView(model=self.apps_store)
c1 = Gtk.TreeViewColumn("Task", Gtk.CellRendererText(), text=0)
c1.set_expand(True)
c2 = Gtk.TreeViewColumn("Status", Gtk.CellRendererText(), text=1)
c2.set_min_width(80)
self.apps_tv.append_column(c1)
self.apps_tv.append_column(c2)
sw.add(self.apps_tv)
box.pack_start(sw, True, True, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
row.set_halign(Gtk.Align.END)
for lbl, cb in [
("End Task", self._on_end_task),
("Switch To", self._on_switch_to),
("New Task...", lambda *_: subprocess.Popen(["/home/carsten/.local/bin/xp-run"])),
]:
b = Gtk.Button.new_with_label(lbl)
b.set_size_request(86, 24)
b.connect("clicked", cb)
row.pack_start(b, False, False, 0)
box.pack_end(row, False, False, 0)
self.nb.append_page(box, Gtk.Label(label="Applications"))
def _build_procs_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
box.set_border_width(8)
sw = Gtk.ScrolledWindow()
sw.set_shadow_type(Gtk.ShadowType.IN)
self.procs_store = Gtk.ListStore(str, str, int, str, int, int) # name, user, cpu, mem_str, mem_kb, pid
self.procs_tv = Gtk.TreeView(model=self.procs_store)
cols = [
("Image Name", 0, 0, True),
("User Name", 1, 1, False),
("CPU", 2, 2, False),
("Mem Usage", 3, 4, False),
("PID", 5, 5, False),
]
for title, col_id, sort_id, expand in cols:
r = Gtk.CellRendererText()
if col_id in (2, 3, 5):
r.set_property("xalign", 1.0)
c = Gtk.TreeViewColumn(title, r, text=col_id)
c.set_sort_column_id(sort_id)
c.set_resizable(True)
c.set_expand(expand)
self.procs_tv.append_column(c)
sw.add(self.procs_tv)
box.pack_start(sw, True, True, 0)
row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
row.set_halign(Gtk.Align.END)
end_b = Gtk.Button.new_with_label("End Process")
end_b.set_size_request(96, 24)
end_b.connect("clicked", self._on_end_proc)
row.pack_start(end_b, False, False, 0)
box.pack_end(row, False, False, 0)
self.nb.append_page(box, Gtk.Label(label="Processes"))
def _build_perf_tab(self):
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
box.set_border_width(8)
# Row 1: CPU Usage meter + CPU Usage History graph
r1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
f_cm = Gtk.Frame(label=" CPU Usage ")
self.cpu_meter = XPMeter()
self.cpu_meter.set_margin_top(4); self.cpu_meter.set_margin_bottom(6)
self.cpu_meter.set_margin_start(6); self.cpu_meter.set_margin_end(6)
f_cm.add(self.cpu_meter)
r1.pack_start(f_cm, False, False, 0)
f_cg = Gtk.Frame(label=" CPU Usage History ")
self.cpu_graph = XPGraph()
self.cpu_graph.set_margin_top(4); self.cpu_graph.set_margin_bottom(6)
self.cpu_graph.set_margin_start(6); self.cpu_graph.set_margin_end(6)
f_cg.add(self.cpu_graph)
r1.pack_start(f_cg, True, True, 0)
box.pack_start(r1, False, False, 0)
# Row 2: Memory meter + Memory Usage History graph
r2 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
f_mm = Gtk.Frame(label=" Mem Usage ")
self.mem_meter = XPMeter()
self.mem_meter.set_margin_top(4); self.mem_meter.set_margin_bottom(6)
self.mem_meter.set_margin_start(6); self.mem_meter.set_margin_end(6)
f_mm.add(self.mem_meter)
r2.pack_start(f_mm, False, False, 0)
f_mg = Gtk.Frame(label=" Memory Usage History ")
self.mem_graph = XPGraph()
self.mem_graph.set_margin_top(4); self.mem_graph.set_margin_bottom(6)
self.mem_graph.set_margin_start(6); self.mem_graph.set_margin_end(6)
f_mg.add(self.mem_graph)
r2.pack_start(f_mg, True, True, 0)
box.pack_start(r2, False, False, 0)
# Row 3: Classic stats frames (Physical Memory / Commit Charge)
r3 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
f_phys = Gtk.Frame(label=" Physical Memory (K) ")
self.phys_lbl = Gtk.Label(label="", xalign=0)
self.phys_lbl.set_margin_top(6); self.phys_lbl.set_margin_bottom(6)
self.phys_lbl.set_margin_start(8); self.phys_lbl.set_margin_end(8)
f_phys.add(self.phys_lbl)
r3.pack_start(f_phys, True, True, 0)
f_sys = Gtk.Frame(label=" Totals ")
self.tot_lbl = Gtk.Label(label="", xalign=0)
self.tot_lbl.set_margin_top(6); self.tot_lbl.set_margin_bottom(6)
self.tot_lbl.set_margin_start(8); self.tot_lbl.set_margin_end(8)
f_sys.add(self.tot_lbl)
r3.pack_start(f_sys, True, True, 0)
box.pack_start(r3, True, True, 0)
self.nb.append_page(box, Gtk.Label(label="Performance"))
def _on_end_task(self, _b):
model, it = self.apps_tv.get_selection().get_selected()
if it:
addr = model[it][2]
subprocess.Popen(["hyprctl", "dispatch", "closewindow", f"address:{addr}"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def _on_switch_to(self, _b):
model, it = self.apps_tv.get_selection().get_selected()
if it:
addr = model[it][2]
subprocess.Popen(["hyprctl", "dispatch", "focuswindow", f"address:{addr}"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def _on_end_proc(self, _b):
model, it = self.procs_tv.get_selection().get_selected()
if not it:
return
name, pid = model[it][0], model[it][5]
dlg = Gtk.MessageDialog(
transient_for=self,
message_type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.YES_NO,
text=f"Do you want to end the process '{name}' (PID {pid})?",
)
dlg.set_title("Task Manager Warning")
dlg.format_secondary_text("Terminating a process can cause undesired results including loss of data.")
resp = dlg.run()
dlg.destroy()
if resp == Gtk.ResponseType.YES:
try:
os.kill(pid, signal.SIGTERM)
except OSError:
pass
self.refresh()
def refresh(self):
# 1. CPU & Memory
idle, total = read_cpu_times()
d_total = max(1, total - self.prev_total)
d_idle = max(0, idle - self.prev_idle)
cpu_pct = 100.0 * (1.0 - d_idle / float(d_total))
self.prev_idle, self.prev_total = idle, total
mi = read_meminfo()
mem_tot = mi.get("MemTotal", 1)
mem_avail = mi.get("MemAvailable", 0)
mem_used = max(0, mem_tot - mem_avail)
mem_pct = 100.0 * mem_used / float(mem_tot)
cached = mi.get("Cached", 0)
self.cpu_meter.set_value(cpu_pct)
self.cpu_graph.push(cpu_pct)
self.mem_meter.set_value(mem_pct)
self.mem_graph.push(mem_pct)
self.phys_lbl.set_text(
f"Total: {mem_tot:>10,}\n"
f"Available: {mem_avail:>10,}\n"
f"System Cache:{cached:>10,}"
)
# 2. Applications (preserve selection)
sel_addr = None
m, it = self.apps_tv.get_selection().get_selected()
if it:
sel_addr = m[it][2]
self.apps_store.clear()
try:
out = subprocess.check_output(["hyprctl", "clients", "-j"], text=True, timeout=1.0)
for c in json.loads(out):
if c.get("mapped", True) and c.get("title"):
it2 = self.apps_store.append([c["title"], "Running", c["address"]])
if c["address"] == sel_addr:
self.apps_tv.get_selection().select_iter(it2)
except Exception:
pass
# 3. Processes (preserve selected PID)
sel_pid = None
m, it = self.procs_tv.get_selection().get_selected()
if it:
sel_pid = m[it][5]
procs, self.prev_proc_ticks = read_processes(self.prev_proc_ticks, d_total, self.ncpu)
self.procs_store.clear()
for comm, user, cp, mem_kb, pid in procs[:140]:
it2 = self.procs_store.append([comm, user, cp, f"{mem_kb:,} K", mem_kb, pid])
if pid == sel_pid:
self.procs_tv.get_selection().select_iter(it2)
# 4. Totals & Statusbar
uptime_s = 0
try:
uptime_s = int(float(Path("/proc/uptime").read_text().split()[0]))
except Exception:
pass
hrs, rem = divmod(uptime_s, 3600)
mins = rem // 60
self.tot_lbl.set_text(
f"Processes: {len(procs):>8}\n"
f"CPU Cores: {self.ncpu:>8}\n"
f"Up Time: {hrs:>4}h {mins:02d}m"
)
self.sb_procs.set_text(f"Processes: {len(procs)}")
self.sb_cpu.set_text(f"CPU Usage: {int(round(cpu_pct))}%")
self.sb_mem.set_text(f"Commit Charge: {mem_used // 1024}M / {mem_tot // 1024}M")
return True
def main():
win = XPTaskManager()
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
+177
View File
@@ -0,0 +1,177 @@
#!/usr/bin/env python3
"""Classic Windows XP sndvol32 tray Volume slider popup (GTK3 + GtkLayerShell)."""
import fcntl
import os
import re
import signal
import subprocess
import sys
os.environ.setdefault("DCONF_PROFILE", "/home/carsten/.config/hypr/dconf/profile")
PID_FILE = f"/run/user/{os.getuid()}/xp-volume-popup.pid"
SOUND_SCRIPT = "/home/carsten/.config/hypr/scripts/xp-sound.sh"
# Toggle behavior: if already open, close it and exit
if os.path.exists(PID_FILE):
try:
old_pid = int(open(PID_FILE).read().strip())
if old_pid != os.getpid():
os.kill(old_pid, signal.SIGTERM)
os.unlink(PID_FILE)
sys.exit(0)
except (OSError, ValueError):
pass
open(PID_FILE, "w").write(str(os.getpid()))
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
gi.require_version("GtkLayerShell", "0.1")
from gi.repository import Gtk, Gdk, GLib, GtkLayerShell
POPUP_CSS = b"""
window#xp-vol-win {
background-color: transparent;
}
.xp-vol-outer {
background-color: #ECE9D8;
border: 1px solid #003C74;
border-radius: 2px;
box-shadow: 2px 3px 6px rgba(0, 0, 0, 0.35);
margin: 4px;
}
.xp-vol-bevel {
background-color: #ECE9D8;
border-top: 1px solid #FFFFFF;
border-left: 1px solid #FFFFFF;
border-right: 1px solid #ACA899;
border-bottom: 1px solid #ACA899;
padding: 8px 10px 8px 10px;
}
.xp-vol-title {
font-family: "Tahoma", sans-serif;
font-size: 8.5pt;
color: #000000;
}
.xp-vol-pct {
font-family: "Tahoma", sans-serif;
font-size: 8pt;
color: #444444;
}
"""
def get_volume_state():
try:
out = subprocess.check_output(["wpctl", "get-volume", "@DEFAULT_AUDIO_SINK@"], text=True, timeout=1.0)
m = re.search(r"([0-9.]+)", out)
pct = int(round(float(m.group(1)) * 100)) if m else 50
muted = "[MUTED]" in out
return max(0, min(100, pct)), muted
except Exception:
return 50, False
class XPVolumePopup(Gtk.Window):
def __init__(self):
super().__init__(type=Gtk.WindowType.TOPLEVEL)
self.set_name("xp-vol-win")
self.set_decorated(False)
self.set_resizable(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.OVERLAY)
GtkLayerShell.set_namespace(self, "xp-volume-popup")
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.BOTTOM, True)
GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.RIGHT, True)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.BOTTOM, 32)
GtkLayerShell.set_margin(self, GtkLayerShell.Edge.RIGHT, 86)
GtkLayerShell.set_keyboard_mode(self, GtkLayerShell.KeyboardMode.ON_DEMAND)
prov = Gtk.CssProvider()
prov.load_from_data(POPUP_CSS)
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), prov, Gtk.STYLE_PROVIDER_PRIORITY_USER)
outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
outer.get_style_context().add_class("xp-vol-outer")
bevel = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
bevel.get_style_context().add_class("xp-vol-bevel")
outer.pack_start(bevel, True, True, 0)
lbl = Gtk.Label(label="Volume")
lbl.get_style_context().add_class("xp-vol-title")
bevel.pack_start(lbl, False, False, 0)
pct, muted = get_volume_state()
self.syncing = True
self.scale = Gtk.Scale.new_with_range(Gtk.Orientation.VERTICAL, 0, 100, 2)
self.scale.set_inverted(True)
self.scale.set_draw_value(False)
self.scale.set_size_request(36, 118)
self.scale.set_value(pct)
self.scale.connect("value-changed", self._on_vol_changed)
self.scale.connect("button-release-event", self._on_vol_released)
bevel.pack_start(self.scale, True, True, 0)
self.pct_lbl = Gtk.Label(label=f"{pct}%")
self.pct_lbl.get_style_context().add_class("xp-vol-pct")
bevel.pack_start(self.pct_lbl, False, False, 0)
self.mute_cb = Gtk.CheckButton(label="Mute")
self.mute_cb.set_active(muted)
self.mute_cb.connect("toggled", self._on_mute_toggled)
bevel.pack_start(self.mute_cb, False, False, 0)
self.syncing = False
self.add(outer)
self.connect("key-press-event", lambda _w, ev: self.quit() if ev.keyval == Gdk.KEY_Escape else False)
self.connect("focus-out-event", lambda *_: self.quit())
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM, lambda: (self.quit(), False)[1])
def _on_vol_changed(self, scale):
if self.syncing:
return
val = int(round(scale.get_value()))
self.pct_lbl.set_text(f"{val}%")
subprocess.Popen(["wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", f"{val}%"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def _on_vol_released(self, _w, _ev):
if not self.mute_cb.get_active():
subprocess.Popen([SOUND_SCRIPT, "ding"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
return False
def _on_mute_toggled(self, cb):
if self.syncing:
return
state = "1" if cb.get_active() else "0"
subprocess.Popen(["wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", state],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
def quit(self):
try:
os.unlink(PID_FILE)
except OSError:
pass
Gtk.main_quit()
return False
def main():
win = XPVolumePopup()
win.show_all()
Gtk.main()
if __name__ == "__main__":
main()
+11 -2
View File
@@ -18,6 +18,8 @@ exec-once = waybar
exec-once = swaync
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-sound-daemon
exec-once = /home/carsten/.local/bin/xp-context-menu --desktop-daemon
exec-once = hypridle
exec-once = /usr/libexec/hyprpolkitagent
exec-once = nm-applet --indicator
@@ -69,6 +71,10 @@ windowrule = match:class ^(nwg-displays)$, float on, center on
windowrule = match:class ^(qt5ct|qt6ct)$, float on, center on
windowrule = match:class ^(engrampa)$, float on, center on
windowrule = match:class ^(hyprpolkitagent)$, float on, center on
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-control-panel)$, float on, center on, size 740 480
windowrule = match:class ^(xp-taskmgr)$, float on, center on, size 450 500
windowrule = match:title ^(Open|Save|Select|Choose|File Operation Progress)(.*)$, float on, center on
# Keybindings
@@ -87,8 +93,11 @@ bind = $mainMod, D, exec, ~/.config/hypr/scripts/show-desktop.sh
bind = $mainMod, L, exec, hyprlock
bind = $mainMod, X, exec, ~/.config/hypr/scripts/xp-power-menu.sh
bind = CTRL ALT, Delete, exec, ~/.config/hypr/scripts/xp-power-menu.sh
bind = $mainMod SHIFT, T, exec, ~/.local/bin/xp-theme-switch --menu
bind = $mainMod SHIFT, W, exec, ~/.config/hypr/scripts/xp-wallpaper-picker.sh
bind = CTRL SHIFT, Escape, exec, /home/carsten/.local/bin/xp-taskmgr
bind = $mainMod, I, exec, /home/carsten/.local/bin/xp-control-panel
bind = $mainMod SHIFT, T, exec, /home/carsten/.local/bin/xp-display-properties
bind = $mainMod SHIFT, W, exec, /home/carsten/.local/bin/xp-display-properties --desktop
bind = ALT, Space, exec, /home/carsten/.local/bin/xp-context-menu --window
bind = $mainMod, N, exec, swaync-client -t -sw
# Window Management
+1 -5
View File
@@ -1,6 +1,2 @@
#!/usr/bin/env bash
if pkill -x rofi; then
exit 0
fi
CMD=$(rofi -dmenu -p "Open:" -theme /home/carsten/.config/rofi/xp-run.rasi -mesg "Type the name of a program, folder, or command, and Windows will open it for you.") || exit 0
[ -n "$CMD" ] && hyprctl dispatch exec "$CMD"
exec /home/carsten/.local/bin/xp-run
+1 -28
View File
@@ -1,29 +1,2 @@
#!/usr/bin/env bash
set -u
WDIR="/usr/local/share/backgrounds/wintc"
if pkill -x rofi; then
exit 0
fi
SEL=$(ls -1 "$WDIR" | grep -iE '\.(jpg|jpeg|png)$' | sort | rofi -dmenu -p "Desktop Wallpaper" -theme /home/carsten/.config/rofi/xp-dialog.rasi) || exit 0
FULL="${WDIR}/${SEL}"
[ -f "$FULL" ] || exit 1
cat > /home/carsten/.config/hypr/hyprpaper.conf <<EOF
splash = false
wallpaper {
monitor =
path = ${FULL}
fit_mode = cover
}
EOF
if [ -f /home/carsten/.config/hypr/xp-theme.env ]; then
sed -i "s|^XP_WALLPAPER=.*|XP_WALLPAPER=\"${FULL}\"|" /home/carsten/.config/hypr/xp-theme.env
fi
pkill -x hyprpaper 2>/dev/null || true
sleep 0.2
hyprctl dispatch exec hyprpaper >/dev/null 2>&1 || nohup setsid hyprpaper >/dev/null 2>&1 &
notify-send -i preferences-desktop-wallpaper "Wallpaper Changed" "Applied ${SEL}"
exec /home/carsten/.local/bin/xp-display-properties --desktop
+5 -2
View File
@@ -21,7 +21,7 @@
"tooltip": true,
"tooltip-format": "Click here to begin",
"on-click": "~/.config/hypr/scripts/xp-start-menu.sh",
"on-click-right": "~/.config/hypr/scripts/xp-power-menu.sh"
"on-click-right": "/home/carsten/.local/bin/xp-context-menu --taskbar"
},
"group/quicklaunch": {
"orientation": "horizontal",
@@ -88,7 +88,8 @@
"pulseaudio": {
"format": " ",
"format-muted": " ",
"on-click": "pavucontrol",
"on-click": "/home/carsten/.local/bin/xp-volume-popup",
"on-click-middle": "pavucontrol",
"on-click-right": "~/.config/hypr/scripts/xp-osd.sh vol-mute",
"on-scroll-up": "~/.config/hypr/scripts/xp-osd.sh vol-up",
"on-scroll-down": "~/.config/hypr/scripts/xp-osd.sh vol-down",
@@ -115,6 +116,8 @@
},
"clock": {
"format": "{:%H:%M}",
"on-click": "/home/carsten/.local/bin/xp-calendar-popup",
"on-click-right": "/home/carsten/.local/bin/xp-context-menu --taskbar",
"tooltip-format": "<tt><small>{calendar}</small></tt>",
"calendar": {
"mode": "month",
+3 -1
View File
@@ -60,7 +60,9 @@ cp -a "${REPO_DIR}/config/xdg-desktop-portal/hyprland-portals.conf" "${HOME}/.co
cp -a "${REPO_DIR}/config/xfce4/xfconf/xfce-perchannel-xml/thunar.xml" "${HOME}/.config/xfce4/xfconf/xfce-perchannel-xml/"
ln -sfn "/usr/local/share/themes/Windows XP style (Blue)/gtk-4.0/gtk.css" "${HOME}/.config/ghostty/xp-tabs.css"
for f in xp-start-menu xp-alttab xp-shutdown-dialog xp-theme-switch xp-generate-logon-bg; do
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-volume-popup xp-calendar-popup xp-sound-daemon xp-context-menu; do
install -Dm755 "${REPO_DIR}/bin/${f}" "${HOME}/.local/bin/${f}"
done