OBS is a great streaming software, the only issue is that you cannot send hotkeys to it when on wayland as it would be "insecure" - I get the mentality, if you allowed hotkey acess to a window not in focus, it could very well be malicious.
The way around this is as follows:
Install python library - simpleobsws:
pip install simpleobsws
Write a python script as follows:
in obs_switch.py:
import asyncio
import simpleobsws
import sys
async def control_obs(action):
url = "ws://localhost:4444"
ws = simpleobsws.WebSocketClient(url=url)
try:
await ws.connect()
await ws.wait_until_identified()
if action in ["1", "2"]: # Scene switching
scenes = {
"1": "camera",
"2": "screen"
}
request = simpleobsws.Request('SetCurrentProgramScene', {
'sceneName': scenes[action]
})
await ws.call(request)
elif action == "toggle":
# First check recording status
request = simpleobsws.Request('GetRecordStatus')
status = await ws.call(request)
if status.responseData['outputActive']:
request = simpleobsws.Request('StopRecord')
else:
request = simpleobsws.Request('StartRecord')
await ws.call(request)
finally:
await ws.disconnect()
if __name__ == "__main__":
if len(sys.argv) > 1:
asyncio.run(control_obs(sys.argv[1]))
then call this via a hotkey setup in GNOME:
/usr/bin/python3 /home/joshua/.config/scripts/obs_switch.py 1
/usr/bin/python3 /home/joshua/.config/scripts/obs_switch.py 2
/usr/bin/python3 /home/joshua/.config/scripts/obs_switch.py toggle
and assign it to whatever hotkey you want. You can now switch OBS stream inputs and toggle recording on the fly when not focusing on an OBS window.
Simple and a nice way to not have to mess around with other settings as it will then carry over to any hotkey daemon you set up.