xvfb-run on OS X
Asked Answered
K

1

39

Is it possible to have xvfb-run on OS X?

I develop a PHP application which uses xvfb-run. Before I worked on Ubuntu and it was OK. Now I've moved onto Mac and the application does not work.

Or maybe any cross-platform alternative is available to use it on both Linux/OS X?

Kimes answered 22/8, 2014 at 16:0 Comment(4)
What is your application using xvfb-run for?Gittens
i use it and whtmltoimage to render HTML code indo PNG image. xvfb-run is needed to be able to run the rendering in headless mode.Kimes
Xvfb is included with OSX 10.9.x (or XQuartz, need to check) - not sure about 10.8, because I don't have it any more. $ type Xvfb; Xvfb is /opt/X11/bin/Xvfb. You can simply run it like this: Xvfb :5 -ac -screen 0 1024x768x8 -extension GLX - and then let your X11-application connect to this screen by setting DISPLAY=:5.0. This link might be helpful: afitnerd.com/2011/09/06/headless-browser-testing-on-macHereby
@AlexanderJanssen why do you use DISPLAY=:5.0 and not DISPLAY=:5?Lactoprotein
D
17

X11 is no longer included with OS X:

https://support.apple.com/en-us/HT201341

X11 server and client libraries for OS X are available from the XQuartz project:

http://xquartz.macosforge.org/

I'm not sure if it includes all the other X goodies like Xvfb. In that case you could compile it yourself; with these options:

--disable-xquartz --enable-xvfb --enable-xnest --enable-kdrive

More info here:

https://www.xquartz.org/Developer-Info.html

IMO: It seems like you would be better of by using wkhtmltoimage straight on the mac osx, removing the need for X:

http://minimul.com/install-osx-wkhtmltoimage-binaries.html

Decrepitate answered 25/9, 2015 at 16:9 Comment(6)
This gets you the xvfb command, but it doesn't get you to xvfb-run which is what the PHP library wants.Libnah
I don't have a compiled version available: the run is just a bash script, seems that this would suffice -> gist.github.com/tyleramos/3744901Decrepitate
That does not work. It calls a lot of commands that do not exist on macOS/OS XLactoprotein
Define "that" (I outlined 2 possible solutions)Decrepitate
@Decrepitate the script you linked is just completely incompatible with mac, not because of missing commands, but also because some of them work in a different way than in Linux.Insipience
for the missing xvfb-run script: The script is indeed Linux: but it's a simple bash script so it should be possible to rewrite that for your needs; considering that you have a working xfvb binary on Mac. Anno 2021; 6 years after I think an Ubuntu docker / Vagrant will make it a lot easier.Decrepitate

© 2022 - 2024 — McMap. All rights reserved.