README.md

4fddc50d6d9f3d82220a4e3264d792d54fc940cf
weechat-matrix-rs/README.md rendered · source · history · blame · raw

167 lines · 6215 bytes

  1[![build-test-release](https://github.com/poljar/weechat-matrix-rs/actions/workflows/release.yml/badge.svg?event=push)](https://github.com/poljar/weechat-matrix-rs/actions/workflows/release.yml)
  2[![#weechat-matrix](https://img.shields.io/badge/matrix-%23weechat--matrix:termina.org.uk-blue.svg?style=flat-square)](https://matrix.to/#/!twcBhHVdZlQWuuxBhN:termina.org.uk?via=termina.org.uk&via=matrix.org)
  3[![license](https://img.shields.io/badge/license-ISC-blue.svg?style=flat-square)](https://github.com/poljar/weechat-matrix-rs/blob/master/LICENSE)
  4
  5# What is weechat-matrix?
  6
  7[Weechat](https://weechat.org/) is an extensible chat client.
  8
  9[Matrix](https://matrix.org/blog/home) is an open network for secure,
 10decentralized communication.
 11
 12weechat-matrix-rs is a Rust plugin for Weechat that lets Weechat communicate
 13over the Matrix protocol. This is a Rust rewrite of the
 14[weechat-matrix](https://github.com/poljar/weechat-matrix) Python script.
 15
 16# Project status
 17
 18This project is a work in progress and doesn't do much yet. It can connect
 19to a Matrix server and send messages.
 20
 21If you are interested in helping out take a look at the issue tracker.
 22
 23# Build
 24
 25Install Rust and the native build dependencies first. On Debian or Ubuntu a
 26typical build environment needs:
 27
 28    sudo apt install build-essential clang libclang-dev libsqlite3-dev pkg-config
 29
 30Other distributions use different package names, but the important native
 31pieces are a C/C++ compiler, `clang`/`libclang`, and SQLite development headers.
 32The `weechat-sys` dependency has a bundled WeeChat plugin header
 33(`weechat-plugin.h`) fallback. If you want to build against the exact WeeChat
 34API installed on your system, install the matching development package
 35(`weechat-dev` on Debian/Ubuntu) or point `WEECHAT_PLUGIN_FILE` at the full
 36path to that header:
 37
 38    export WEECHAT_PLUGIN_FILE=/usr/include/weechat/weechat-plugin.h
 39
 40If `bindgen` reports that `stddef.h`, `libclang`, or `libLLVM` is missing, check
 41that the `clang` command-line tools, C/C++ compiler headers, and matching
 42`libclang` package are installed. On minimal distributions the library package
 43alone may not provide the compiler include paths that `bindgen` needs.
 44
 45After the dependencies are installed the plugin can be compiled with:
 46
 47    cargo build --release
 48
 49If you are developing on weechat-matrix-rs, use debug builds which are faster at
 50the expense of plugin performance:
 51
 52    cargo build
 53
 54On Linux this creates a `libmatrix.so` file in the `target/release/`
 55(`target/debug` for dev builds) folder. Rename it to `matrix.so` and copy it to
 56your WeeChat plugin directory.
 57
 58`make install` uses WeeChat's XDG data directory by default:
 59
 60    make install
 61
 62This installs the release build to:
 63
 64    ${XDG_DATA_HOME:-$HOME/.local/share}/weechat/plugins/matrix.so
 65
 66Use `PROFILE=debug` for a debug build:
 67
 68    make install PROFILE=debug
 69
 70On older WeeChat setups the plugin directory may instead live under
 71`$WEECHAT_HOME/plugins`, commonly `~/.weechat/plugins/`. Create the directory if
 72needed and copy the renamed plugin there.
 73
 74On macOS the built library extension is usually `.dylib`. WeeChat may need this
 75extension enabled before it loads the plugin:
 76
 77    /set weechat.plugin.extension ".so,.dll,.dylib"
 78
 79Rename `target/release/libmatrix.dylib` to `matrix.dylib` before copying it to
 80your WeeChat plugin directory.
 81
 82# Debian / Ubuntu package
 83
 84A `.deb` package can be built using `cargo-deb`. This requires
 85[Rust installed](https://rustup.rs/) (via rustup, the recommended method).
 86
 87First ensure `cargo-deb` is available:
 88
 89    cargo install cargo-deb
 90
 91Then build the package with:
 92
 93    make deb
 94
 95The resulting `.deb` package is placed in `target/debian/`. Install it with:
 96
 97    sudo dpkg -i target/debian/weechat-matrix_*.deb
 98
 99# Loading the plugin
100
101Restart WeeChat after installing the plugin, or load it manually:
102
103    /plugin load matrix
104
105Check that it is loaded with:
106
107    /plugin list
108
109If WeeChat cannot find the plugin, check that the file is named `matrix.so`
110(`matrix.dylib` on macOS), that it is in a directory from WeeChat's plugin
111search path, and that `.so`/`.dylib` is enabled in
112`weechat.plugin.extension`.
113
114# Configuration
115
116Configuration is completed primarily through the Weechat interface. First start
117WeeChat, make sure the plugin is loaded, and then issue the following commands
118_(replace the placeholders in brackets [] with your own details)_:
119
1201. Add a server _(make sure the url includes the scheme e.g. 'https://matrix.org')_:
121
122       /matrix server add [server-name] [server-url]
123
1242. Set your username and password:
125
126       /set matrix-rust.server.[server-name].username [username]
127       /set matrix-rust.server.[server-name].password [password]
128
1293. Now try to connect. The first connection can take a few minutes while the
130   client syncs the account:
131
132       /matrix connect [server-name]
133
1344. Automatically connect to the server:
135
136       /set matrix-rust.server.[server-name].autoconnect on
137
1385. If everything works, save the configuration:
139
140       /save
141
142To hide join/leave noise from users who have not been active recently, add a WeeChat
143filter for Matrix smart-filter tags:
144
145       /filter add matrix_smart * matrix_smart_filter *
146
147The inactivity delay defaults to five minutes and can be changed with:
148
149       /set matrix-rust.look.smart_filter_delay 300000
150
151
152# Helpful Commands
153
154`/help matrix` will print information about the `/matrix` command.
155
156`/matrix help [command]` will print information for subcommands, such as `/matrix help server`.
157
158Room buffers accept normal message input after `/matrix connect [server-name]`
159has completed.
160
161`/matrix media download <mxc-uri> [file]` downloads Matrix media through the logged-in client, including homeservers that require authenticated media. It refuses to overwrite an existing file. When `[file]` is omitted, the media id is saved with the configured prefix, which defaults to `matrix-media-`:
162
163       /set matrix-rust.media.download_prefix matrix-media-
164
165The prefix may include a directory and supports `~`, `$XDG_STATE_HOME`, and `${XDG_STATE_HOME}`. Parent directories are created automatically:
166
167       /set matrix-rust.media.download_prefix "$XDG_STATE_HOME/weechat-matrix/media/matrix-media-"