Metadata-Version: 2.1
Name: mmtools
Version: 0.0.29
Summary: mmtools
Home-page: https://github.com/frbor/mmtools
License: ISC
Author: Fredrik Borg
Author-email: fredrikb.borg@gmail.com
Requires-Python: >=3.7.0,<4.0.0
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved
Classifier: License :: OSI Approved :: ISC License (ISCL)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Utilities
Requires-Dist: caep (>=0.0.4,<0.1.0)
Requires-Dist: dbus-python (>=1.3.2,<2.0.0)
Requires-Dist: mattermostdriver (>=7.3.2,<8.0.0)
Requires-Dist: notify2 (>=0.3.1,<0.4.0)
Requires-Dist: passpy (>=1.0.2,<2.0.0)
Requires-Dist: pydantic (>=1.10.2,<2.0.0)
Requires-Dist: requests (>=2.28.1,<3.0.0)
Description-Content-Type: text/markdown

# mmtools - i3 status bar and notification script for Mattermost

mmtools are various tools using the [mattermost](https://mattermost.org) API.

# Installation

```bash
sudo pip3 install mmtools
```

This will install mmtols from pypi, including the following required packages:

- caep
- pydantic
- mattermostdriver
- passpy
- notify2
- dbus-python
- requests

For dbus-python to build, you need to have the libdbus-1-dev package installed. On debian you can do

```bash
sudo apt install libdbus-1-dev
```

# Tools

The following tools are included:

### mmstatus

`mmstatus` connects to the mattermost API to get unread messages in all channels. It then outputs a statusbar (usable in i3blocks) of unread messages and exits. Supports private/public/user channels and different coloring on group chats and user chats.

Example configuration for i3blocks:

```
[mattermost]
command=/usr/local/bin/mmstatus
separator=true
interval=60
signal=12
```

### mmpolybar

`mmpolybar` same as mmstatus, but with polybar colors.

Example configuration for polybar:

```
[module/mmpolybar]
type = custom/script
exec = mmpolybar
tail = true
```

### mmwaybar

`mmwaybar` same as mmstatus, but with output for waybar.

Example configuration for waybar:

```
"custom/mattermost": {
    "exec": " mmwaybar",
    "return-type": "json",
    "interval": 90
}
```

### mmwatch

`mmwatch` connects to the mattermost websocket API and can display notification on messages and send SIGUSR2 to i3blocks to update statusbar before next interval.


## Configuration

All tools can be configured using both command line arguments and a configuration file.

`mmtools` will first look for a configuration in `~/.config/mmtools/config-<HOSTNAME>` with fallback to `~/.config/mmtools/config`.

Use the following command to create the configuration `~/.config/mmtools/config`. The same configuration file is used for both tools.

```bash
mmconfig user
```

In this file you must specify at least:

```
# Mattermost server
server = <SERVER>

# Mattermost user
user = <USERNAME>

# either password
password = <MATTERMOST PASSWORD>

# OR pass entry (https://www.passwordstore.org)
password-pass-entry = <PASS ENTRY>
```

## User service for `mmwatch`

`mmwatch` can be started as a systemd user service by creating the following file:

`.config/systemd/user/mmwatch.service`

with this content:

```
[Unit]
Description=mm watch

[Service]
ExecStart=/usr/local/bin/mmwatch

Restart=always

# time to sleep before restarting a service
RestartSec=30

[Install]
WantedBy=default.target
```

Enable at login

```
systemctl --user enable mmwatch
```

Start manually
```
systemctl --user start mmwatch
```

# Local development

For local development, execute:

```bash
pip3 install -e .
```

