Skip to content

Instantly share code, notes, and snippets.

@kode54
Created March 18, 2023 00:19
Show Gist options
  • Save kode54/041bd92ea2a167097e32be32fcf2b2ef to your computer and use it in GitHub Desktop.
Save kode54/041bd92ea2a167097e32be32fcf2b2ef to your computer and use it in GitHub Desktop.
OBS Recording Toggle, based on obs-wayland-shortcuts, but using obs-cli and not obs-cli-leafac.
#!/usr/bin/env python3
# Original Author: Andrew Shark
# Homepage: https://gitlab.com/AndrewShark/obs-wayland-shortcuts
# License: GPLv3
# Modified By: Christopher Snowhill
# This script is made for convenience. It is invoked by a logid gesture for MX Master mouse.
# It also works when invoked by a keyboard shortcut from your preferred Wayland compositor/desktop environment.
import subprocess
obs_cli = "/usr/bin/obs-cli"
obs_password = "<your password here>"
p2_result = subprocess.run([obs_cli, "--password", obs_password, "recording", "toggle"], capture_output=True).stdout
print(p2_result)
@brubrant
Copy link

This didn't work for me on Manjaro. The obs_cli is outdated.

What Worked:

  1. Enabled websocket on OBS
  2. Instaled this lib using pipx: https://github.com/pschmitt/obs-cli
  3. Added this command on my wayland custom shortcuts: obs-cli -p -P record toggle

(change the password and the port on the above command)

@kode54
Copy link
Author

kode54 commented Jun 26, 2024

That script you linked to also supports a configuration file in your home directory for port/username/password, per the Python interface library it uses to talk to OBS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment