📺 Control Chromecasts from Linux and D-Bus
Project description
📺 Control Chromecasts from Linux
Control your Chromecast via MPRIS media player controls.
MPRIS is the standard media player interface on Linux desktops.
chromecast_mpris
allows you to control media playback on Chromecasts, and provides an interface for playback information.
MPRIS integration is enabled by default in Plasma Desktop, and, along with GNOME's volume control widget, there are widgets for GNOME, too. playerctl
provides a CLI for controlling media players through MPRIS.
Check out ▶️mpris_server if you want to integrate MPRIS support into your media player.
Screenshots
Controlling a Chromecast via Plasma Desktop's Media Player widget:
Features
- Control generic music and video playback
- Control app playback
- View playback information in real-time
- Display thumbnail and title
- Display playback position and total time
- Seek forward and backward
- Play / Pause / Stop
- Volume up and down
- Play next and previous
- Quit Chromecast app
- Open media from MPRIS
- Playlist integration
Installation
Requirements
Installing PyGObject
On Debian-derived distributions like Ubuntu, install python3-gi
with apt
.
On Arch, you'll want to install python-gobject
, or install chromecast_mpris
directly from the AUR.
On macOS, install pygobject3
via brew
.
Use pip
to install PyGObject>=3.34.0
if there are no installation candidates available in your vendor's package repositories.
PyPI
python3 -m pip install chromecast_mpris
You'll get a chromecast_mpris
executable added to your $PATH
.
GitHub
Clone the repo, run python3 -m pip install -r requirements.txt
, followed by python3 setup.py install
.
You'll get a chromecast_mpris
executable added to your $PATH
.
AUR
If you're on Arch, you can install chromecast_mpris
directly from the AUR.
yay -S chromecast_mpris
Upgrading
Stable releases are uploaded to PyPI. You can upgrade your chromecast_mpris
installation like so:
python3 -m pip --upgrade chromecast_mpris
See the releases page on GitHub.
Usage
You'll need to make sure that your computer is on the same network as your Chromecasts, and that you're able to make connections to them.
It also helps to know the names of the devices in advance.
Help
$ chromecast_mpris --help
Usage: chromecast_mpris [OPTIONS]
Control Chromecasts through MPRIS media controls.
Options:
-n, --name TEXT Specify a Chromecast name, otherwise control the
first Chromecast found.
-w, --wait INTEGER Retry after specified amount of seconds if a
Chromecast isn't found.
-l, --log-level INTEGER Debugging log level. [default: 20]
--help Show this message and exit.
Connecting to a Chromecast
Connect to a Chromecast named "My Chromecast" and run chromecast_mpris
in the background.
$ chromecast_mpris -n "My Chromecast" &
[1] 1234
After launching chromecast_mpris
, you can use any MPRIS client to interact with it. MPRIS support is built in directly to Plasma Desktop and GNOME 3, and you can use playerctl
on the command-line.
Retrying until a Chromecast is found
You can use the -w/--wait
flag to specify a waiting period in seconds before chromecast_mpris
will try find a Chromecast again if one is not found initially.
For example, if you want to wait 60 seconds between scans for Chromecasts, you can run the following:
$ export SECONDS=60
$ chromecast_mpris -w $SECONDS
This is useful if you'd like to start chromecast_mpris
at login, and there is a chance that your Chromecast isn't on, or you're on a different network.
Opening a URI on a Chromecast
Get the D-Bus name for your Chromecast using playerctl
.
$ playerctl -l
My_Chromecast
Use the D-Bus name to issue commands to it.
$ export URL="http://ccmixter.org/content/gmz/gmz_-_Parametaphoriquement.mp3"
$ playerctl -p My_Chromecast open "$URL"
This will play a song on the Chromecast.
License
See LICENSE
. Message me if you'd like to use this project with a different license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chromecast_mpris-0.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 477ddadc50ac4c0e601b71afd8c5641c6651d1efd54a16b1e231417405ce4b02 |
|
MD5 | 5ee55d04cc6bf2f98fc35843a5de311c |
|
BLAKE2b-256 | 80fb1bdce37e32a19e8392d2ce86cab9c0f78ed813288a6524813e1e6965d1a3 |