Compare commits
8 Commits
better-doc
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ec86044d6 | ||
|
|
561953e4af | ||
|
|
ed011c5e6c | ||
|
|
6f24eb14d5 | ||
|
|
1f4f868e03 | ||
|
|
55b2412a8a | ||
|
|
d80e68140f | ||
|
|
97d5d98247 |
5
go.mod
Normal file
5
go.mod
Normal file
@@ -0,0 +1,5 @@
|
||||
module github.com/firestuff/slidetogether
|
||||
|
||||
go 1.18
|
||||
|
||||
require github.com/google/uuid v1.3.0
|
||||
2
go.sum
Normal file
2
go.sum
Normal file
@@ -0,0 +1,2 @@
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
8
main.go
8
main.go
@@ -381,8 +381,12 @@ func present(w http.ResponseWriter, r *http.Request) {
|
||||
case <-ticker.C:
|
||||
writePresentHeartbeat(w, flusher)
|
||||
|
||||
case ctrl := <-controlChan:
|
||||
case ctrl, ok := <-controlChan:
|
||||
if ok {
|
||||
writePresentEvent(ctrl, w, flusher)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,7 +558,7 @@ func (rm *room) sendAdminEvent(ae *adminEvent) {
|
||||
}
|
||||
|
||||
func (rm *room) sendControlEvent(ce *controlEvent) {
|
||||
for present, _ := range rm.present {
|
||||
for present := range rm.present {
|
||||
present <- ce
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,27 +3,25 @@
|
||||
# To install dependencies:
|
||||
# pip3 install requests sseclient-py pyautogui
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pyautogui
|
||||
import requests
|
||||
import sseclient
|
||||
import sys
|
||||
import time
|
||||
import urllib
|
||||
|
||||
ALLOWED_CONTROLS = {'left', 'right'}
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print(f'usage: {sys.argv[0]} <url>')
|
||||
sys.exit(1)
|
||||
parser = argparse.ArgumentParser(description='slidetogether.io presenter client')
|
||||
parser.add_argument('url')
|
||||
parser.add_argument('--keynote', action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
pyautogui.FAILSAFE = False
|
||||
|
||||
url = urllib.parse.urlparse(sys.argv[1])
|
||||
url = urllib.parse.urlparse(args.url)
|
||||
qs = urllib.parse.parse_qs(url.query)
|
||||
|
||||
if 'room' not in qs or len(qs['room']) != 1:
|
||||
print(f'invalid url: {sys.argv[1]}')
|
||||
print(f'invalid url: {args.url}')
|
||||
|
||||
room = qs['room'][0]
|
||||
|
||||
@@ -36,6 +34,25 @@ presentUrl = urllib.parse.urlunparse([
|
||||
url.fragment,
|
||||
])
|
||||
|
||||
if args.keynote:
|
||||
import subprocess
|
||||
LOOKUP = {
|
||||
'left': 'show previous',
|
||||
'right': 'show next',
|
||||
}
|
||||
def send_key(key):
|
||||
subprocess.run([
|
||||
'osascript',
|
||||
'-e', 'tell application "Keynote"',
|
||||
'-e', LOOKUP[key],
|
||||
'-e', 'end tell',
|
||||
])
|
||||
else:
|
||||
import pyautogui
|
||||
pyautogui.FAILSAFE = False
|
||||
def send_key(key):
|
||||
pyautogui.press(control)
|
||||
|
||||
while True:
|
||||
try:
|
||||
response = requests.get(presentUrl, stream=True)
|
||||
@@ -49,7 +66,7 @@ while True:
|
||||
print(f'INVALID CONTROL: {control}')
|
||||
continue
|
||||
print(control)
|
||||
pyautogui.press(control)
|
||||
send_key(control)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
time.sleep(2)
|
||||
|
||||
@@ -70,8 +70,8 @@ tfoot tr {
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.control-button:active {
|
||||
background: var(--subtle-color);
|
||||
.controls.enable .control-button:active {
|
||||
background: var(--highlight-color);
|
||||
transition: none;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user