Skip to content

Aziks0/aw-watcher-mpv

Repository files navigation

aw-watcher-mpv

An ActivityWatch watcher for mpv, as a C plugin.

Features

  • There is only one utility, no need for a logger and a scanner
  • It only runs when mpv is running
  • You can choose which properties you want to send on heartbeats

Note

Heartbeats are only sent when something is playing. If your media is paused, no heartbeats are sent.

Installation

Windows

Download aw-watcher-mpv-windows.zip from the latest release here.

Place aw-watcher-mpv.dll in your mpv scripts folder. By default, it is located in %APPDATA%/mpv. Check out the mpv documentation if you can't find it.

Linux

Important

mpv needs to be compiled with the cplugins feature, otherwise the plugin won't be loaded.

openssl-3 and libcurl need to be installed on your system.

Download aw-watcher-mpv-linux.tar.gz from the latest release here.

Place aw-watcher-mpv.so in your mpv scripts folder. If you don't know where to find it, check out the mpv documentation on the matter.

Configuration

You can configure the behavior of aw-watcher-mpv by creating a JSON file in your mpv script-opts folder (refer to installation section to find your mpv folder). The file needs to have the same name as the dll you've put in scripts (if you haven't changed the dll name, it should be named aw-watcher-mpv.json).

Options available

Option Description
url The URL of the Activity Watch API.
poll_time How often heartbeats are sent, in whole seconds (no float).
pulse_time Maximum time between 2 heartbeats to be merged, in whole seconds (no float).
log_level Log level. See its own section.
properties List of properties to send with each heartbeat. See its own section.

log_level

Log level available:

  • no
  • fatal
  • error
  • warn
  • info
  • debug

properties

You can choose which mpv properties you want to send by writing them in a JSON array. Take a look at the default configuration for an exemple.

A list of available properties can be found here or you can call mpv --list-properties in a shell.

Note

Heartbeats are only sent when the property core-idle is false.

Default configuration

{
    "url": "http://127.0.0.1:5600/api/0",
    "poll_time": 5,
    "pulse_time": 11,
    "log_level": "error",
    "properties": [
        "filename",
        "media-title"
    ]
}

Credits