Control Chromecast Devices From A Linux Desktop Via MPRIS Widgets Using chromecast_mpris

chromecast_mpris is a daemon that allows you to control Chromecast devices from your Linux desktop using MPRIS widgets. The tool can also be used to open media and play YouTube videos on your Chromecast from the command line.

MPRIS (Media Player Remote Interfacing Specification) support is available by default in the Plasma Desktop and Cinnamon, GNOME has a simple MPRIS widget in its Date / Time menu (and there are third-party extensions for this as well, like this MPRIS Indicator Button), etc., and there's also a command line tool, called playerctl, to control media players that implement the MPRIS D-Bus Interface Specification.

chromecast_mpris GNOME Shell Indicator Button
chromecast_mpris controlling my Chromecast using the MPRIS Indicator Button extension for GNOME Shell

It's worth noting that this program only works with devices that implement the Cast v2 API (it uses PyChromecast under the hood to control Chromecast devices), like Chromecasts, and some Cast-enabled devices like Google Home.

Even though it can play media on the Chromecast with the help of the playerctl command, chromecast_mpris' purpose is to serve as a remote control, in the same way the MPRIS interface works for every other player that uses it, e.g. Rhythmbox, VLC, etc. So use it to play, pause, skip, fast-forward, rewind, seek and control the volume of remote Chromecast devices from your Linux desktop.

Since this exposes MPRIS controls for your Chromecast, it means you can also use your keyboard's media keys to remote control the Chromecast.

chromecast_mpris features:

  • Control video and music playback
  • View playback information in real time
  • Display thumbnail, title, playback position and media length
  • Seek forward and backward, play, pause, and stop playback
  • Volume up and down
  • Play next and previous
  • Quit casted app
  • Open media and play YouTube videos from the command line (using playerctl)

The program does not have playlist support yet.

Below you'll find a couple more screenshots of MPRIS widgets (under KDE Plasma and Cinnamon desktops) able to control a Chromecast device using chromecast_mpris:

chromecast_mpris KDE Plasma

chromecast_mpris Cinnamon Linux Mint

You might also like: How To Cast Your GNOME Shell Desktop To A Chromecast (With Audio, Wayland / X11 Support) Using Cast to TV


How to play media / YouTube videos on the Chromecast using chromecast_mpris and playerctl


Playing media / YouTube videos on the Chromecast requires knowing the device name. With chromecast_mpris installed and running, get the Chromecast device name using the following command (you'll need to install playerctl if you haven't already, e.g. on Debian / Ubuntu: sudo apt install playerctl):

playerctl --list-all

Once you know the Chromecast name, play a media file using:

playerctl --player MyDevice open "URL"

Replacing MyDevice with the device name, and URL with the link to the media file.

Example from the chromecast_mpris project page:

playerctl --player MyDevice open "http://ccmixter.org/content/gmz/gmz_-_Parametaphoriquement.mp3"

Or, play a YouTube video:

playerctl --player MyDevice open "YoutubeURL"

Replacing MyDevice with the Chromecast name, and YoutubeURL with the link to the YouTube video.

Example:

playerctl --player MyDevice open "https://www.youtube.com/watch?v=Jg5wkZ-dJXA"

You might also like: CATT Command Line Chromecast Player


Install chromecast_mpris



The tool is available on AUR for Arch Linux / Manjaro users, and on PyPI from where it can easily be installed on any Linux distribution using PIP.

Once installed, run it, and you will be able to control your Chromecast from a MPRIS widget:

chromecast_mpris

I only have one Chromecast device, so I'm not sure how chromecast_mpris behaves when there are multiple devices available. [[Edit]] The tool does have an option to specify which Chromecast device to use:

chromecast_mpris --name "MyDevice"

Where MyDevice is the name of the Chromecast device.

You can also specify the streaming device IP or hostname (--host), its UUID (--uuid), and there's also an option to retry after a specified amount of seconds if a device isn't found (--wait). See the application help (--help) for more info.

If you want to add this to your startup applications, and you've installed this using PIP, make sure you enter the full path to the executable (/home/YOURUSERNAME/.local/bin/chromecast_mpris).

More Chromecast-related articles from Linux Uprising: