Control Chromecast Devices From A Linux Desktop Via MPRIS Widgets Using cast_control
cast_control (previously 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.
cast_control 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, cast_controls' 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.
cast_control 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 cast_control:
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 cast_control and playerctl
Playing media / YouTube videos on the Chromecast requires knowing the device name. With cast_control 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 cast_control 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 cast_control
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:
cast_control service connect
If you have more than 1 Chromecast, you can specify the name of the device to connect to, using:
cast_control service connect --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/cast_control
).
More Chromecast-related articles from Linux Uprising:
- fx_cast Adds Chromecast Support To Firefox
- How To Use pulseaudio-dlna To Stream Audio To Chromecast Devices On Ubuntu 20.10 / Ubuntu 20.04 / Linux Mint 20.x
- Cast To TV v12 Chromecast Extension For GNOME Shell Adds Automatic Image Slideshow, Audio Only Transcoding, More
- Cast Videos To Chromecast On Linux With Gnomecast