By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: Remotely Control Youtube With This Command-line Approach on Linux | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > Remotely Control Youtube With This Command-line Approach on Linux | HackerNoon
Computing

Remotely Control Youtube With This Command-line Approach on Linux | HackerNoon

News Room
Last updated: 2025/05/08 at 8:20 AM
News Room Published 8 May 2025
Share
SHARE

This pages describes how to remotely control youtube running within a browser from the command-line.

In practice this sort of script may not be used directly from the command-line but rather attached to a keyboard shortcut or run from another script that forms a larger process.

This approach only works for Linux due to the limitations of the Chrome extension it uses. If you have programming experience you may be able to adapt the approach for another operating system. I would direct anyone interested in doing this to mozeidon as an example of a remote control from Chrome which can be run from the command-line.

This approach only works for Chromium-based browsers. I got it working with Brave, but Vivalid is another Chrome-based browser.

How this works

This entire page is effectively alternative and more complete documentation for streamkeys which, almost incidentally provides this feature. This page, however, focuses on command-line usage for Linux – documents and works around some issues in streamkeys, and is an easy-to-find article on the topic of controlling youtube from the command-line.

Streamkeys was written with the intention of controlling youtube, or other media players, running with Chrome from any other tabs. However, incidentally it also provides support for MPRIS which is a generally linux protocol for controlling multimedia players from the command-line. This standard can be used to cotrol youtube playback from the command-line.

You can do things like:

  • Stop the player
  • Skip forward
  • Get the current position in the audio. Suitable for adding to notes or shared with others.
  • Get the length of the video

Obtaining the may be particularly useful when combined yt-dlp to obtain subtitles for the video.

Setting everything up

Unfortunately stream has been removed from the Chrome extension store, has a build process that depends on deprecated libraries, and requires an out of date build process. It does however still work.

You need to download streamkeys, build it, and manually add it to Chrome. This may be good experience for you if you ever intend to develop a browser extension.

Requirements:

  1. uv is needed to use an old version of python required by node-gyp which is required by node-sass

  2. nvm is required to use an old version of node used for building the extension

  3. python3-dbus is needed for the interface used to communicate with the extension from the command-line

  4. playerctl is a command-line tool to communicate with mediaplayers (includig streamkeys after some configuration).

Both of these tools are standard, broadly used develoment tools

To install requiments:

  1. sudo apt-get install pipx

  2. sudo apt-get install python3-dbus

  3. pipx install uv

  4. Follow the instructions here to install nvm. Note that nvm updaes you shell configuration and requires you to reload this configuraiton aor restart your shell

To make a build of streamkeys:

  1. cd ~/.local. I like to keep third-party installed code here – but you may store your code elsewhere.

  2. Clone streamkeys. git clone [email protected]:berrberr/streamkeys.git

  3. cd streamkeys

  4. Create a uv virtualenv with an old python uv venv --python=3.10

  5. Activate the uv virtual virtualenv source .venv/bin/activate

  6. Install node 16 nvm install 16

  7. Enable node 16 nvm use 16

  8. Add this python python --version should return 3.10 and node --version should 16.

  9. Set up the build environment with npm install

  10. Create the extension npm run dev

To install streamkeys:

  1. Locate the extension ./build/unpacked-dev

  2. Go to the extension page in chrome “chrome://extensions”

  3. Add a developer extension with the path of build/unpacked-dev

To enable streamkeys for use with debug (MPIRS), you must run a script.

  1. Find the id of the streamkeys extension. Go to brave://extensions/ and click on the Details of streamkeys package. This should have an ID – copy this ID.
  2. Run the script python3 ./build/unpacked-dev/native/mpris_host_setup.py install $ID with this ID.

The command playerctl pause should now pause youtube and playerctl play start it.

Usage

You can use playerctl from the command-line. You may like to explore the documentation. This script can be wrapped for ther purposes.

I use the following scripts (amongst others):

skip: Skip 10 seconds forward (or number of seconds given)

#!/bin/bash
playerctl position | perl -pe "$_ = $_ + ${1-10}" | xargs playerctl position; playerctl position

back: Skip 10 seconds backwards (or number of seconds given)

#!/bin/bash
skip ${1:--10}

pos: Return the position into the video

#!/bin/bash
playerctl position

yt-position: Return the percentage through the video

#!/bin/bash
length=$(playerctl metadata  | grep length | awk '{ print $3 }')
pos=$(playerctl position)
perl -e 'my ($a,$b) = @ARGV; print(int($a * 1000000 / $b * 100) . "%n")' "$pos" "$length"

yt-link: Return a link to the video 10 seconds ago

#!/bin/bash
mozeidon tabs  get  | jq '.[] | .[] | select(.url | test("youtube\.com")) | .url ' -rc | { read line ; echo $line&t=$(playerctl position | perl -pe '$_ -= 10') ; }

I use this script (and others) to refer to videos while taking notes in Obsidian. If you are interested in note taking you might like to read my review of note taking in Obsidian.

Alternatives

ytmdesktop is a desktop app for youtube which can be remotely controlled via http. There tends to be a risk that such players attached to a changing website like google will stop working unless they have dedicated maintainers.

You may prefer to download media from youtube using yt-dlp to download media and play it in another player.

A shortcut to jump to the youtube tab may be sufficient for your uses. I have down this before with a combination of key simulation with xdotool interacting with the tab selection feature and wmctrl to raise windows. You can aso used mozeidon to select tabs

It is to be noted that the youtube website provides a variety of social and recommednation featues that other approaches do not support.

References

  1. yt-dlp
  2. mozeidon

About me

I am @readwithai. I create tools for reading, research and agency sometimes using the markdown editor Obsidian.

I also create a stream of tools that are related to carrying out my work.

I write about lots of things – including tools like this – on X. My blog is more about reading and research and agency.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Google Maps Can Now Scan Your iPhone Screenshots for Places
Next Article Seven signs your iPhone is slowing itself down – including surprising torch clue
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

Top 10 Notebook LM Alternatives for Note Taking I
Computing
NFL issues brutal punishment decision to former Chiefs Super Bowl champion
News
Celsius Founder Alex Mashinsky Sentenced to 12 Years in Prison
Gadget
10 Amazon Prime Perks Every Smart Shopper Should Know
News

You Might also Like

Computing

Top 10 Notebook LM Alternatives for Note Taking I

28 Min Read
Computing

Want Trustworthy AI? Put It on the Blockchain | HackerNoon

16 Min Read
Computing

Xiaomi 14 Ultra to debut at the MWC 2024 · TechNode

1 Min Read
Computing

Power Concentration and Voting Dynamics in Compound Governance | HackerNoon

30 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?