MCPcopy Index your code
hub / github.com/2e3s/aw-watcher-media-player

github.com/2e3s/aw-watcher-media-player @v1.1.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.4 ↗ · + Follow
45 symbols 80 edges 8 files 1 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Media Player watcher

This watcher sends information the media which is playing now to ActivityWatch. It supports any player which can report its status to the system and be controllable by tray or standard multimedia keys, such as Spotify, Foobar, browser-based players, and others. Most media players are supported.

Environment Support
Linux :heavy_check_mark: Yes (MPRIS)
Windows :heavy_check_mark: Yes
MacOS :heavy_check_mark: Yes

Examples of reported data

Spotify in Linux:

{
  "album": "How to Measure a Planet? (Deluxe Edition)",
  "artist": "The Gathering",
  "player": "Spotify",
  "title": "My Electricity",
  "uri": "https://open.spotify.com/track/1cSWc2kX4z39L5uFdGcjFP"
}

Firefox in Linux (no plugins):

{
    "artist": "Eileen",
    "player": "Mozilla Firefox",
    "title": "🇺🇦 🇵🇱 Гей, соколи! / Hej, sokoły! – Ukrainian/Polish folk song"
}

MS Edge in Windows:

{
  "artist": "Bel Canto Choir Vilnius",
  "player": "MSEdge",
  "title": "Shchedryk (Carol of the Bells) – Bel Canto Choir Vilnius"
}

Default Windows player

{
  "album": "Zemlya",
  "artist": "Okean Elzy",
  "player": "Microsoft.ZuneMusic_8wekyb3d8bbwe!Microsoft.ZuneMusic",
  "title": "Obijmy"
}

Spotify in MacOS:

{
  "album": "This Is the Sound",
  "artist": "Cellar Darling",
  "player": "Spotify.app",
  "title": "Fire, Wind & Earth"
}

Installation

  • Linux:
  • Install the attached .deb or .rpm file from the latest release.
  • To install manually and make it available for ActivityWatch, run sudo unzip -j aw-watcher-media-player-linux.zip aw-watcher-media-player -d /usr/local/bin in the console.
    • Optionally, to use visualizations, run sudo unzip -d /usr/local/share/aw-watcher-media-player/visualization aw-watcher-media-player-linux.zip 'visualization/*'.

Windows: - Download and run the attached installer aw-watcher-media-player-installer.exe from the latest release. - To install manually and make it available for ActivityWatch, unpack the executable from aw-watcher-media-player-windows.zip into any new folder, right-click on "Start" -> "System" -> "Advanced system settings" - "Advanced" tab -> "Environment Variables..." -> upper "Edit...", add the new folder path.

MacOS: - To install manually and make it available for ActivityWatch, run unzip -j aw-watcher-media-player-macos-aarch64.zip aw-watcher-media-player -d /usr/local/bin in the console. You may need to run sudo xattr -d com.apple.quarantine /usr/local/bin/aw-watcher-media-player. - Optionally, add aw-watcher-media-player to autostart at aw-qt/aw-qt.toml in config directory.

Configuration

Configuration file is located at config_dir/aw-watcher-media-player/aw-watcher-media-player.toml. It's created on the first run, or it may be created manually before running the binary. CLI arguments override the file configuration. Example:

port = 5600
host = "localhost"
poll_time = 5
include_players = ["Spotify", "firefox", "chrom"]
exclude_players = ["chromium"]

Filter options for including and excluding players for reporting look for a case-insensitive substring. Use -vv to see what's reported.

Note that normally browsers report the currently playing media to the system even in a private mode/tab/window.

Custom Visualization

custom_visualization

This watcher has a visualization which attempts to do its best to display the sorted list of artists with the overall play time for each artist. Note that ActiveWatch UI gives no abilities for the widget to control its sizing, so it may appear smaller than builtin visualizations.

1. - aw-server: Add the following section to your aw-server/aw-server.toml file in config directory: toml [server.custom_static] aw-watcher-media-player = "/path/to/aw-watcher-media-player/visualization" # aw-watcher-media-player = "/usr/share/aw-watcher-media-player/visualization" # .deb or .rpm installation # aw-watcher-media-player = "/usr/local/share/aw-watcher-media-player/visualization" # Linux installation from archive # aw-watcher-media-player = 'C:\Users\<USER>\AppData\Local\aw-watcher-media-player\visualization' # Windows installer - aw-server-rust: Add the following section to your aw-server-rust/config.toml file in config directory: toml [custom_static] aw-watcher-media-player = "/path/to/aw-watcher-media-player/visualization" # aw-watcher-media-player = "/usr/share/aw-watcher-media-player/visualization" # .deb or .rpm installation # aw-watcher-media-player = "/usr/local/share/aw-watcher-media-player/visualization" # Linux installation from archive # aw-watcher-media-player = 'C:\Users\<USER>\AppData\Local\aw-watcher-media-player\visualization' # Windows installer 2. Restart ActivityWatch 3. Add custom visualizations from the Activity Watch GUI: Activity > Edit View > Add Visualization > Custom Visualization 4. Enter aw-watcher-media-player for the watcher name.

The visualization is not customizable from ActivityWatch UI. In order to change, the output, open index.html: - Find getAggregation function and change event.data.artist to event.data.player to aggregate by players. - Change MAX_AGGREGATIONS to determine the maximum number of entries (default is 50).

Build

cargo build --release on any platform. See release.yml for details.

Extension points exported contracts — how you extend this code

CrossMediaPlayer (Interface)
(no doc) [3 implementers]
src/platform.rs

Core symbols most depended-on inside this repo

assert_toml_eq
called by 5
src/config.rs
sample_toml
called by 3
src/config.rs
default_config_file
called by 3
src/config.rs
default_port
called by 1
src/config.rs
default_host
called by 1
src/config.rs
default_poll_time
called by 1
src/config.rs
report_player
called by 1
src/config.rs
legacy_config_file
called by 1
src/config.rs

Shape

Function 18
Method 17
Class 9
Interface 1

Languages

Rust100%

Modules by API surface

src/config.rs25 symbols
src/watcher.rs4 symbols
src/platform/linux.rs4 symbols
src/platform/windows.rs3 symbols
src/platform/macos.rs3 symbols
src/platform.rs3 symbols
src/main.rs2 symbols
build.rs1 symbols

For agents

$ claude mcp add aw-watcher-media-player \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page