added laplace headless in the README
This commit is contained in:
@@ -7,3 +7,9 @@ a plugin which complements the project [P2PRC](https://p2prc.akilan.io)
|
||||
## Laplace Binary
|
||||
The laplace binary is generated from the fork:
|
||||
https://github.com/Akilan1999/laplace/tree/keyboard_mouse
|
||||
|
||||
## Running laplace
|
||||
```
|
||||
chromium --auto-select-desktop-capture-source=Entire screen --url https://0.0.0.0:8888/?mode=headless
|
||||
|
||||
```
|
||||
|
||||
BIN
end-to-end-demo-playwriter
Executable file
BIN
end-to-end-demo-playwriter
Executable file
Binary file not shown.
85
end-to-end-demo-playwriter.go
Normal file
85
end-to-end-demo-playwriter.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"github.com/mxschmitt/playwright-go"
|
||||
)
|
||||
|
||||
func assertErrorToNilf(message string, err error) {
|
||||
if err != nil {
|
||||
log.Fatalf(message, err)
|
||||
}
|
||||
}
|
||||
|
||||
func assertEqual(expected, actual interface{}) {
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
panic(fmt.Sprintf("%v does not equal %v", actual, expected))
|
||||
}
|
||||
}
|
||||
|
||||
const todoName = "Bake a cake"
|
||||
|
||||
func main() {
|
||||
pw, err := playwright.Run()
|
||||
assertErrorToNilf("could not launch playwright: %w", err)
|
||||
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
||||
Headless: playwright.Bool(false),
|
||||
})
|
||||
assertErrorToNilf("could not launch Chromium: %w", err)
|
||||
context, err := browser.NewContext()
|
||||
assertErrorToNilf("could not create context: %w", err)
|
||||
page, err := context.NewPage()
|
||||
assertErrorToNilf("could not create page: %w", err)
|
||||
_, err = page.Goto("https://0.0.0.0:")
|
||||
assertErrorToNilf("could not goto: %w", err)
|
||||
|
||||
// Helper function to get the amount of todos on the page
|
||||
assertCountOfTodos := func(shouldBeCount int) {
|
||||
count, err := page.EvalOnSelectorAll("ul.todo-list > li", "el => el.length")
|
||||
assertErrorToNilf("could not determine todo list count: %w", err)
|
||||
assertEqual(shouldBeCount, count)
|
||||
}
|
||||
|
||||
// Initially there should be 0 entries
|
||||
assertCountOfTodos(0)
|
||||
|
||||
// Adding a todo entry (click in the input, enter the todo title and press the Enter key)
|
||||
assertErrorToNilf("could not click: %v", page.Click("input.new-todo"))
|
||||
assertErrorToNilf("could not type: %v", page.Type("input.new-todo", todoName))
|
||||
assertErrorToNilf("could not press: %v", page.Press("input.new-todo", "Enter"))
|
||||
|
||||
// After adding 1 there should be 1 entry in the list
|
||||
assertCountOfTodos(1)
|
||||
|
||||
// Here we get the text in the first todo item to see if it"s the same which the user has entered
|
||||
textContentOfFirstTodoEntry, err := page.EvalOnSelector("ul.todo-list > li:nth-child(1) label", "el => el.textContent")
|
||||
assertErrorToNilf("could not get first todo entry: %w", err)
|
||||
assertEqual(todoName, textContentOfFirstTodoEntry)
|
||||
|
||||
// The todo list should be persistent. Here we reload the page and see if the entry is still there
|
||||
_, err = page.Reload()
|
||||
assertErrorToNilf("could not reload: %w", err)
|
||||
assertCountOfTodos(1)
|
||||
|
||||
// Set the entry to completed
|
||||
assertErrorToNilf("could not click: %v", page.Click("input.toggle"))
|
||||
|
||||
// Filter for active entries. There should be 0, because we have completed the entry already
|
||||
assertErrorToNilf("could not click: %v", page.Click("text=Active"))
|
||||
assertCountOfTodos(0)
|
||||
|
||||
// If we filter now for completed entries, there should be 1
|
||||
assertErrorToNilf("could not click: %v", page.Click("text=Completed"))
|
||||
assertCountOfTodos(1)
|
||||
|
||||
// Clear the list of completed entries, then it should be again 0
|
||||
assertErrorToNilf("could not click: %v", page.Click("text=Clear completed"))
|
||||
assertCountOfTodos(0)
|
||||
|
||||
assertErrorToNilf("could not close browser: %w", browser.Close())
|
||||
assertErrorToNilf("could not stop Playwright: %w", pw.Stop())
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,3 +1,5 @@
|
||||
module github.com/Akilan1999/remotegameplay
|
||||
|
||||
go 1.16
|
||||
|
||||
require github.com/mxschmitt/playwright-go v0.1100.0
|
||||
|
||||
19
go.sum
Normal file
19
go.sum
Normal file
@@ -0,0 +1,19 @@
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/h2non/filetype v1.1.0/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
|
||||
github.com/mxschmitt/playwright-go v0.1100.0 h1:GkI1TuXU50GlA988VqqdoTObLzi2bbeT8RmLtcxKQrc=
|
||||
github.com/mxschmitt/playwright-go v0.1100.0/go.mod h1:a3SD3v+56XMA0sDDxXJXy+QGnCfXrNZ/+4gwR5ioSgU=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w=
|
||||
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
5
playwriter.go
Normal file
5
playwriter.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
81
site.yml
81
site.yml
@@ -3,9 +3,82 @@
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
- name: set config for laplace
|
||||
ansible.builtin.script: ./laplace -setconfig
|
||||
- name: Install VNC-required system packages
|
||||
apt: pkg={{ item }} state=latest
|
||||
with_items:
|
||||
- firefox
|
||||
- lubuntu-desktop
|
||||
- vnc4server
|
||||
- xinetd
|
||||
|
||||
- name: run laplace
|
||||
ansible.builtin.script: ./laplace -tls -addr 0.0.0.0:8888
|
||||
- name: Create novnc install dir
|
||||
file: path={{ novnc_install_dir }} state=directory
|
||||
|
||||
- name: Clone novnc
|
||||
git: repo=https://github.com/novnc/noVNC.git dest="{{ novnc_install_dir }}" version="stable/v0.6"
|
||||
|
||||
- name: Clone websockify
|
||||
git: repo=https://github.com/novnc/websockify dest="{{ novnc_install_dir }}/utils/websockify"
|
||||
|
||||
- name: Create ~/.vnc dir
|
||||
file: path=~/.vnc state=directory
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Remove old vncpasswd dir
|
||||
file: path=~/vncpasswd state=absent
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Clone vncpasswd
|
||||
git: repo=https://github.com/trinitronx/vncpasswd.py dest=~/vncpasswd
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Create vnc password bridge
|
||||
command: python ~/vncpasswd/vncpasswd.py {{ vnc_password }} -f ~/.vnc/passwd
|
||||
become_user: "{{ default_user }}"
|
||||
when: vnc_password is defined
|
||||
|
||||
- name: Chmod on vnc password file
|
||||
file: path=~/.vnc/passwd mode=0600
|
||||
become_user: "{{ default_user }}"
|
||||
when: vnc_password is defined
|
||||
|
||||
# Move vnc_lite.html which takes vnc_password as query argument
|
||||
# to index.html and rewrite it so that password is autoset, no
|
||||
# need to specify via query parameter.
|
||||
- name: Autoset novnc passwd to match the vnc one
|
||||
shell: sed 's/password\ =/password\ = "{{ vnc_password }}";\/\//' {{ novnc_install_dir }}/vnc_auto.html > {{ novnc_install_dir }}/index.html #"
|
||||
|
||||
- name: Remove temp vncpasswd dir
|
||||
file: path=~/vncpasswd state=absent
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Copy script for starting X
|
||||
copy: src=xstartup dest=~/.vnc/xstartup mode=0755
|
||||
become_user: "{{ default_user }}"
|
||||
|
||||
- name: Make sure /etc/X11/xinit/xinitrc has execute permissions set
|
||||
file: path=/etc/X11/xinit/xinitrc mode=0755
|
||||
|
||||
- name: Copy novnc init file
|
||||
copy: src=novnc_init dest=/etc/init.d/novnc mode=0755
|
||||
|
||||
- name: Copy novnc default file
|
||||
template: src=novnc_default.j2 dest=/etc/default/novnc
|
||||
|
||||
- name: Copy vncserver default file
|
||||
template: src=vncserver_default.j2 dest=/etc/default/vncserver
|
||||
|
||||
- name: Copy lightdm config file
|
||||
copy: src=lightdm.conf dest=/etc/lightdm/lightdm.conf
|
||||
|
||||
- name: "Make sure lightdm respawns - fix for race condition: https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/969489"
|
||||
lineinfile: dest=/etc/init/lightdm.conf line="respawn" insertafter="stop on runlevel [016]"
|
||||
|
||||
- name: "Remove a11y indicator to fix: https://bugs.launchpad.net/lightdm/+bug/1322275"
|
||||
replace: dest=/etc/lightdm/lightdm-gtk-greeter.conf.d/30_lubuntu.conf regexp="show-indicators=~host;~spacer;~clock;~spacer;~session;~language;~a11y;~power" replace="show-indicators=~host;~spacer;~clock;~spacer;~session;~language;~power"
|
||||
|
||||
- name: Copy vnc config file for xinetd
|
||||
template: src=xinetd_vnc.j2 dest=/etc/xinetd.d/vnc
|
||||
|
||||
- include: create_simple_service.yml src_file='novnc'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user