Compare commits

8 Commits

Author SHA1 Message Date
Ian Gulliver
4ec86044d6 Switch to go module 2022-10-23 05:19:01 +00:00
Ian Gulliver
561953e4af Merge branch 'master' of github.com:firestuff/slidetogether 2021-06-11 16:40:50 +00:00
Ian Gulliver
ed011c5e6c Better feedback on button clicks 2021-06-11 16:40:37 +00:00
Ian Gulliver
6f24eb14d5 Clean up imports 2021-06-03 10:02:03 -07:00
Ian Gulliver
1f4f868e03 Add --keynote which uses applescript to control keynote directly 2021-06-03 09:58:41 -07:00
Ian Gulliver
55b2412a8a Be consistent with other loop break 2021-05-21 16:22:27 +00:00
Ian Gulliver
d80e68140f Fix runaway CPU usage when present client disconnects 2021-05-21 16:21:00 +00:00
Ian Gulliver
97d5d98247 Merge pull request #1 from firestuff/better-docs
Better install/use documentation
2021-02-24 15:25:07 -08:00
5 changed files with 43 additions and 15 deletions

5
go.mod Normal file
View 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
View 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=

View File

@@ -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
}
}

View File

@@ -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)

View File

@@ -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;
}