aboutsummaryrefslogtreecommitdiffstats
path: root/meet.lua
diff options
context:
space:
mode:
authorTeddy Wing2021-11-29 22:28:12 +0100
committerTeddy Wing2021-11-29 22:28:12 +0100
commitc50888fd0ea6f0802b834dbf4c2a799bdb37d3fc (patch)
tree3e3292ce164ab57497379c52c3e7db9cc3b81d7c /meet.lua
parent20f324ea775636bfb94e1ec8f3214438b146f645 (diff)
downloaddothammerspoon-c50888fd0ea6f0802b834dbf4c2a799bdb37d3fc.tar.bz2
Add a way to set output volume from a Google Meet videoconference
I'm planning to make a Greasemonkey script that loads on Google Meet videoconference pages and make an HTTP request to this Hammerspoon server to set the output volume to a predetermined level.
Diffstat (limited to 'meet.lua')
-rw-r--r--meet.lua46
1 files changed, 46 insertions, 0 deletions
diff --git a/meet.lua b/meet.lua
new file mode 100644
index 0000000..238a376
--- /dev/null
+++ b/meet.lua
@@ -0,0 +1,46 @@
+-- Copyright (c) 2021 Teddy Wing
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+
+meet_csrf = 'tRuEptc89Uu 1UdpeOl1SZWW8QjjVSj8cu9kv7di68YDGZH83gKdC3H725f xIo4MqFacxqInARWtTkhcmOWDLNL5bti6d22ZwqF'
+
+meet_server = hs.httpserver.new(false, false)
+meet_server:setInterface('loopback')
+meet_server:setPort(3337)
+meet_server:setCallback(function(method, path, headers, body)
+ response_headers = {}
+ response_headers['Access-Control-Allow-Origin'] = 'https://meet.google.com'
+ response_headers['Vary'] = 'Origin'
+
+ if headers['HS-Meet'] ~= meet_csrf then
+ return '', 403, response_headers
+ end
+
+ if method == 'POST' then
+ if path == '/volume-meet' then
+ wasSet = hs.audiodevice.defaultOutputDevice():setOutputVolume(38)
+
+ if not wasSet then
+ return '', 500, response_headers
+ end
+
+ return '', 200, response_headers
+ end
+ end
+
+ return '', 404, response_headers
+end)
+
+meet_server:start()