vfb 0.1.0__py3-none-win_amd64.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.
- vfb/__init__.py +33 -0
- vfb/bin/vfb.exe +0 -0
- vfb-0.1.0.dist-info/LICENSE +21 -0
- vfb-0.1.0.dist-info/METADATA +89 -0
- vfb-0.1.0.dist-info/RECORD +7 -0
- vfb-0.1.0.dist-info/WHEEL +4 -0
- vfb-0.1.0.dist-info/entry_points.txt +2 -0
vfb/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""vfb: a virtual display with Xvfb's command line on Linux, macOS and Windows.
|
|
2
|
+
|
|
3
|
+
import vfb, subprocess
|
|
4
|
+
p = subprocess.Popen([vfb.path(), "-displayfd", "1", "-screen", "0", "1440x900x24",
|
|
5
|
+
"-report", "geometry", "-eofexit"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
6
|
+
n, x, y, w, h, scale = p.stdout.readline().split()
|
|
7
|
+
|
|
8
|
+
See https://github.com/JWriter20/vfb for the options. On Linux vfb runs Xvfb,
|
|
9
|
+
which must be installed; on Windows it needs the Virtual Display Driver.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import os
|
|
13
|
+
import subprocess # nosec
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
__all__ = ["path", "main"]
|
|
17
|
+
__version__ = "0.1.0" # set by scripts/package.py
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def path():
|
|
21
|
+
"""The absolute path of the vfb binary in this package."""
|
|
22
|
+
p = os.path.join(os.path.dirname(os.path.abspath(__file__)), "bin", "vfb.exe" if sys.platform == "win32" else "vfb")
|
|
23
|
+
if not os.path.isfile(p):
|
|
24
|
+
raise FileNotFoundError(f"{p}: this vfb wheel has no binary for {sys.platform}")
|
|
25
|
+
return p
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def main():
|
|
29
|
+
"""The `vfb` command: runs the binary with this process's arguments."""
|
|
30
|
+
if sys.platform == "win32":
|
|
31
|
+
# No exec on Windows; pass stdin through so -eofexit still works.
|
|
32
|
+
sys.exit(subprocess.call([path(), *sys.argv[1:]])) # nosec
|
|
33
|
+
os.execv(path(), [path(), *sys.argv[1:]])
|
vfb/bin/vfb.exe
ADDED
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JWriter20
|
|
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,89 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: vfb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A virtual display with Xvfb's command line on Linux, macOS and Windows
|
|
5
|
+
Home-page: https://github.com/JWriter20/vfb
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: xvfb,virtual-display,headless,display,monitor
|
|
8
|
+
Requires-Python: >=3.8
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: MacOS
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# vfb
|
|
16
|
+
|
|
17
|
+
One virtual display command for Linux, macOS and Windows, with Xvfb's command line. On macOS and Windows `vfb` adds a monitor that does not exist to the logged-in desktop and reports its number the way `Xvfb -displayfd` does; the system compositor draws it on the GPU like a real panel, with no screen plugged in. On Linux it runs Xvfb.
|
|
18
|
+
|
|
19
|
+
| | Linux | macOS | Windows |
|
|
20
|
+
|---|---|---|---|
|
|
21
|
+
| Display | an Xvfb server (Xvfb on PATH, or `VFB_XVFB`) | `CGVirtualDisplay` (private CoreGraphics API, macOS 12+) | a monitor of the [Virtual Display Driver](https://github.com/VirtualDrivers/Virtual-Display-Driver) (signed, MIT) |
|
|
22
|
+
| Display number | the X display number (`:N`) | the `CGDirectDisplayID` | the `\\.\DISPLAYn` number |
|
|
23
|
+
| Needs | Xvfb installed (`apt install xvfb`) | a logged-in GUI session (a plain ssh session works) | the driver installed, run inside an interactive session |
|
|
24
|
+
| Lives | as long as the process; vfb stops Xvfb when it stops, and the kernel stops Xvfb if vfb is killed | as long as the process | the monitor is attached while vfb runs and detached when it stops |
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
pip install vfb # Python: vfb.path() is the binary; `vfb` is on PATH
|
|
30
|
+
npm install @jwriter20/vfb # Node: require("@jwriter20/vfb").path(); `npx vfb`
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Each carries the binary for its platform (macOS 12+ universal, Linux x86_64, arm64 and i686, Windows x64 and x86: every platform Camoufox ships). On Linux, install Xvfb too (`apt install xvfb`). On Windows, install the [Virtual Display Driver](https://github.com/VirtualDrivers/Virtual-Display-Driver) once, as administrator; `ci/install-vdd.ps1` does it on a machine nobody configured by hand.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
vfb [:N] [-displayfd FD] [-screen 0 WxH[xD]] [-refresh HZ]
|
|
39
|
+
[-report geometry] [-eofexit] [-noparentwatch]
|
|
40
|
+
macOS only: [-scale 1|2] [-gamut p3|srgb] [-name NAME]
|
|
41
|
+
Windows only: [-match ID]
|
|
42
|
+
vfb list [-match ID] (Windows)
|
|
43
|
+
vfb detach N (Windows)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- `-displayfd FD` writes the display number and a newline to FD once the display is up at the asked-for mode. Without it the number goes to stdout. On Windows only `1` (stdout) is supported, since a child inherits no other descriptor.
|
|
47
|
+
- `-report geometry` makes the line `N X Y W H SCALE`: where the display sits on the desktop (points on macOS, pixels on Windows) and its scale: the backing scale on macOS, the system's display scaling (effective DPI / 96) on Windows. A browser window that fills the display is W x H CSS pixels on macOS and W/SCALE x H/SCALE on Windows.
|
|
48
|
+
- `-eofexit` stops vfb when its stdin closes. This is the graceful stop on Windows, where a console-less child gets no signal; it lets vfb detach the monitor it attached. A launcher that holds vfb's stdin also stops vfb if the launcher dies.
|
|
49
|
+
- vfb exits with its parent unless `-noparentwatch` is given.
|
|
50
|
+
- Common Xvfb flags (`-ac`, `-nolisten tcp`, `-nocursor`, `-br`, `-extension X`, `+extension X`, `-fp X`, `-dpi X`) are accepted and ignored.
|
|
51
|
+
|
|
52
|
+
### Linux
|
|
53
|
+
|
|
54
|
+
vfb starts Xvfb with `-displayfd` and every Xvfb flag it was given (`-nolisten tcp`, `-ac`, `+extension GLX`, ...), and handles the options Xvfb lacks: `-report`, `-eofexit`, `-noparentwatch`, and `-refresh`, `-scale`, `-gamut`, `-name`, `-match`, which are ignored. With `-report geometry` the line is `N 0 0 W H 1`. Without `-screen` the screen is 1920x1080x24, the same default as on the other systems. vfb stops Xvfb with SIGTERM, so Xvfb removes its lock file and socket, and exits with Xvfb's status if Xvfb exits on its own.
|
|
55
|
+
|
|
56
|
+
### macOS
|
|
57
|
+
|
|
58
|
+
`-screen 0 1440x900 -scale 2` is a 1440x900-point HiDPI display backed by 2880x1800 pixels. The display gets the size in millimetres of a 218 ppi panel (2x) or a 109 ppi one (1x), and P3 primaries unless `-gamut srgb` is given.
|
|
59
|
+
|
|
60
|
+
### Windows
|
|
61
|
+
|
|
62
|
+
The driver's monitors are a fixed pool, set by `count` in `C:\VirtualDisplayDriver\vdd_settings.xml`. vfb claims a free one with a session-local mutex (`Local\vfb-DISPLAYn`), attaches it to the right of the rightmost monitor, sets the mode, and detaches it on exit. A mode has to be listed in the driver's `resolutions` first; vfb names the available ones when it is not. `vfb list` shows the pool. A killed vfb cannot detach its monitor; it leaves a marker in `%LOCALAPPDATA%\vfb`, `vfb list` shows that monitor as `stale`, and the next vfb to claim it detaches it when it stops. `vfb detach N` detaches one by hand.
|
|
63
|
+
|
|
64
|
+
Run vfb inside the interactive session whose desktop it extends (for automation, a scheduled task with `LogonType Interactive`); from a service or ssh session it finds no monitors.
|
|
65
|
+
|
|
66
|
+
## Build
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
macos/build.sh # universal binary, ad-hoc signed
|
|
70
|
+
cd linux && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o vfb .
|
|
71
|
+
cd windows && GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o vfb.exe .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Release
|
|
75
|
+
|
|
76
|
+
`.github/workflows/release.yml` builds the four binaries, packages them with `scripts/package.py` (reproducible wheels and npm tarballs, standard library only), and installs the packages on each OS. A tag `vX.Y.Z` also publishes them to PyPI and npm through trusted publishing.
|
|
77
|
+
|
|
78
|
+
## Tests
|
|
79
|
+
|
|
80
|
+
`tests/smoke.py SERVER` (Python standard library only) opens displays one at a time and two at once, checks through the OS itself that each is up at the asked-for mode, closes them by every stop path, and checks nothing is left: no process, no display, no lock or marker, no leaked memory (macOS `leaks`), no growth in ColorSync's device registry. CI runs it on Linux (x86_64 and 32-bit builds), macOS arm64 and x86_64, and Windows (x64 and 32-bit builds), where `ci/install-vdd.ps1` installs the driver first.
|
|
81
|
+
|
|
82
|
+
## macOS: display changes are spaced out
|
|
83
|
+
|
|
84
|
+
Every display added or removed makes WindowServer re-lay out every window and colorsync re-read its device registry. So vfb:
|
|
85
|
+
|
|
86
|
+
- makes one display change at a time per user (a lock in the user's temporary directory) and leaves at least 2 s between one change and the next;
|
|
87
|
+
- on exit, waits until the display has left WindowServer's online list before the next vfb may change anything;
|
|
88
|
+
- gives each display a stable identity. ColorSync keeps every display it has seen as a device for good, so a new serial per run grows that registry forever and makes every later change slower. vfb's serial comes from the lowest slot no running vfb holds, so the registry holds one device per vfb that ever ran at the same time. There are 256 slots; with all of them held, vfb refuses to start (exit 1) rather than make a one-off identity that only root could remove.
|
|
89
|
+
- sets the mode it was asked for. macOS remembers the last mode used for each display identity (including 1x versus HiDPI), so a slot that last ran at another size comes up in that size. vfb switches it once and reports the display only when both the size in points and the size in pixels match.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
vfb/__init__.py,sha256=NygkpQDoGHIvuh3iKRWPdDYZghQfQb5baDTXwTzwFCs,1284
|
|
2
|
+
vfb/bin/vfb.exe,sha256=X_-p-0qyrNV2EwHSAFkIRFBhnwLFeWSTRM3AKeOUqcY,1940480
|
|
3
|
+
vfb-0.1.0.dist-info/LICENSE,sha256=7gVlcYo-PuO2_5zfPtuDyZL1fDOep7vGmJF8LLSKwXg,1066
|
|
4
|
+
vfb-0.1.0.dist-info/METADATA,sha256=f8xhbeqV8Z1Xa5EAgeOhIAp0UqEbRZ39MorpVzHNs8o,7323
|
|
5
|
+
vfb-0.1.0.dist-info/WHEEL,sha256=ocNW9v3IBQm1CepmJ1Y_7KBeO-pET60-X2ItuWhJUpU,100
|
|
6
|
+
vfb-0.1.0.dist-info/entry_points.txt,sha256=-dxe_h6U9lNZ5Pw08UgbLq-QEhfCIw01U8pvzYWJ9zk,33
|
|
7
|
+
vfb-0.1.0.dist-info/RECORD,,
|