plug is a customizable vibrator control command wrapper
Find a file
2025-07-10 20:40:29 +03:00
src v1.0.0 2025-07-10 20:40:29 +03:00
.gitignore inital commit 2025-07-09 04:59:02 +03:00
Cargo.lock v1.0.0 2025-07-10 20:40:29 +03:00
Cargo.toml v1.0.0 2025-07-10 20:40:29 +03:00
README.md v1.0.0 2025-07-10 20:40:29 +03:00
rust-toolchain.toml v1.0.0 2025-07-10 20:40:29 +03:00

plug

plug is a customizable vibrator control command wrapper

it uses buttplug.io to communicate with hardware, so, it is only compatible with devices that are supported by it. you will need Intiface® Central (or any other impl) installed and listening on websocket for the buttplug.io client to connect to, though it doesn't have to be on the device you are running plug on.

installation

you will need rustup to build and install plug. after that, you may simply clone the repository and use cargo to install it:

git clone https://git.slonk.ing/slonk/plug
cargo install --path plug

usage

plug cargo check
plug meson compile -C build
plug test $((RANDOM % 6)) = 0
plug true
plug false
# truly, the limit is your imagination

config

file

the configuration file location defaults to $XDG_CONFIG_HOME/plug/config.toml on *nix, and %APPDATA%\plug\config.toml on windows, and can be overriden using the PLUG_CONFIG environment variable

the format, with defaults, is as follows:

url = "ws://127.0.0.1:12345"
trust_all_certs = false
timeout = 1000 # give up after trying to connect to
               # the remote after this many millis

[actions]
success = [1.0, 2000] # 1.0 (max) speed for 2000ms
error = [0.2, 400]    # 0.2 (20%) speed for 400ms

to disable a certain action, set it's value to "none". you can also use a 2d array to construct more complex patterns:

[actions]
success = [[1.0, 1000], [0.0, 500], [1.0, 1000]]
error = "none"

environment variables

alongside PLUG_CONFIG, you can also configure each value via environment variables.

export PLUG_URL=ws://10.69.0.2:12345
export PLUG_TRUST_ALL_CERTS=false
export PLUG_TIMEOUT=5000
export PLUG_ON_SUCCESS=1.0/2000 # 1.0 for 2000ms
export PLUG_ON_ERROR=0.2/400    # you know the drill

the pattern format for environment variables is a commaseparated array with elements in the shape of <speed>/<length>, so the toml example can be replicated as such:

export PLUG_ON_SUCCESS=1.0/1000,0.0/500,1.0/1000
export PLUG_ON_ERROR=none
# or
export PLUG_ON_ERROR=

all durations are in unsigned 64bit integer milliseconds

debugging

you can use the PLUG_LOG environment variable to configure what gets logged:

export PLUG_LOG=plug=error # quiet mode
export PLUG_LOG=plug=info  # default, basic action logging
export PLUG_LOG=debug      # detailed debug logging
export PLUG_LOG=plug=trace,buttplug=trace,debug # for debugging cosmic jokes

todo

  • choose devices
    • make waiting for device configurable, allow waiting for a specific device
    • choose which devices actually get activated
  • more actions
    • currently only Vibrate ScalarCmd on all motors is supported
    • support for other command types
    • configure which motors get triggered
  • more exit statuses
    • signal handling
    • make all 256 signals mappable
  • LD_PRELOADable version?
  • early termination handling