Package: pt-web-vnc
pt-web-vncServe a display or the window of a particular application via VNC & http usingx11vnc&novnc.The script can share an existing display or create a new one, depending on the provided display id. New displays are created usingXvfband it’s dimensions and color depth can be specified via command line arguments.It’s also possible to share particular windows from a display by using the ‘window-title’ argument. This will look for a window with the provided name in a given display and will only share that particular section of the display. If this argument is not provided, the whole display is shared.A python modulept_web_vncis also included which provides synchronous and asynchronous wrappers around thept-web-vncscript.Usagept-web-vnc<COMMAND>--display-id<DISPLAY_ID>--HEIGHT<SCREEN_HEIGHT>--WIDTH<SCREEN_WIDTH>--ssl-certificate<SSL_CERTIFICATE>--window-title<WINDOW_TITLE>--run<RUN_COMMAND>--background-colour<COLOUR>--with-window-managerwhere:COMMAND:{start,stop,url,clients}start:startsharingadisplayorappbasedonthegivenarguments.stop:stopsharingthegivendisplay.url:printthenovncURLwheretheprovideddisplayisbeingserved.clients:printthenumberofclientsconnectedtoaparticulardisplay.--display-idDISPLAY_ID:integer,idforthedisplaytouse/create.IftheprovideddisplayIDdoesn\'texist,anewonewillbecreated.--heightSCREEN_HEIGHT:integer,heightinpixelsforthevirtualdisplaytocreate.Defaultsto1080.--widthSCREEN_WIDTH:integer,widthinpixelsforthevirtualdisplaytocreate.Defaultsto1920.--depthSCREEN_DEPTH:integer,pixeldepthforthevirtualdisplaytocreate.Defaultsto24.--ssl-certificateSSL_CERTIFICATE:pathtocombinedSSLcertificate&keyfile.Optional.--window-titleWINDOW_TITLE:TitleofawindowinadisplaytoshareoverVNC.Optional.--runRUN_COMMAND:CommandtorunbeforestartingVNCserver.--background-colourCOLOUR:stringwithacolournametouseasbackgroundforthevirtualdisplay.--with-window-manager:startawindowmanagerinthespecifiedDISPLAY_ID.Fornow,thewindowmanagerusedis'bspwm'.ExamplesStart a virtual display with custom dimensions and background$pt-web-vncstart--display-id100--height500--width1000--background-colourred# Get the URL to connect$pt-web-vncurl--display-id100http://pi-top.local:61100/vnc.html?autoconnect=true$pt-web-vncstop--display-id100Run an application in a virtual display and share its windowBy using the--runargument to start an application and providing its window title via--window-titleit’s possible to share a particular window.# Start chromium and look for its window title$pt-web-vncstart--display-id50--run'chromium-browser'--window-title'New Tab - Chromium'# Get the URL to connect$pt-web-vncurl--display-id50http://pi-top.local:61050/vnc.html?autoconnect=true$pt-web-vncstop--display-id50Share an existing displayIt’s possible to share your main display instead of creating a new one by providing its display id. In most cases, the id for your main display will be0.$pt-web-vncstart--display-id0# Get the URL to connect$pt-web-vncurl--display-id0http://pi-top.local:61000/vnc.html?autoconnect=true$pt-web-vncstop--display-id000Python module examplesCreate and share a display with custom dimensions and background colour>>>frompt_web_vncimportstart,connection_details,stop>>>start(display_id=50,height=500,width=1000,background_colour="blue",)>>># Get connection details>>>details=connection_details(display_id=50)>>>details.url'http://pi-top.local:61050/vnc.html?autoconnect=true&resize=scale'>>># Stop sharing>>>stop(display_id=50)Asynchronously start sharing display 0>>>importasyncio>>>frompt_web_vncimportasync_start,async_connection_details,async_stop>>># Start sharing display 0>>>asyncio.run(async_start(display_id=0)...>>># Get connection details>>>details=asyncio.run(async_connection_details(display_id=0))>>>details.url'http://pi-top.local:61000/vnc.html?autoconnect=true&resize=scale'>>># Returned object also contains parsed elements of the URL>>>details.scheme'http'>>>details.hostname'pi-top.local'>>>details.port61000>>>details.path'/vnc.html?autoconnect=true&resize=scale'>>># Stop sharing display 0>>>asyncio.run(async_stop(display_id=0)