linux-media-control

Control media playback on Linux using playerctl. Play, pause, skip, control volume for Spotify, VLC, and other media players. Use when a user asks FRIDAY to play music, pause, skip track, or control m

SKILL.md

GitHub

Linux Media Control CLI

Use playerctl to control media players (Spotify, VLC, Firefox, Chrome, etc.) from the terminal. This is the standard way to control media on Linux.

Setup

Install playerctl:

sudo apt-get install -y playerctl

Basic Playback Control

Play

playerctl play

Pause

playerctl pause

Toggle play/pause

playerctl play-pause

Stop

playerctl stop

Next track

playerctl next

Previous track

playerctl previous

Volume Control

Get current volume

playerctl volume

Set volume (0.0 to 1.0)

playerctl volume 0.5

Increase volume

playerctl volume 0.1+

Decrease volume

playerctl volume 0.1-

Mute (set to 0)

playerctl volume 0

Track Information

Current track metadata

playerctl metadata

Track title

playerctl metadata title

Artist

playerctl metadata artist

Album

playerctl metadata album

Current position

playerctl position

Track length

playerctl metadata mpris:length

Album art URL

playerctl metadata mpris:artUrl

Formatted output

playerctl metadata --format "{{ artist }} - {{ title }}"

Seeking

Go to position (seconds)

playerctl position 30

Skip forward 10 seconds

playerctl position 10+

Skip backward 10 seconds

playerctl position 10-

Player Selection

List available players

playerctl --list-all

Control specific player

playerctl --player=spotify play
playerctl --player=vlc pause
playerctl --player=firefox next

Control all players

playerctl --all-players pause

Ignore specific player

playerctl --ignore-player=chromium play-pause

Player Status

Get playback status

playerctl status

Returns: Playing, Paused, or Stopped

Check if playing

if [ "$(playerctl status)" = "Playing" ]; then
  echo "Music is playing"
fi

Shuffle & Loop

Get shuffle status

playerctl shuffle

Enable/disable shuffle

playerctl shuffle on
playerctl shuffle off
playerctl shuffle toggle

Get loop status

playerctl loop

Set loop mode

playerctl loop None
playerctl loop Track
playerctl loop Playlist

Advanced

Open URI in player

playerctl open "spotify:track:4iV5W9uYEdYUVa79Axb7Rh"
playerctl open "https://example.com/song.mp3"

Follow metadata changes (watch mode)

playerctl metadata --follow --format "Now playing: {{ artist }} - {{ title }}"

Wait for player events

playerctl --follow status

Spotify Specific

List Spotify tracks

playerctl --player=spotify metadata

Get Spotify track ID

playerctl --player=spotify metadata mpris:trackid

Play specific Spotify URI

playerctl --player=spotify open spotify:track:TRACK_ID

Scripts Examples

Now Playing Notification

notify-send "Now Playing" "$(playerctl metadata --format '{{ artist }} - {{ title }}')"

Auto-pause on lock

# Add to screen lock script
playerctl pause

Toggle play and show status

playerctl play-pause
if [ "$(playerctl status)" = "Playing" ]; then
  notify-send "Playing" "$(playerctl metadata title)"
else
  notify-send "Paused"
fi

System Volume (alternative)

Using pactl (PulseAudio)

# Get volume
pactl get-sink-volume @DEFAULT_SINK@

# Set volume
pactl set-sink-volume @DEFAULT_SINK@ 50%

# Increase volume
pactl set-sink-volume @DEFAULT_SINK@ +10%

# Decrease volume
pactl set-sink-volume @DEFAULT_SINK@ -10%

# Mute toggle
pactl set-sink-mute @DEFAULT_SINK@ toggle

Using amixer (ALSA)

# Increase volume
amixer set Master 10%+

# Decrease volume
amixer set Master 10%-

# Mute toggle
amixer set Master toggle

Notes

  • Linux-only.
  • Works with MPRIS-compatible players (Spotify, VLC, Firefox, Chrome, etc.).
  • Spotify must be running for Spotify commands to work.
  • Use playerctl --list-all to see available players.
  • Some features may vary by player.