chatgpt-float 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ """ChatGPT floating window: a Chromium app window toggled with Alt+Space."""
2
+
3
+ __version__ = "1.0.0"
@@ -0,0 +1,38 @@
1
+ import argparse
2
+ import sys
3
+
4
+ from . import core
5
+
6
+
7
+ def load_platform():
8
+ if sys.platform == "win32":
9
+ from . import windows as m
10
+ elif sys.platform == "darwin":
11
+ from . import macos as m
12
+ elif sys.platform.startswith("linux"):
13
+ from . import linux as m
14
+ else:
15
+ sys.exit(f"Unsupported platform: {sys.platform}")
16
+ return m
17
+
18
+
19
+ def main():
20
+ p = argparse.ArgumentParser(prog="chatgpt-float", description="Floating ChatGPT window (Alt+Space).")
21
+ p.add_argument("command", choices=["toggle", "daemon", "install", "uninstall"],
22
+ help="toggle: show/hide (launches if closed); daemon: resident hotkey listener "
23
+ "(Windows/macOS); install/uninstall: shortcut + autostart")
24
+ p.add_argument("--hidden", action="store_true", help="start without showing the window")
25
+ a = p.parse_args()
26
+ m = load_platform()
27
+ if a.command == "toggle":
28
+ core.toggle(m.Backend(), hidden=a.hidden)
29
+ elif a.command == "daemon":
30
+ m.daemon(a.hidden)
31
+ elif a.command == "install":
32
+ m.install()
33
+ else:
34
+ m.uninstall()
35
+
36
+
37
+ if __name__ == "__main__":
38
+ main()
@@ -0,0 +1,74 @@
1
+ import os
2
+ import shutil
3
+ import sys
4
+
5
+ URL = "https://chatgpt.com/"
6
+ W, H = 449, 590 # fixed content size of the window
7
+ APP_NAME = "chatgpt-float"
8
+
9
+
10
+ def package_root():
11
+ """Directory that contains the chatgpt_float package (made importable by the launchers)."""
12
+ return os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
13
+
14
+
15
+ def data_dir():
16
+ if sys.platform == "win32":
17
+ base = os.environ.get("APPDATA", os.path.expanduser("~"))
18
+ elif sys.platform == "darwin":
19
+ base = os.path.expanduser("~/Library/Application Support")
20
+ else:
21
+ base = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
22
+ return os.path.join(base, APP_NAME)
23
+
24
+
25
+ def profile_dir():
26
+ legacy = os.path.expanduser("~/.config/chatgpt-float-brave") # first Linux version
27
+ if sys.platform.startswith("linux") and os.path.isdir(legacy):
28
+ return legacy
29
+ return os.path.join(data_dir(), "profile")
30
+
31
+
32
+ _CANDIDATES = {
33
+ "win32": [
34
+ r"%ProgramFiles%\BraveSoftware\Brave-Browser\Application\brave.exe",
35
+ r"%ProgramFiles(x86)%\BraveSoftware\Brave-Browser\Application\brave.exe",
36
+ r"%LocalAppData%\BraveSoftware\Brave-Browser\Application\brave.exe",
37
+ r"%ProgramFiles%\Google\Chrome\Application\chrome.exe",
38
+ r"%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe",
39
+ r"%LocalAppData%\Google\Chrome\Application\chrome.exe",
40
+ r"%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe",
41
+ ],
42
+ "darwin": [
43
+ "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
44
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
45
+ "/Applications/Chromium.app/Contents/MacOS/Chromium",
46
+ "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
47
+ ],
48
+ }
49
+ _LINUX_NAMES = ["brave-browser", "brave", "google-chrome", "google-chrome-stable",
50
+ "chromium", "chromium-browser", "microsoft-edge"]
51
+
52
+
53
+ def find_browser():
54
+ """A Chromium-based browser (needed for passkeys). Override with CHATGPT_FLOAT_BROWSER."""
55
+ override = os.environ.get("CHATGPT_FLOAT_BROWSER")
56
+ if override:
57
+ return override
58
+ if sys.platform.startswith("linux"):
59
+ for n in _LINUX_NAMES:
60
+ p = shutil.which(n)
61
+ if p:
62
+ return p
63
+ else:
64
+ for c in _CANDIDATES.get(sys.platform, []):
65
+ p = os.path.expandvars(c)
66
+ if os.path.exists(p):
67
+ return p
68
+ sys.exit("No Chromium-based browser found (Brave, Chrome, Chromium, Edge). "
69
+ "Install one or set CHATGPT_FLOAT_BROWSER to its path.")
70
+
71
+
72
+ def browser_args():
73
+ return [f"--app={URL}", f"--user-data-dir={profile_dir()}", f"--window-size={W},{H}",
74
+ "--no-first-run", "--no-default-browser-check"]
chatgpt_float/core.py ADDED
@@ -0,0 +1,37 @@
1
+ import subprocess
2
+ import sys
3
+ import time
4
+
5
+ from . import config
6
+
7
+
8
+ def launch(extra_args=()):
9
+ subprocess.Popen([config.find_browser(), *config.browser_args(), *extra_args],
10
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
11
+ start_new_session=(sys.platform != "win32"))
12
+
13
+
14
+ def toggle(backend, hidden=False):
15
+ """Launch if closed; otherwise show/hide. hidden=True launches without showing."""
16
+ win = backend.find()
17
+ if win is None:
18
+ backend.launch()
19
+ for _ in range(150):
20
+ time.sleep(0.2)
21
+ win = backend.find()
22
+ if win:
23
+ break
24
+ else:
25
+ sys.exit("ChatGPT window not found after launch")
26
+ place = getattr(backend, "place", None)
27
+ if place:
28
+ place(win) # initial position: centered, flush with the bottom edge
29
+ if hidden:
30
+ time.sleep(1.5)
31
+ backend.hide(win)
32
+ else:
33
+ backend.show(win)
34
+ elif backend.is_visible(win):
35
+ backend.hide(win)
36
+ else:
37
+ backend.show(win)
chatgpt_float/icon.svg ADDED
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256">
2
+ <rect width="256" height="256" rx="56" fill="#10a37f"/>
3
+ <path d="M60 64h136a20 20 0 0 1 20 20v76a20 20 0 0 1-20 20h-70l-44 36v-36H60a20 20 0 0 1-20-20V84a20 20 0 0 1 20-20z" fill="#fff"/>
4
+ <circle cx="92" cy="122" r="12" fill="#10a37f"/>
5
+ <circle cx="128" cy="122" r="12" fill="#10a37f"/>
6
+ <circle cx="164" cy="122" r="12" fill="#10a37f"/>
7
+ </svg>
chatgpt_float/linux.py ADDED
@@ -0,0 +1,149 @@
1
+ """Linux (GNOME on X11/XWayland): window control through libX11 + xprop."""
2
+ import ctypes
3
+ import os
4
+ import shutil
5
+ import shlex
6
+ import subprocess
7
+ import sys
8
+
9
+ from . import config, core
10
+
11
+ CLASS = config.APP_NAME
12
+ W, H = config.W, config.H
13
+ KEY_PATH = "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/chatgpt-float/"
14
+ KEY_SCHEMA = "org.gnome.settings-daemon.plugins.media-keys.custom-keybinding"
15
+ MEDIA = "org.gnome.settings-daemon.plugins.media-keys"
16
+ AUTOSTART = os.path.expanduser("~/.config/autostart/chatgpt-float.desktop")
17
+ LAUNCHER = os.path.expanduser("~/.local/share/applications/chatgpt-float.desktop")
18
+ ICON_DIR = os.path.expanduser("~/.local/share/icons/hicolor/scalable/apps")
19
+ ICON = os.path.join(ICON_DIR, "chatgpt-float.svg")
20
+
21
+
22
+ class _Msg(ctypes.Structure):
23
+ _fields_ = [("type", ctypes.c_int), ("serial", ctypes.c_ulong), ("send_event", ctypes.c_int),
24
+ ("display", ctypes.c_void_p), ("window", ctypes.c_ulong), ("message_type", ctypes.c_ulong),
25
+ ("format", ctypes.c_int), ("data", ctypes.c_long * 5), ("pad", ctypes.c_long * 5)]
26
+
27
+
28
+ class _Hints(ctypes.Structure):
29
+ _fields_ = [("flags", ctypes.c_long)] + [(n, ctypes.c_int) for n in (
30
+ "x", "y", "width", "height", "min_width", "min_height", "max_width", "max_height",
31
+ "width_inc", "height_inc", "min_ax", "min_ay", "max_ax", "max_ay", "base_width", "base_height")] + [
32
+ ("win_gravity", ctypes.c_int)]
33
+
34
+
35
+ def _sh(*a):
36
+ return subprocess.run(a, capture_output=True, text=True).stdout
37
+
38
+
39
+ class Backend:
40
+ def __init__(self):
41
+ x = self.x = ctypes.CDLL("libX11.so.6")
42
+ x.XOpenDisplay.restype = ctypes.c_void_p
43
+ x.XOpenDisplay.argtypes = [ctypes.c_char_p]
44
+ x.XInternAtom.restype = ctypes.c_ulong
45
+ x.XInternAtom.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_int]
46
+ x.XDefaultRootWindow.restype = ctypes.c_ulong
47
+ x.XDefaultRootWindow.argtypes = [ctypes.c_void_p]
48
+ x.XSendEvent.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_int, ctypes.c_long, ctypes.c_void_p]
49
+ x.XIconifyWindow.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_int]
50
+ x.XFlush.argtypes = [ctypes.c_void_p]
51
+ x.XMoveWindow.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_int, ctypes.c_int]
52
+ x.XResizeWindow.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_uint, ctypes.c_uint]
53
+ x.XSetWMNormalHints.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_void_p]
54
+ self.d = x.XOpenDisplay(None)
55
+ if not self.d:
56
+ sys.exit("No X11/XWayland display available")
57
+ self.root = x.XDefaultRootWindow(self.d)
58
+
59
+ def _atom(self, n):
60
+ return self.x.XInternAtom(self.d, n.encode(), 0)
61
+
62
+ def _msg(self, win, mtype, data):
63
+ m = _Msg(type=33, send_event=1, display=self.d, window=win, message_type=self._atom(mtype), format=32)
64
+ for i, v in enumerate(data):
65
+ m.data[i] = v
66
+ self.x.XSendEvent(self.d, self.root, 0, (1 << 20) | (1 << 19), ctypes.byref(m))
67
+ self.x.XFlush(self.d)
68
+
69
+ def launch(self):
70
+ core.launch([f"--class={CLASS}", "--ozone-platform=x11"])
71
+
72
+ def find(self):
73
+ ids = _sh("xprop", "-root", "_NET_CLIENT_LIST").split("#")[-1].replace(",", " ").split()
74
+ for i in ids:
75
+ if f'"{CLASS}"' in _sh("xprop", "-id", i, "WM_CLASS"):
76
+ return int(i, 16)
77
+
78
+ def is_visible(self, win):
79
+ return "_NET_WM_STATE_HIDDEN" not in _sh("xprop", "-id", hex(win), "_NET_WM_STATE")
80
+
81
+ def lock_size(self, win):
82
+ h = _Hints(flags=16 | 32, min_width=W, min_height=H, max_width=W, max_height=H)
83
+ self.x.XSetWMNormalHints(self.d, win, ctypes.byref(h))
84
+ self.x.XResizeWindow(self.d, win, W, H)
85
+ self.x.XFlush(self.d)
86
+
87
+ def place(self, win):
88
+ """Center horizontally, bottom edge on the bottom of the work area."""
89
+ self.lock_size(win)
90
+ wa = _sh("xprop", "-root", "_NET_WORKAREA").split("=")[-1].replace(",", " ").split()
91
+ fe = _sh("xprop", "-id", hex(win), "_NET_FRAME_EXTENTS").split("=")[-1].replace(",", " ").split()
92
+ if len(wa) < 4:
93
+ return
94
+ ax, ay, aw, ah = (int(v) for v in wa[:4])
95
+ left, right, top, bottom = (int(v) for v in fe[:4]) if len(fe) >= 4 else (0, 0, 0, 0)
96
+ x = ax + (aw - (W + left + right)) // 2 + left
97
+ y = ay + ah - H - bottom
98
+ self.x.XMoveWindow(self.d, win, x, y)
99
+ self.x.XFlush(self.d)
100
+
101
+ def show(self, win):
102
+ self.lock_size(win)
103
+ self._msg(win, "_NET_ACTIVE_WINDOW", [2, 0, 0])
104
+ self._msg(win, "_NET_WM_STATE", [1, self._atom("_NET_WM_STATE_ABOVE"), 0, 1, 0])
105
+
106
+ def hide(self, win):
107
+ self.x.XIconifyWindow(self.d, win, 0)
108
+ self.x.XFlush(self.d)
109
+
110
+
111
+ def install():
112
+ cmd = f"env PYTHONPATH={shlex.quote(config.package_root())} {shlex.quote(sys.executable)} -m chatgpt_float toggle"
113
+ subprocess.run(["gsettings", "set", "org.gnome.desktop.wm.keybindings", "activate-window-menu", "[]"], check=True)
114
+ cur = subprocess.run(["gsettings", "get", MEDIA, "custom-keybindings"], capture_output=True, text=True,
115
+ check=True).stdout.strip()
116
+ if "chatgpt-float" not in cur:
117
+ new = f"['{KEY_PATH}']" if cur in ("@as []", "[]") else cur[:-1] + f", '{KEY_PATH}']"
118
+ subprocess.run(["gsettings", "set", MEDIA, "custom-keybindings", new], check=True)
119
+ for k, v in (("name", "ChatGPT flotante"), ("command", cmd), ("binding", "<Alt>space")):
120
+ subprocess.run(["gsettings", "set", f"{KEY_SCHEMA}:{KEY_PATH}", k, v], check=True)
121
+ os.makedirs(os.path.dirname(AUTOSTART), exist_ok=True)
122
+ with open(AUTOSTART, "w") as f:
123
+ f.write("[Desktop Entry]\nType=Application\nName=ChatGPT flotante\n"
124
+ f"Exec={cmd} --hidden\nX-GNOME-Autostart-Delay=5\n")
125
+ # App-menu entry + icon. To use your own icon, put icon.svg in ~/.config/chatgpt-float/ first.
126
+ custom = os.path.join(config.data_dir(), "icon.svg")
127
+ os.makedirs(ICON_DIR, exist_ok=True)
128
+ shutil.copyfile(custom if os.path.exists(custom) else os.path.join(os.path.dirname(__file__), "icon.svg"), ICON)
129
+ os.makedirs(os.path.dirname(LAUNCHER), exist_ok=True)
130
+ with open(LAUNCHER, "w") as f:
131
+ f.write("[Desktop Entry]\nType=Application\nName=ChatGPT flotante\nIcon=chatgpt-float\n"
132
+ f"Exec={cmd}\nStartupWMClass={CLASS}\nCategories=Utility;\n")
133
+ print("Installed: Alt+Space toggles the window; it also starts (hidden) at login.")
134
+
135
+
136
+ def uninstall():
137
+ cur = subprocess.run(["gsettings", "get", MEDIA, "custom-keybindings"], capture_output=True, text=True).stdout.strip()
138
+ if KEY_PATH in cur:
139
+ items = [i.strip() for i in cur.strip("[]").split(",") if KEY_PATH not in i and i.strip()]
140
+ subprocess.run(["gsettings", "set", MEDIA, "custom-keybindings", "[" + ", ".join(items) + "]" if items else "@as []"])
141
+ subprocess.run(["gsettings", "reset", "org.gnome.desktop.wm.keybindings", "activate-window-menu"])
142
+ for f in (AUTOSTART, LAUNCHER, ICON):
143
+ if os.path.exists(f):
144
+ os.remove(f)
145
+ print("Uninstalled.")
146
+
147
+
148
+ def daemon(_hidden):
149
+ sys.exit("Linux uses the GNOME shortcut; run `install` instead of `daemon`.")
chatgpt_float/macos.py ADDED
@@ -0,0 +1,97 @@
1
+ """macOS: window control through System Events (AppleScript); hotkey through pynput.
2
+
3
+ Limits: macOS cannot pin another app's window on top, and the window size is set at
4
+ launch only (it is not locked against resizing).
5
+ """
6
+ import os
7
+ import subprocess
8
+ import sys
9
+
10
+ from . import config, core
11
+
12
+ LABEL = "com.chatgptfloat.agent"
13
+ PLIST = os.path.expanduser(f"~/Library/LaunchAgents/{LABEL}.plist")
14
+
15
+
16
+ def _osa(script):
17
+ return subprocess.run(["osascript", "-e", script], capture_output=True, text=True).stdout.strip()
18
+
19
+
20
+ def _proc(pid):
21
+ return f'(first process whose unix id is {pid})'
22
+
23
+
24
+ class Backend:
25
+ def launch(self):
26
+ core.launch()
27
+
28
+ def find(self):
29
+ out = subprocess.run(["ps", "-axo", "pid=,ppid=,command="], capture_output=True, text=True).stdout
30
+ rows = []
31
+ for line in out.splitlines():
32
+ parts = line.split(None, 2)
33
+ if len(parts) == 3 and f"--user-data-dir={config.profile_dir()}" in parts[2] and "--type=" not in parts[2]:
34
+ rows.append(int(parts[0]))
35
+ for pid in rows: # main process of our instance, once it has a window
36
+ n = _osa(f'tell application "System Events" to count windows of {_proc(pid)}')
37
+ if n.isdigit() and int(n) > 0:
38
+ return pid
39
+ return None
40
+
41
+ def is_visible(self, pid):
42
+ return _osa(f'tell application "System Events" to get visible of {_proc(pid)}') == "true"
43
+
44
+ def place(self, pid):
45
+ """Center horizontally, flush with the bottom of the screen (best effort)."""
46
+ out = _osa('tell application "Finder" to get bounds of window of desktop')
47
+ try:
48
+ _, _, sw, sh = (int(v) for v in out.replace(" ", "").split(","))
49
+ except ValueError:
50
+ return
51
+ _osa(f'tell application "System Events"\nset w to window 1 of {_proc(pid)}\n'
52
+ f'set {{ww, wh}} to size of w\nset position of w to {{({sw} - ww) div 2, {sh} - wh}}\nend tell')
53
+
54
+ def show(self, pid):
55
+ _osa(f'tell application "System Events"\nset p to {_proc(pid)}\nset visible of p to true\n'
56
+ 'set frontmost of p to true\nend tell')
57
+
58
+ def hide(self, pid):
59
+ _osa(f'tell application "System Events" to set visible of {_proc(pid)} to false')
60
+
61
+
62
+ def daemon(hidden):
63
+ try:
64
+ from pynput import keyboard
65
+ except ImportError:
66
+ sys.exit("Install the hotkey dependency: pip3 install pynput "
67
+ "(and allow Accessibility for your terminal/Python in System Settings > Privacy)")
68
+ b = Backend()
69
+ if hidden and b.find() is None:
70
+ core.toggle(b, hidden=True)
71
+ with keyboard.GlobalHotKeys({"<alt>+<space>": lambda: core.toggle(b)}) as h:
72
+ h.join()
73
+
74
+
75
+ def install():
76
+ os.makedirs(os.path.dirname(PLIST), exist_ok=True)
77
+ with open(PLIST, "w") as f:
78
+ f.write(f"""<?xml version="1.0" encoding="UTF-8"?>
79
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
80
+ <plist version="1.0"><dict>
81
+ <key>Label</key><string>{LABEL}</string>
82
+ <key>ProgramArguments</key><array><string>{sys.executable}</string><string>-m</string><string>chatgpt_float</string><string>daemon</string><string>--hidden</string></array>
83
+ <key>EnvironmentVariables</key><dict><key>PYTHONPATH</key><string>{config.package_root()}</string></dict>
84
+ <key>RunAtLoad</key><true/><key>KeepAlive</key><true/>
85
+ </dict></plist>
86
+ """)
87
+ subprocess.run(["launchctl", "unload", PLIST], capture_output=True)
88
+ subprocess.run(["launchctl", "load", PLIST])
89
+ print("Installed: Alt+Space toggles the window; it starts at login. "
90
+ "Grant Accessibility permission to Python when macOS asks.")
91
+
92
+
93
+ def uninstall():
94
+ subprocess.run(["launchctl", "unload", PLIST], capture_output=True)
95
+ if os.path.exists(PLIST):
96
+ os.remove(PLIST)
97
+ print("Uninstalled.")
@@ -0,0 +1,118 @@
1
+ """Windows: window control through user32, global hotkey through RegisterHotKey."""
2
+ import ctypes
3
+ import os
4
+ import subprocess
5
+ import sys
6
+ from ctypes import wintypes
7
+
8
+ from . import config, core
9
+
10
+ user32 = ctypes.windll.user32
11
+ user32.GetWindowLongPtrW.restype = ctypes.c_ssize_t
12
+ user32.GetWindowLongPtrW.argtypes = [wintypes.HWND, ctypes.c_int]
13
+ user32.SetWindowLongPtrW.restype = ctypes.c_ssize_t
14
+ user32.SetWindowLongPtrW.argtypes = [wintypes.HWND, ctypes.c_int, ctypes.c_ssize_t]
15
+ user32.SetWindowPos.argtypes = [wintypes.HWND, wintypes.HWND, ctypes.c_int, ctypes.c_int,
16
+ ctypes.c_int, ctypes.c_int, wintypes.UINT]
17
+
18
+ RUN_KEY = r"Software\Microsoft\Windows\CurrentVersion\Run"
19
+ RUN_NAME = "ChatGPTFloat"
20
+ NO_WINDOW = 0x08000000
21
+
22
+
23
+ def _our_pids():
24
+ ps = ("(Get-CimInstance Win32_Process | Where-Object "
25
+ "{ $_.CommandLine -like '*chatgpt-float*profile*' }).ProcessId")
26
+ out = subprocess.run(["powershell", "-NoProfile", "-Command", ps], capture_output=True, text=True,
27
+ creationflags=NO_WINDOW).stdout
28
+ return {int(x) for x in out.split() if x.isdigit()}
29
+
30
+
31
+ class Backend:
32
+ def launch(self):
33
+ core.launch()
34
+
35
+ def find(self):
36
+ pids = _our_pids()
37
+ if not pids:
38
+ return None
39
+ found = []
40
+
41
+ @ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
42
+ def cb(hwnd, _):
43
+ pid = wintypes.DWORD()
44
+ user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
45
+ if pid.value in pids:
46
+ cls = ctypes.create_unicode_buffer(64)
47
+ user32.GetClassNameW(hwnd, cls, 64)
48
+ if cls.value == "Chrome_WidgetWin_1" and user32.GetWindowTextLengthW(hwnd) > 0:
49
+ found.append(hwnd)
50
+ return True
51
+
52
+ user32.EnumWindows(cb, 0)
53
+ return found[0] if found else None
54
+
55
+ def is_visible(self, hwnd):
56
+ return bool(user32.IsWindowVisible(hwnd)) and not user32.IsIconic(hwnd)
57
+
58
+ def lock_size(self, hwnd):
59
+ style = user32.GetWindowLongPtrW(hwnd, -16)
60
+ style &= ~(0x00040000 | 0x00010000) # no resize border, no maximize button
61
+ user32.SetWindowLongPtrW(hwnd, -16, style)
62
+ user32.SetWindowPos(hwnd, None, 0, 0, 0, 0, 0x0001 | 0x0002 | 0x0004 | 0x0020)
63
+
64
+ def place(self, hwnd):
65
+ """Center horizontally, bottom edge on the bottom of the work area."""
66
+ wa = wintypes.RECT()
67
+ user32.SystemParametersInfoW(0x0030, 0, ctypes.byref(wa), 0) # SPI_GETWORKAREA
68
+ r = wintypes.RECT()
69
+ user32.GetWindowRect(hwnd, ctypes.byref(r))
70
+ w, h = r.right - r.left, r.bottom - r.top
71
+ x = wa.left + (wa.right - wa.left - w) // 2
72
+ y = wa.bottom - h
73
+ user32.SetWindowPos(hwnd, None, x, y, 0, 0, 0x0001 | 0x0004) # NOSIZE | NOZORDER
74
+
75
+ def show(self, hwnd):
76
+ self.lock_size(hwnd)
77
+ user32.ShowWindow(hwnd, 9) # SW_RESTORE
78
+ user32.SetWindowPos(hwnd, ctypes.c_void_p(-1), 0, 0, 0, 0, 0x0001 | 0x0002) # TOPMOST
79
+ user32.SetForegroundWindow(hwnd)
80
+
81
+ def hide(self, hwnd):
82
+ user32.ShowWindow(hwnd, 0) # SW_HIDE
83
+
84
+
85
+ def daemon(hidden):
86
+ """Resident process: registers Alt+Space and toggles on each press."""
87
+ b = Backend()
88
+ if not user32.RegisterHotKey(None, 1, 0x0001 | 0x4000, 0x20): # MOD_ALT | MOD_NOREPEAT, VK_SPACE
89
+ sys.exit("Could not register Alt+Space (already used by another program)")
90
+ if hidden and b.find() is None:
91
+ core.toggle(b, hidden=True)
92
+ msg = wintypes.MSG()
93
+ while user32.GetMessageW(ctypes.byref(msg), None, 0, 0) != 0:
94
+ if msg.message == 0x0312: # WM_HOTKEY
95
+ core.toggle(b)
96
+
97
+
98
+ def install():
99
+ import winreg
100
+ exe = sys.executable
101
+ if exe.lower().endswith("python.exe"):
102
+ exe = exe[:-10] + "pythonw.exe" # no console window
103
+ code = (f"import sys,runpy;sys.path.insert(0,r'{config.package_root()}');"
104
+ "sys.argv=['chatgpt-float','daemon','--hidden'];runpy.run_module('chatgpt_float',run_name='__main__')")
105
+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_KEY, 0, winreg.KEY_SET_VALUE) as k:
106
+ winreg.SetValueEx(k, RUN_NAME, 0, winreg.REG_SZ, f'"{exe}" -c "{code}"')
107
+ subprocess.Popen([exe, "-c", code], creationflags=NO_WINDOW | 0x00000008)
108
+ print("Installed: Alt+Space toggles the window; it starts at login.")
109
+
110
+
111
+ def uninstall():
112
+ import winreg
113
+ try:
114
+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_KEY, 0, winreg.KEY_SET_VALUE) as k:
115
+ winreg.DeleteValue(k, RUN_NAME)
116
+ except FileNotFoundError:
117
+ pass
118
+ print("Uninstalled (stop the running pythonw.exe from Task Manager if needed).")
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: chatgpt-float
3
+ Version: 1.0.0
4
+ Summary: Floating, always-on-top ChatGPT window toggled with Alt+Space (Linux, Windows, macOS)
5
+ License: MIT
6
+ Keywords: chatgpt,openai,floating,hotkey,desktop
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Operating System :: Microsoft :: Windows
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Environment :: X11 Applications
12
+ Classifier: Topic :: Desktop Environment
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pynput; sys_platform == "darwin"
17
+ Dynamic: license-file
18
+
19
+ # ChatGPT floating window
20
+
21
+ A small always-on-top ChatGPT window you show or hide with **Alt+Space**.
22
+ It runs a real Chromium-based browser in app mode (Brave, Chrome, Chromium or Edge) with its
23
+ own profile, so sign-in works, including passkeys. You sign in once; the session is kept.
24
+
25
+ ## Install
26
+
27
+ pipx install chatgpt-float # or: pip install --user chatgpt-float
28
+ chatgpt-float install # shortcut + start at login
29
+ chatgpt-float uninstall
30
+
31
+ From a checkout, use `python3 -m chatgpt_float install`. Re-run `install` if you move or
32
+ upgrade the Python environment, because the shortcut stores its path.
33
+
34
+ Commands: `toggle` (show/hide, launches if closed; `--hidden` launches without showing),
35
+ `daemon` (Windows/macOS hotkey listener), `install`, `uninstall`.
36
+ Set `CHATGPT_FLOAT_BROWSER` to a browser path to override auto-detection.
37
+ Window size is `W, H` in `chatgpt_float/config.py`.
38
+
39
+ ## Platforms
40
+
41
+ | | Linux | Windows | macOS |
42
+ |---|---|---|---|
43
+ | Requirements | GNOME, `xprop` (`x11-utils`), XWayland | Python 3 | Python 3, `pip3 install pynput` |
44
+ | Hotkey | GNOME custom shortcut | `RegisterHotKey` (resident `daemon`) | `pynput` (needs Accessibility permission) |
45
+ | Always on top | yes | yes | **no** (macOS limitation) |
46
+ | Fixed size (no resize/maximize) | yes | yes | **no** (size set at launch only) |
47
+ | Tested | **yes** | **no** | **no** |
48
+
49
+ Only the Linux (GNOME/X11) backend has been run. Windows and macOS are implemented but untested.
@@ -0,0 +1,14 @@
1
+ chatgpt_float/__init__.py,sha256=GWf1ICXdcaXKhiWZMX0nX5YHRxdL-5O0TLcTrmY-OGY,100
2
+ chatgpt_float/__main__.py,sha256=-kgaOTgDfsELXDhYrMH-dsPl5bNtu3E-hiE-zcVSjBk,1154
3
+ chatgpt_float/config.py,sha256=yjWYas8-W5br3xOHt3DVkQMeXyogo106vOOYx_Vw7tc,2767
4
+ chatgpt_float/core.py,sha256=5sj7d0r4ZjMpAmK1TuzY7NB0yqylFnxY4OvhS1fvpYo,1082
5
+ chatgpt_float/icon.svg,sha256=_Lynyq4T05HBpe3NTzK2XZ20c3XT49n_BqSb93oaQHA,442
6
+ chatgpt_float/linux.py,sha256=zIhAdlrW-mdXDGFNEm9K7_dVpcoLuvORWzomakZx35s,7204
7
+ chatgpt_float/macos.py,sha256=wsmRLEYokAOY0dTpOfCKwLdWsao4zJ45kigO_snxaKE,3824
8
+ chatgpt_float/windows.py,sha256=nHW2lE9shj3vEV_94LKKRpddTDfe0kv0y5p0qDiazns,4663
9
+ chatgpt_float-1.0.0.dist-info/licenses/LICENSE,sha256=7lSjKi7VuM0Pu94JShCzYV9Pv0qgkoW7dzhnmz1qWBc,1083
10
+ chatgpt_float-1.0.0.dist-info/METADATA,sha256=0YfhvQ4uLMgktn8Fz-62p5q-TKeCLVUdLnRA8vbiWts,2107
11
+ chatgpt_float-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
12
+ chatgpt_float-1.0.0.dist-info/entry_points.txt,sha256=eaUSEDMcSZNAx5rHX9gqlcIiCzHgCpgPxwWLJ_8p5P0,62
13
+ chatgpt_float-1.0.0.dist-info/top_level.txt,sha256=pvLJOGuBu6UNfdzkcOmi9u_ftnCMgLlwiRCEF0-Fzto,14
14
+ chatgpt_float-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ chatgpt-float = chatgpt_float.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 chatgpt-float contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ chatgpt_float