Giter Club home page Giter Club logo

playerctl's Introduction

Playerctl

For true players only: vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others.

Chat

About

Playerctl is a command-line utility and library for controlling media players that implement the MPRIS D-Bus Interface Specification. Playerctl makes it easy to bind player actions, such as play and pause, to media keys. You can also get metadata about the playing track such as the artist and title for integration into statusline generators or other command-line tools.

Playerctl also comes with a daemon that allows it to act on the currently active media player called playerctld.

Using the CLI

playerctl [--version] [--list-all] [--all-players] [--player=NAME] [--ignore-player=IGNORE] [--format=FORMAT] [--no-messages] COMMAND

Here is a list of available commands:

Command Description
play Command the player to play.
pause Command the player to pause
play-pause Command the player to toggle between play/pause.
stop Command the player to stop.
next Command the player to skip to the next track.
previous Command the player to skip to the previous track.
position [OFFSET][+/-] Command the player to go to the position or seek forward or backward OFFSET in seconds.
volume [LEVEL][+/-] Print or set the volume to LEVEL from 0.0 to 1.0.
status Get the play status of the player. Either "Playing", "Paused", or "Stopped".
metadata [KEY...] Print the metadata for the current track. If KEY is passed, print only those values from the metadata.
open [URI] Command for the player to open a given URI. Can be either a file path or a remote URL.
loop [STATUS] Print or set the loop status. Either "None", "Track", or "Playlist".
shuffle [STATUS] Print or set the shuffle status. Either "On", "Off".

Selecting Players to Control

Without specifying any players to control, Playerctl will act on the first player it can find.

Playerctl comes with a service called playerctld that monitors the activity of media players in the background. If playerctld is running, Playerctl will act on players in order of their last activity. To start playerctld, add the following command to your system startup script:

playerctld daemon

You can list the names of players that are available to control that are running on the system with playerctl --list-all.

If you'd only like to control certain players, you can pass the names of those players separated by commas with the --player flag. Playerctl will select the first instance of a player in that list that supports the command. To control all players in the list, you can use the --all-players flag.

Similarly, you can ignore players by passing their names with the --ignore-player flag.

The special player name %any can be used in the list of selected players once to match any player not in the list. This can be used to prioritize or deprioritize players.

Examples:

# Command the first instance of VLC to play
playerctl --player=vlc play

# Command all players to stop
playerctl --all-players stop

# Command VLC to go to the next track if it's running. If it's not, send the
# command to Spotify.
playerctl --player=vlc,spotify next

# Get the status of the first player that is not Gwenview.
playerctl --ignore-player=Gwenview status

# Command any player to play, but select Chromium last
playerctl --player=%any,chromium play

# Command any player to play, but select VLC first
playerctl --player=vlc,%any play

Printing Properties and Metadata

You can pass a format string with the --format argument to print properties in a specific format. Pass the variable you want to print in the format string between double braces like {{ VARIABLE }}. The variables available are either the name of the query command, or anything in the metadata map which can be viewed with playerctl metadata. You can use this to integrate playerctl into a statusline generator.

For a simple "now playing" banner:

playerctl metadata --format "Now playing: {{ artist }} - {{ album }} - {{ title }}"
# prints 'Now playing: Lana Del Rey - Born To Die - Video Games'

Included in the template language are some built-in variables and helper functions for common formatting that you can call on template variables. It can also do basic math operations on numbers.

# Prints 'Total length: 3:23'
playerctl metadata --format "Total length: {{ duration(mpris:length) }}"

# Prints 'At position: 1:16'
playerctl position --format "At position: {{ duration(position) }}"

# Prints 'Artist in lowercase: lana del rey'
playerctl metadata --format "Artist in lowercase: {{ lc(artist) }}"

# Prints 'STATUS: PLAYING'
playerctl status --format "STATUS: {{ uc(status) }}"

# Prints the time remaining in the track (e.g, 'Time remaining: 2:07')
playerctl metadata --format "Time remaining: {{ duration(mpris:length - position) }}"

# Prints volume from 0 - 100
playerctl metadata --format "Volume: {{ volume * 100 }}"
Function Argument Description
lc string Convert the string to lowercase.
uc string Convert the string to uppercase.
duration int Convert the duration to hh:mm:ss format.
markup_escape string Escape XML markup characters in the string.
default any, any Print the first value if it is present, or else print the second.
emoji status or volume Try to convert the variable to an emoji representation.
trunc string, int Truncate string to a maximum length.
Variable Description
playerName The name of the current player.
position The position of the current track in microseconds
status The playback status of the current player
volume The volume from 0.0 to 1.0
album The album of the current track.
artist The artist of the current track.
title The title of the current track.

Following changes

You can pass the --follow flag to query commands to block, wait for players to connect, and print the query whenever it changes. If players are passed with --player, players earlier in the list will be preferred in the order they appear unless --all-players is passed. When no player can support the query, such as when all the players exit, a newline will be printed. For example, to be notified of information about the latest currently playing track for your media players, use:

playerctl metadata --format '{{ playerName }}: {{ artist }} - {{ title }} {{ duration(position) }}|{{ duration(mpris:length) }}' --follow

Changing the position of the track

You can seek to a position in the track or skip forward and back.

# Go back 30 seconds
playerctl position 30-

# Go forward 30 seconds
playerctl position 30+

# Seek to the position at 30 seconds
playerctl position 30

Troubleshooting

Debug Logging

To enable debug logging, set the environment variable G_MESSAGES_DEBUG=playerctl. It's helpful to include a debug log when you report issues.

No Players Found

Some players like Spotify require certain DBus environment variables to be set which are normally set within the session manager. If you're not using a session manager or it does not set these variables automatically (like xinit), launch your desktop environment wrapped in a dbus-launch command. For example, in your .xinitrc file, use this to start your WM:

exec dbus-launch --autolaunch=$(cat /var/lib/dbus/machine-id) i3

Some players may require installation of a plugin or other configuration.

In Quod Libet open the window File -> Plugins and select the plugin called MPRIS D-Bus Support.

Playerctld Autostart Issues

If playerctld does not autostart and you use xinit and systemd, you might need this fix to enable DBus activation to work correctly:

systemctl --user import-environment DISPLAY XAUTHORITY

if which dbus-update-activation-environment >/dev/null 2>&1; then
        dbus-update-activation-environment DISPLAY XAUTHORITY
fi

Installing

First, check and see if Playerctl is available from your package manager (if it is not, get someone to host a package for you) and also check the releases page on github.

Fedora

playerctl is available for Fedora 28 or later:

sudo dnf install playerctl

Mageia, openSUSE

playerctl is available for Mageia and openSUSE via this COPR repository. First, install the repository file for your distribution from COPR. Then, install playerctl with your package manager of choice.

Guix

playerctl is available as a Guix package which can be installed on any Linux distribution after installing Guix:

guix install playerctl

Compile from source

Using the cli and library requires GLib (which is a dependency of almost all of these players as well, so you probably already have it). You can use the library in almost any programming language with the associated introspection binding library.

Additionally, you also need the following build dependencies:

gobject-introspection for building introspection data (configurable with the introspection meson option)

gtk-doc for building documentation (configurable with the gtk-doc meson option)

Fedora users also need to install redhat-rpm-config

To generate and build the project to contribute to development and install playerctl to /:

meson mesonbuild
sudo ninja -C mesonbuild install

Note that you need meson installed. In case your distro only has an older version of meson in its repository you can install the newest version via pip:

pip3 install meson

Also keep in mind that gtk-doc and gobject-introspection are enabled by default, you can disable them with -Dintrospection=false and -Dgtk-doc=false.

If you don't want to install playerctl to / you can install it elsewhere by exporting DESTDIR before invoking ninja, e.g.:

export PREFIX="/usr/local"
meson --prefix="${PREFIX}" --libdir="${PREFIX}/lib" mesonbuild
export DESTDIR="$(pwd)/install"
ninja -C mesonbuild install

You can use it later on by exporting the following variables:

export LD_LIBRARY_PATH="$DESTDIR/${PREFIX}/lib/:$LD_LIBRARY_PATH"
export GI_TYPELIB_PATH="$DESTDIR/${PREFIX}/lib/:$GI_TYPELIB_PATH"
export PATH="$DESTDIR/${PREFIX}/bin:$PATH"

Using the Library

To use a scripting library, find your favorite language from this list and install the bindings library. Documentation for the library is hosted here. For examples on how to use the library, see the examples folder.

Example Python Script

For more advanced users, Playerctl provides an introspectable library available in your favorite scripting language that allows more detailed control like the ability to subscribe to media player events or get metadata such as artist and title for the playing track. This example uses the Python bindings.

#!/usr/bin/env python3

from gi.repository import Playerctl, GLib

player = Playerctl.Player('vlc')


def on_metadata(player, metadata):
    if 'xesam:artist' in metadata.keys() and 'xesam:title' in metadata.keys():
        print('Now playing:')
        print('{artist} - {title}'.format(
            artist=metadata['xesam:artist'][0], title=metadata['xesam:title']))


def on_play(player, status):
    print('Playing at volume {}'.format(player.props.volume))


def on_pause(player, status):
    print('Paused the song: {}'.format(player.get_title()))


player.connect('playback-status::playing', on_play)
player.connect('playback-status::paused', on_pause)
player.connect('metadata', on_metadata)

# start playing some music
player.play()

if player.get_artist() == 'Lana Del Rey':
    # I meant some good music!
    player.next()

# wait for events
main = GLib.MainLoop()
main.run()

For a more complete example which is capable of listening to when players start and exit, see player-manager.py from the official examples.

Resources

Check out the following articles about Playerctl:

Related projects from the maker of Playerctl:

License

This work is available under the GNU Lesser General Public License (See COPYING).

Copyright © 2014, Tony Crisci

playerctl's People

Contributors

acrisci avatar actondev avatar busybox11 avatar cnt0 avatar davidbittner avatar daviwil avatar dmsalomon avatar duxks avatar erzoe avatar fendse avatar hisbaan avatar hjdskes avatar jklotz77 avatar jwflory avatar kebablord avatar knowledgejunkie avatar markusg avatar matrach avatar matthias-fauconneau avatar maxice8 avatar orestisfl avatar patrickchin avatar pta2002 avatar sentriz avatar sudaraka avatar the-king-of-toasters avatar timgates42 avatar vild avatar xdavidwu avatar xpmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

playerctl's Issues

`playerctl` unable to get `track id` from Audacious

I was testing out seeking capabilities of playerctl with Audacious until the following happened:

$ playerctl position 10 +   
Could not execute command: Could not get track id to set position

Is this normal? I use i3 btw, which I'm hoping doesn't affect anything.

No D-Bus interface with Spotify

I went over some of the issues here and noticed that there's a problem with Spotify itself providing the D-Bus interface. Is this problem still relevant?

Output of:

$ dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
method return time=1515162666.148629 sender=org.freedesktop.DBus -> destination=:1.3 serial=3 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string ":1.3"
      string "org.gnome.Terminal"
      string ":1.1"
   ]

My original problem is with Spotify but I decided to try other media players with support for MPRIS D-Bus, so I tried Clementine. Still no players with playerctl -l.

I'm happy to provide any other needed outputs.

library error

When typing 'playerctl play' into terminal I get the following error

playerctl: error while loading shared libraries: libplayerctl-1.0.so.0: cannot open shared object file: No such file or directory

System info

Linux dosx0029 3.16.0-24-generic #32-Ubuntu SMP Tue Oct 28 13:07:32 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Here are the details of my install process
http://pastebin.com/JgYaB4Bt

./autogen.sh
I am going to run ./configure with no arguments - if you wish 
to pass any to it, please specify them on the ./autogen.sh command line.
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I build/autotools
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build'.
libtoolize: copying file `build/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build/autotools'.
libtoolize: copying file `build/autotools/libtool.m4'
libtoolize: copying file `build/autotools/ltoptions.m4'
libtoolize: copying file `build/autotools/ltsugar.m4'
libtoolize: copying file `build/autotools/ltversion.m4'
libtoolize: copying file `build/autotools/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GOBJECT... yes
checking for GIO... yes
checking for gdbus-codegen... /usr/bin/gdbus-codegen
checking for gcc option to accept ISO C99... -std=gnu99
checking for gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking whether make supports nested variables... yes
checking dependency style of gcc -std=gnu99... gcc3
checking for pkg-config... (cached) /usr/bin/pkg-config
checking pkg-config is at least version 0.16... yes
checking for GLIB - version >= 2.0.0... yes (version 2.42.0)
checking for ar... ar
checking the archiver (ar) interface... ar
checking whether make supports nested variables... (cached) yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... yes
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gobject-introspection... no
checking for gtk-doc... yes
checking for gtkdoc-check... gtkdoc-check.test
checking for gtkdoc-check... /usr/bin/gtkdoc-check
checking for gtkdoc-rebase... /usr/bin/gtkdoc-rebase
checking for gtkdoc-mkpdf... /usr/bin/gtkdoc-mkpdf
checking whether to build gtk-doc documentation... no
checking for GTKDOC_DEPS... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating playerctl/Makefile
config.status: creating playerctl/playerctl.pc
config.status: creating playerctl/playerctl-version.h
config.status: creating doc/Makefile
config.status: creating doc/reference/Makefile
config.status: creating doc/reference/version.xml
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
make
make  all-recursive
make[1]: Entering directory '/home/BCAMATH/efoster/playerctl'
Making all in playerctl
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl/playerctl'
/usr/bin/gdbus-codegen --generate-c-code playerctl-generated mpris-dbus-interface.xml
make  all-am
make[3]: Entering directory '/home/BCAMATH/efoster/playerctl/playerctl'
  CC       playerctl-player.lo
  CC       playerctl-generated.lo
  CCLD     libplayerctl-1.0.la
  CC       playerctl-playerctl-cli.o
  CCLD     playerctl
  GEN      playerctl-1.0.pc
make[3]: Leaving directory '/home/BCAMATH/efoster/playerctl/playerctl'
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl/playerctl'
Making all in doc
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl/doc'
Making all in reference
make[3]: Entering directory '/home/BCAMATH/efoster/playerctl/doc/reference'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc/reference'
make[3]: Entering directory '/home/BCAMATH/efoster/playerctl/doc'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc'
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc'
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl'
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl'
make[1]: Leaving directory '/home/BCAMATH/efoster/playerctl'
sudo make install
Making install in playerctl
make[1]: Entering directory '/home/BCAMATH/efoster/playerctl/playerctl'
make  install-am
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl/playerctl'
make[3]: Entering directory '/home/BCAMATH/efoster/playerctl/playerctl'
 /bin/mkdir -p '/usr/local/lib'
 /bin/bash ../libtool   --mode=install /usr/bin/install -c   libplayerctl-1.0.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libplayerctl-1.0.so.0.0.0 /usr/local/lib/libplayerctl-1.0.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libplayerctl-1.0.so.0.0.0 libplayerctl-1.0.so.0 || { rm -f libplayerctl-1.0.so.0 && ln -s libplayerctl-1.0.so.0.0.0 libplayerctl-1.0.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libplayerctl-1.0.so.0.0.0 libplayerctl-1.0.so || { rm -f libplayerctl-1.0.so && ln -s libplayerctl-1.0.so.0.0.0 libplayerctl-1.0.so; }; })
libtool: install: /usr/bin/install -c .libs/libplayerctl-1.0.lai /usr/local/lib/libplayerctl-1.0.la
libtool: install: /usr/bin/install -c .libs/libplayerctl-1.0.a /usr/local/lib/libplayerctl-1.0.a
libtool: install: chmod 644 /usr/local/lib/libplayerctl-1.0.a
libtool: install: ranlib /usr/local/lib/libplayerctl-1.0.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
 /bin/mkdir -p '/usr/local/bin'
  /bin/bash ../libtool   --mode=install /usr/bin/install -c playerctl '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/playerctl /usr/local/bin/playerctl
 /bin/mkdir -p '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 playerctl-1.0.pc '/usr/local/lib/pkgconfig'
 /bin/mkdir -p '/usr/local/include/playerctl'
 /usr/bin/install -c -m 644 ../playerctl/playerctl-player.h ../playerctl/playerctl-version.h ../playerctl/playerctl.h '/usr/local/include/playerctl'
make[3]: Leaving directory '/home/BCAMATH/efoster/playerctl/playerctl'
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl/playerctl'
make[1]: Leaving directory '/home/BCAMATH/efoster/playerctl/playerctl'
Making install in doc
make[1]: Entering directory '/home/BCAMATH/efoster/playerctl/doc'
Making install in reference
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl/doc/reference'
make[3]: Entering directory '/home/BCAMATH/efoster/playerctl/doc/reference'
make[3]: Nothing to be done for 'install-exec-am'.
Nothing to install
make[3]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc/reference'
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc/reference'
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl/doc'
make[3]: Entering directory '/home/BCAMATH/efoster/playerctl/doc'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc'
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc'
make[1]: Leaving directory '/home/BCAMATH/efoster/playerctl/doc'
make[1]: Entering directory '/home/BCAMATH/efoster/playerctl'
make[2]: Entering directory '/home/BCAMATH/efoster/playerctl'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/BCAMATH/efoster/playerctl'
make[1]: Leaving directory '/home/BCAMATH/efoster/playerctl'
playerctl play
playerctl: error while loading shared libraries: libplayerctl-1.0.so.0: cannot open shared object file: No such file or directory

List all dependencies

The read me needs to state that libglib2.0, gtk-doc-tools, and gobject_introspection are dependencies. I am sure there are other dependencies, but those are the ones I ran into.

No metadata on Spotify

On playerctl version 0.4.2-1, spotify version 0.9.17.1-1, running playerctl metadata outputs no metadata. Other commands (play, pause) work with spotify, and metadata works with other players (tested it with vlc).

playerctl position does not work

Looks like position argument is not working correctly with Spotify.

user@ubuntu:~$ playerctl position 10
An error occurred: Could not get track id to set position

Though following works:

user@ubuntu:~$ playerctl metadata
{'mpris:trackid': <'spotify:track:3emundWeK0EWgGVU2tDzfs'>, ...

For reproduction:

user@ubuntu:~$ spotify --version
Spotify version 1.0.28.89.gf959d4ce, Copyright (c) 2016, Spotify Ltd
user@ubuntu:~$ playerctl --version
v0.5.0

I am using Ubuntu Server 16.04.

Spotify: Connection to player failed: No players found

Hi there,

Thanks a lot for playerctl!

I would like to use it together with Spotify. Spotify is installed and running:

Output ps aux:

orschiro 31357  1.3  1.7 804368 138764 ?       Sl   11:29   0:07 /usr/share/spotify/spotify-client/spotify
orschiro 31366  0.1  0.3 493768 30480 ?        S    11:29   0:00 /usr/share/spotify/spotify-client/spotify
orschiro 31367  0.0  0.4 344136 32956 ?        S    11:29   0:00 /usr/share/spotify/spotify-client/Data/SpotifyHelper --type=zygote --no-sandbox --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data
orschiro 31417  0.5  1.2 993664 97616 ?        Sl   11:30   0:02 /usr/share/spotify/spotify-client/Data/SpotifyHelper --type=renderer --js-flags=--harmony-proxies --no-sandbox --lang=en-US --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data --disable-accelerated-2d-canvas --disable-accelerated-video-decode --channel=31357.1.196113414
orschiro 31419  0.0  0.6 945152 53008 ?        Sl   11:30   0:00 /usr/share/spotify/spotify-client/Data/SpotifyHelper --type=renderer --js-flags=--harmony-proxies --no-sandbox --lang=en-US --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data --disable-accelerated-2d-canvas --disable-accelerated-video-decode --channel=31357.2.1469170544
orschiro 31420  0.1  0.6 948928 55740 ?        Sl   11:30   0:00 /usr/share/spotify/spotify-client/Data/SpotifyHelper --type=renderer --js-flags=--harmony-proxies --no-sandbox --lang=en-US --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data --disable-accelerated-2d-canvas --disable-accelerated-video-decode --channel=31357.3.1245562772
orschiro 31429  0.0  0.6 947500 51544 ?        Sl   11:30   0:00 /usr/share/spotify/spotify-client/Data/SpotifyHelper --type=renderer --js-flags=--harmony-proxies --no-sandbox --lang=en-US --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data --disable-accelerated-2d-canvas --disable-accelerated-video-decode --channel=31357.4.538276180
orschiro 31449  0.1  0.8 458468 70392 ?        Sl   11:30   0:00 /usr/share/spotify/spotify-client/Data/SpotifyHelper --type=gpu-process --channel=31357.5.1794837258 --no-sandbox --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data --supports-dual-gpus=false --gpu-driver-bug-workarounds=0,6,19 --gpu-vendor-id=0x8086 --gpu-device-id=0x2a42 --gpu-driver-vendor --gpu-driver-version --lang=en-US --locales-dir-path=/usr/share/spotify/spotify-client/Data/locales --log-severity=disable --resources-dir-path=/usr/share/spotify/spotify-client/Data

However, playerctl fails with the following command:

~ playerctl next
Connection to player failed: No players found

Installed applications:

spotify 0.9.11.27-1
playerctl 0.4.0-1
Arch Linux 64 Bit 3.16.5-1-ck

Any idea why the spotify player is not found?

Thanks for your help!

Package for Fedora

Hi! Could you please package playerctl for Fedora in order for its users to take advantage of it without having to compile it? A COPR repository would be even bettter.
Thanks in advance!

PS: Another idea could be creating a flatpak for it.

autogen.sh fails with error: HAVE_INTROSPECTION does not appear in AM_CONDITIONAL

This is occurring when I try to build the package on Ubuntu 14.04. Here is the full output from sudo ./autogen.sh:

I am going to run ./configure with no arguments - if you wish 
to pass any to it, please specify them on the ./autogen.sh command line.
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I build/autotools
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build'.
libtoolize: copying file `build/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build/autotools'.
libtoolize: copying file `build/autotools/libtool.m4'
libtoolize: copying file `build/autotools/ltoptions.m4'
libtoolize: copying file `build/autotools/ltsugar.m4'
libtoolize: copying file `build/autotools/ltversion.m4'
libtoolize: copying file `build/autotools/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
playerctl/Makefile.am:73: error: HAVE_INTROSPECTION does not appear in AM_CONDITIONAL
autoreconf: automake failed with exit status: 1

Doesn't work with Banshee

Maybe I'm doing something wrong, but I can't control Banshee with playerctl. It does not see the player, the list option shows "no players".

It works fine for Clementine, Spotify and Amarok.

Is there anything I can try to get it working - or help you add the support?


version 0.4.2, built from AUR
Arch 64bit, Xfce4

mpv Support?

I'm very often using mpv as player for videos. I noticed that playerctl don't supports it.
Would be very nice if you could add it (if possible)! 😃

Option to list available players

As @acrisci mentioned in #2 (c.f. his comment), you can list the currently available MPRIS-compatible players with:

dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames

It would be great to add a list command to playerctl to do this job.

BTW, it makes even more sense since playerctl asks for not the whole name but only the last field (i.e. org.mpris.MediaPlayer2.[PLAYER]) which would be used as is with the --player option.

e.g.

$ playerctl list
vlc
clementine
$ playerctl --player clementine play

Support for Totem Video Player?

Dear @acrisci,

I am wondering whether Totem Video Player is supported?

Yours,

Robert

image
Playerctl saying no supported players found despite Totem playing an mp3 file.

i386 release?

Is there a possibility for a i386 release for the 32bit ubuntu/debian?

Errors with gpmdp ( google-play-music-desktop-player )

Playerctl always outputs the following when I control google-play-music-desktop-player, as identified by playerctl -l. I'll refer to it as gpmdp from now.

(playerctl:13598): GLib-GIO-WARNING **: Received property Rate with type y does not match expected type d in the expected interface

(playerctl:13598): GLib-GIO-WARNING **: Received property Volume with type y does not match expected type d in the expected interface

(playerctl:13598): GLib-GIO-WARNING **: Received property Position with type u does not match expected type x in the expected interface

(playerctl:13598): GLib-GIO-WARNING **: Received property MinimumRate with type y does not match expected type d in the expected interface

(playerctl:13598): GLib-GIO-WARNING **: Received property MaximumRate with type y does not match expected type d in the expected interface

Playerctl is able to control gpmdp successfully but will cause the shell to get stuck after doing so and prevent a program that's supposed to run afterwards from running.

For example, I run a command to update my status bar with the current playing song.

Thanks for reading and let me know if any extra info is needed.

EDIT: I am running playerctl v0.5.0 and gpdmp v3.6.0. There are no new commits to the repo since v0.5.0 came out so I assume there are no differences between the release and the git version.

mpris metadata signal does not work with Spotify

Spotify does not emit the metadata signal correctly. We get errors like this with no event data given:

(process:18170): GLib-GIO-WARNING **: Value for PropertiesChanged signal with type '(sa{sv}an)' does not match '(sa{sv}as)'

It does however emit the signal correctly on the the properties signal. Here is an example Python script that works correctly:

interface_name = 'org.freedesktop.DBus.Properties'
member = 'PropertiesChanged'
object_path = '/org/mpris/MediaPlayer2'
arg0 = None
flags = 0
callback = properties_changed_callback
user_data = None
user_data_free_func = None

conn = Gio.bus_get_sync(Gio.BusType.SESSION, None)
conn.signal_subscribe(sender, interface_name, member, object_path, arg0,
                                     flags, callback, user_data, user_data_free_func)
GLib.MainLoop().run()

Implementing this in the library might be challenging because we may have to hold two connections to dbus, one for mpris and the other for the properties changed signal on the same object path.

Notification when player application closes?

I'm using playerctl's python interface to create an i3blocks script to show the current song title/artist. I've uploaded it as a gist here. Overall, it's been working great! One issue I've run into though is that while I can easily get updates when the song changes with callbacks registered via player.on('metadata'), I don't get any notifications when the player exits. If I quit spotify, my script doesn't get any updates and it will keep showing the song that was last playing.

One solution to this would be to periodically poll playerctl to see if the player is still active, but I'd like to avoid this if possible. Is there a way to get what I want out of playerctl? And if not, do you have any suggestions for how I might implement this? I'd be happy to send in a PR if this is functionality you'd like included in playerctl.

Thanks!

Error with unknown variable -e

When trying to execute the playerctl stop command from a service, so the music pauses when my compuer goes into suspended mode, the journalctl command shows this error:

 playerctl[27568]: Option parsing failed: Unknown option -e

and none of the other commands run. The service file is:

[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=forking

Environment=DISPLAY=:0
ExecStart=/usr/bin/playerctl stop
ExecStart=/usr/bin/locker
ExecStartPos=/usr/bin/sleep

[Install]
WantedBy=sleep.target

I think the command should take the varable but not do anything with it. Just to make it usable in the Service files.

Position not updates

def showPosition():
  threading.Timer(1.0, printit).start()
  print(player.props.position)

showPosition()

Just shows the same position every 1 second
The only solution I found is recreate the player object every time.

def showPosition():
  threading.Timer(1.0, printit).start()
  player = Playerctl.Player(player_name='clementine')
  print(player.props.position)

showPosition()

Any other solution ?

Update playerctl version in manpage using meson

The new manpage (doc/playerctl.1) includes the version of playerctl it covers.

Keeping the internal versioning in the manpage synchronised with that of the project as a whole could be achieved using meson.

Add option to output metadata as JSON

I'm having a bit of a tough time parsing the metadata output.

According to #22, it's formatted in "GVariant", which is rather obscure and lacks many utilities to assist with parsing it.

It seems a more standard format like JSON would make more sense.

Adding a flag like --output=FORMAT where FORMAT is one of json, gvariant, etc. and keeping gvariant as the default would ensure this change wouldn't break any existing dependent code.

playerctl volume, status and metadata not working with Spotify on Arch Linux

Hey,

I'm using Arch Linux and want to control Spotify v1.0.14 (latest release) with playerctl. The following commands work as expected:

  • play
  • pause
  • play-pause
  • stop
  • next
  • previous

Unfortunately the others however seem to be broken right now:

  • volume: has no effect at all
  • status: prints "Not available"
  • metadata: has no effect at all

Is this a problem of the Spotify client? Apparently DBUS support was removed in Spotify and was reintegrated just recently with v1.0.13. Are they maybe lacking some features of MPRIS in their current implementation?

GLib-GIO-WARNING **: Received property Rate with type y does not match expected type d in the expected interface

Dear @acrisci,

Thank you for your work!

I just installed the latest deb package on Ubuntu 16.10 to test it.

Can you help me with the following error?

Yours,

Robert

orschiro@x230:~$ playerctl play-pause

(playerctl:15525): GLib-GIO-WARNING **: Received property Rate with type y does not match expected type d in the expected interface

(playerctl:15525): GLib-GIO-WARNING **: Received property Volume with type y does not match expected type d in the expected interface

(playerctl:15525): GLib-GIO-WARNING **: Received property Position with type u does not match expected type x in the expected interface

(playerctl:15525): GLib-GIO-WARNING **: Received property MinimumRate with type y does not match expected type d in the expected interface

(playerctl:15525): GLib-GIO-WARNING **: Received property MaximumRate with type y does not match expected type d in the expected interface

playerctl status with Spotify

Hi, I'm using i3wm and wanted to display a notification when I play/pause my player. I've made a little script to achieve this with dunstify that looks like this :

#!/bin/bash
PLAYERSTATUS=$(playerctl status)
if [[ "$PLAYERSTATUS" == "Playing" ]]
then
	dunstify -p -r 3 -u low -i /usr/share/icons/Notifications/pause.png  "Player" "Paused";
elif [[ "$PLAYERSTATUS" == "Paused" ]]
then
	dunstify -p -r 3 -u low -i /usr/share/icons/Notifications/play.png "Player" "Playing";
else
	dunstify -p -r 3 -u low "Player" "$PLAYERSTATUS";
fi

For some reason, in Spotify, when it's the active player, I had to switch the status and display the notification with the reverse status, because there seems to be a delay between the display of the notification and the change of status making the notification display the reversed status. Now, when I tried with another player like MPV, I get Paused when Playing and Playing when Paused, so MPV is working as intended, why not Spotify?

Feature Request: API to list mpris players

While using the library, a function to find players instead of dealing with dbus would be nice.

Some research data from me:

According to MPRIS D-Bus Interface Specification;
Each media player must request a unique bus name which begins with org.mpris.MediaPlayer2.

And this project just pulled all the names and grepped the ones starting with org.mpris.MediaPlayer2;

function list-valid-player-targets {
    echo "$(dbus-send --session --dest=org.freedesktop.DBus \
        --type=method_call --print-reply /org/freedesktop/DBus \
        org.freedesktop.DBus.ListNames | grep org.mpris.MediaPlayer2 |
        awk -F\" '{print $2}' | cut -d '.' -f4- | sort )"
}

Fails to build when using parallel make

I cannot compile playerctl using parallel make:

alexander@localhost:.../playerctl$ make -j 4
make  all-recursive
make[1]: Entering directory '/home/alexander/src-ext/playerctl'
Making all in playerctl
make[2]: Entering directory '/home/alexander/src-ext/playerctl/playerctl'
/usr/bin/gdbus-codegen --generate-c-code playerctl-generated mpris-dbus-interface.xml
make[2]: *** No rule to make target 'playerctl-generated.h', needed by 'all'.  Schluss.
make[2]: *** Warte auf noch nicht beendete Prozesse...
make[2]: Leaving directory '/home/alexander/src-ext/playerctl/playerctl'
Makefile:427: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/alexander/src-ext/playerctl'
Makefile:358: recipe for target 'all' failed
make: *** [all] Error 2

Building using the non-parallel make succeeds:

alexander@localhost:../playerctl$ make
make  all-recursive
make[1]: Entering directory '/home/alexander/src-ext/playerctl'
Making all in playerctl
make[2]: Entering directory '/home/alexander/src-ext/playerctl/playerctl'
make  all-am
make[3]: Entering directory '/home/alexander/src-ext/playerctl/playerctl'
  CC       playerctl-player.lo
  CC       playerctl-generated.lo
  CCLD     libplayerctl-1.0.la
  CC       playerctl-playerctl-cli.o
  CCLD     playerctl
  GISCAN   Playerctl_1_0_gir
  GISCAN   Playerctl-1.0.gir
  GEN      playerctl-1.0.pc
  GICOMP   Playerctl-1.0.gir
make[3]: Leaving directory '/home/alexander/src-ext/playerctl/playerctl'
make[2]: Leaving directory '/home/alexander/src-ext/playerctl/playerctl'
Making all in doc
make[2]: Entering directory '/home/alexander/src-ext/playerctl/doc'
Making all in reference
make[3]: Entering directory '/home/alexander/src-ext/playerctl/doc/reference'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/alexander/src-ext/playerctl/doc/reference'
make[3]: Entering directory '/home/alexander/src-ext/playerctl/doc'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/alexander/src-ext/playerctl/doc'
make[2]: Leaving directory '/home/alexander/src-ext/playerctl/doc'
make[2]: Entering directory '/home/alexander/src-ext/playerctl'
make[2]: Leaving directory '/home/alexander/src-ext/playerctl'
make[1]: Leaving directory '/home/alexander/src-ext/playerctl'

Compilation fails with -j2 and higher

Hello,

Build fails if more than one thread (job) is used during "make" phase. This is probably due to race conditions since it fails on different things if -j2 and -j3 is used.

I found this because I created an ebuild to merge playerctl on Gentoo (available here: https://github.com/anders-larsson/gentoo-overlay/tree/master/media-sound/playerctl).

From travis (https://travis-ci.org/anders-larsson/gentoo-overlay):

   media-sound/playerctl/playerctl-0.4.2.ebuild: Upstream parallel compilation bug (ebuild calls emake -j1 on line: 39)
   media-sound/playerctl/playerctl-9999.ebuild: Upstream parallel compilation bug (ebuild calls emake -j1 on line: 39)

Build log:

playerctl-0.4.2 % make -j2
make  all-recursive
make[1]: Entering directory '/mnt/local/storage/home/workarea/playerctl-0.4.2'
Making all in playerctl
make[2]: Entering directory '/mnt/local/storage/home/workarea/playerctl-0.4.2/playerctl'
make  all-am
make[3]: Entering directory '/mnt/local/storage/home/workarea/playerctl-0.4.2/playerctl'
  CC       playerctl-player.lo
  CC       playerctl-generated.lo
  CC       playerctl-playerctl-cli.o
  GISCAN   Playerctl_1_0_gir
libtool:   error: cannot find the library 'libplayerctl-1.0.la' or unhandled argument 'libplayerctl-1.0.la'
linking of temporary binary failed: Command '['/bin/sh', '../libtool', '--mode=link', '--tag=CC', '--silent', 'cc', '-o', '/mnt/local/storage/home/workarea/playerctl-0.4.2/playerctl/tmp-introspectHf69RB/Playerctl-Playerctl_1_0_gir', '-export-dynamic', '/mnt/local/storage/home/workarea/playerctl-0.4.2/playerctl/tmp-introspectHf69RB/Playerctl-Playerctl_1_0_gir.o', '-L.', 'libplayerctl-1.0.la', '-lgio-2.0', '-lgobject-2.0', '-Wl,--export-dynamic', '-lgmodule-2.0', '-pthread', '-lglib-2.0']' returned non-zero exit status 1
/usr/share/gobject-introspection-1.0/Makefile.introspection:153: recipe for target 'Playerctl_1_0_gir' failed
make[3]: *** [Playerctl_1_0_gir] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/mnt/local/storage/home/workarea/playerctl-0.4.2/playerctl'
Makefile:424: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/mnt/local/storage/home/workarea/playerctl-0.4.2/playerctl'
Makefile:438: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/mnt/local/storage/home/workarea/playerctl-0.4.2'
Makefile:370: recipe for target 'all' failed
make: *** [all] Error 2

radiotray

Hi, thanks for this great and proper software. Could you please add the support on "radiotray"?
Ty

Feature Request: All stop/current command on all players

Some way to tell all mpris players to stop playing. Maybe one of these:

  • an all-stop command
  • the ability to pass in a wildcard as player. This could actually support wildcards, or only explicitly support a special string (maybe * or all) - which causes the current command to be executed against all players

Please consider adding a Changelog

Currently key changes between versions is available on the Github releases page.

Adding a changelog file to the project would be very useful not only to end-users for quickly understanding changes between releases (e.g. when using tarballs), but also for Linux distribution packagers who can automatically include the changelog with packaged versions of the software.

Timeout was reached

Hi,

My playerctl play-pause is returning the message An error ocurred: Timeout was reached. My spotify version is 1.0.52.717.g2f08534a.

What could I do to fix this? Is someone getting the same error?

Tks

Support wider set of characters in metadata

When playing a song called 'Lähettäkää minulle kirjoja' from Spotify, playerctl metadata 'xesam:title' gives me 'L?hett?k?? minulle kirjoja'.

It could also be possible that the problem is with Spotify...

Any chance of an Ubuntu x86_64 package please?

I tried building from source, which worked, but as you mentioned somewhere getting it rigged into your distro can be a challenge, so the media keys didn't work.

Any chance of an Ubuntu x86_64 package please? :) I also would be delighted to Flattr or gittip you for this work :)

Volume deltas (+/- by a certain amount)

Change volume by a certain amount with volume +/-.

This can be used in volume up and volume down key bindings.

Example:

playerctl volume +0.1 # increase volume by 10%
playerctl volume -0.2 # decrease volume by 20%

What is the default player? Or, --first-player-of=A,B,C

In the README:

If no player is specified, it will use the first player it can find.

How is it determined which one is first? Is it possible to have some influence over that?

Alternatively, what do you think of adding a command-line parameter that specifies multiple player name, and the command would be sent to the first of these that can be found? (That way the list specifies a priority order.)

If this sounds good, could you point me to appropriate parts of the code where I could start making a patch for it?

(My use case is that I keep Rhythmbox open semi-permanently in the background for music and pause it when I want to listen to something else. That something else might be another player supported by playerctl. If so, I’d like commands to go to that player until it is closed.)

Issue while building from source

I get the following error when I build from the source:

➜  playerctl git:(master) make
make  all-recursive
make[1]: Entering directory '/home/utkarsh/GitHub/playerctl'
Making all in playerctl
make[2]: Entering directory '/home/utkarsh/GitHub/playerctl/playerctl'
/usr/bin/gdbus-codegen --generate-c-code playerctl-generated mpris-dbus-interface.xml
make  all-am
make[3]: Entering directory '/home/utkarsh/GitHub/playerctl/playerctl'
  CC       playerctl-player.lo
  CC       playerctl-generated.lo
  CCLD     libplayerctl-1.0.la
ar: `u' modifier ignored since `D' is the default (see `U')
  CC       playerctl-playerctl-cli.o
playerctl-cli.c: In function ‘handle_player_command’:
playerctl-cli.c:298:55: warning: too many arguments for format [-Wformat-extra-args]
   g_set_error(error, playerctl_cli_error_quark (), 1, "Command not recognized: %s", command[0], NULL);
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CCLD     playerctl
  GEN      playerctl-1.0.pc
make[3]: Leaving directory '/home/utkarsh/GitHub/playerctl/playerctl'
make[2]: Leaving directory '/home/utkarsh/GitHub/playerctl/playerctl'
Making all in doc
make[2]: Entering directory '/home/utkarsh/GitHub/playerctl/doc'
Making all in reference
make[3]: Entering directory '/home/utkarsh/GitHub/playerctl/doc/reference'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/utkarsh/GitHub/playerctl/doc/reference'
make[3]: Entering directory '/home/utkarsh/GitHub/playerctl/doc'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/utkarsh/GitHub/playerctl/doc'
make[2]: Leaving directory '/home/utkarsh/GitHub/playerctl/doc'
make[2]: Entering directory '/home/utkarsh/GitHub/playerctl'
make[2]: Leaving directory '/home/utkarsh/GitHub/playerctl'
make[1]: Leaving directory '/home/utkarsh/GitHub/playerctl'

Fails to build on Debian

Hi! I can't build this on Debian unstable, as I get the following error:

make  all-recursive
make[1]: Entering directory '/tmp/p2'
Making all in playerctl
make[2]: Entering directory '/tmp/p2/playerctl'
/usr/bin/gdbus-codegen --generate-c-code playerctl-generated mpris-dbus-interface.xml
make  all-am
make[3]: Entering directory '/tmp/p2/playerctl'
  CC       playerctl-player.lo
  CC       playerctl-generated.lo
  CCLD     libplayerctl-1.0.la
  CC       playerctl-playerctl-cli.o
  CCLD     playerctl
playerctl-cli.c:58: error: undefined reference to 'g_option_context_new'
playerctl-cli.c:59: error: undefined reference to 'g_option_context_add_main_entries'
playerctl-cli.c:60: error: undefined reference to 'g_option_context_set_description'
playerctl-cli.c:61: error: undefined reference to 'g_option_context_set_summary'
playerctl-cli.c:63: error: undefined reference to 'g_option_context_parse'
playerctl-cli.c:97: error: undefined reference to 'g_printerr'
playerctl-cli.c:64: error: undefined reference to 'g_printerr'
playerctl-cli.c:174: error: undefined reference to 'g_string_new'
playerctl-cli.c:177: error: undefined reference to 'g_dbus_proxy_new_for_bus_sync'
playerctl-cli.c:192: error: undefined reference to 'g_dbus_proxy_call_sync'
playerctl-cli.c:206: error: undefined reference to 'g_variant_get_child_value'
playerctl-cli.c:208: error: undefined reference to 'g_variant_get_strv'
playerctl-cli.c:211: error: undefined reference to 'g_str_has_prefix'
playerctl-cli.c:212: error: undefined reference to 'g_strsplit'
playerctl-cli.c:213: error: undefined reference to 'g_string_append_printf'
playerctl-cli.c:214: error: undefined reference to 'g_strfreev'
playerctl-cli.c:69: error: undefined reference to 'g_print'
playerctl-cli.c:101: error: undefined reference to 'g_strcmp0'
playerctl-cli.c:107: error: undefined reference to 'g_ascii_strtod'
playerctl-cli.c:108: error: undefined reference to 'g_object_set'
playerctl-cli.c:165: error: undefined reference to 'g_printerr'
playerctl-cli.c:188: error: undefined reference to 'g_propagate_error'
playerctl-cli.c:77: error: undefined reference to 'g_printerr'
playerctl-cli.c:218: error: undefined reference to 'g_object_unref'
playerctl-cli.c:219: error: undefined reference to 'g_variant_unref'
playerctl-cli.c:220: error: undefined reference to 'g_variant_unref'
playerctl-cli.c:221: error: undefined reference to 'g_free'
playerctl-cli.c:223: error: undefined reference to 'g_string_free'
playerctl-cli.c:84: error: undefined reference to 'g_print'
playerctl-cli.c:90: error: undefined reference to 'g_option_context_get_help'
playerctl-cli.c:90: error: undefined reference to 'g_print'
playerctl-cli.c:201: error: undefined reference to 'g_propagate_error'
playerctl-cli.c:202: error: undefined reference to 'g_object_unref'
playerctl-cli.c:114: error: undefined reference to 'g_strcmp0'
playerctl-cli.c:117: error: undefined reference to 'g_strcmp0'
playerctl-cli.c:111: error: undefined reference to 'g_object_get'
playerctl-cli.c:112: error: undefined reference to 'g_print'
playerctl-cli.c:120: error: undefined reference to 'g_strcmp0'
playerctl-cli.c:146: error: undefined reference to 'g_free'
playerctl-cli.c:150: error: undefined reference to 'g_object_get'
playerctl-cli.c:158: error: undefined reference to 'g_free'
playerctl-cli.c:161: error: undefined reference to 'g_option_context_get_help'
collect2: error: ld returned 1 exit status
Makefile:539: recipe for target 'playerctl' failed
make[3]: *** [playerctl] Error 1
make[3]: Leaving directory '/tmp/p2/playerctl'
Makefile:412: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/tmp/p2/playerctl'
Makefile:426: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/p2'
Makefile:357: recipe for target 'all' failed
make: *** [all] Error 2

Can you tell me how to fix this? Please don't just refer me to the prebuilt Debian package.

Thanks!

SegFault when calling `playerctl.Player().play()` without any connected MPRIS server

alexander@localhost:...$ gdb python3
...
(gdb) run
Starting program: /usr/bin/python3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
Entering interactive mode...
>>> from gi.repository import Playerctl as playerctl
>>> p = playerctl.Player()
[New Thread 0x7ffff3e58700 (LWP 27204)]
>>> p.stop()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
GLib.Error: playerctl-player-error-quark: No players found (1)
>>> p.play()

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3ee7c19 in org_mpris_media_player2_player_get_playback_status (object=0x0) at playerctl-generated.c:3021
3021      return ORG_MPRIS_MEDIA_PLAYER2_PLAYER_GET_IFACE (object)->get_playback_status (object);
(gdb) bt full
#0  0x00007ffff3ee7c19 in org_mpris_media_player2_player_get_playback_status (object=0x0) at playerctl-generated.c:3021
No locals.
#1  0x00007ffff3ee3483 in playerctl_player_play (self=0xc73350, err=0x7fffffffd750) at playerctl-player.c:532
        tmp_error = 0x0
        status = <optimized out>
        __func__ = "playerctl_player_play"
#2  0x00007ffff50bfdc0 in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
No symbol table info available.
#3  0x00007ffff50bf828 in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
No symbol table info available.
#4  0x00007ffff5c84af4 in ?? () from /usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
No symbol table info available.
#5  0x00007ffff5c863f8 in ?? () from /usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
No symbol table info available.
#6  0x00007ffff5c7a5ae in ?? () from /usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
No symbol table info available.
#7  0x00000000004f2249 in PyEval_EvalFrameEx ()
No symbol table info available.
#8  0x00000000004ec9fc in PyEval_EvalCodeEx ()
No symbol table info available.
#9  0x0000000000581115 in ?? ()
No symbol table info available.
#10 0x000000000046021b in PyRun_InteractiveOneObject ()
No symbol table info available.
#11 0x000000000045fa36 in PyRun_InteractiveLoopFlags ()
No symbol table info available.
#12 0x000000000045bd6c in ?? ()
No symbol table info available.
#13 0x000000000041e233 in ?? ()
No symbol table info available.
#14 0x00000000004ca8ef in main ()
No symbol table info available.

As you can see from the log calling playerctl.Player().stop() produces the expected result (an exception), but playerctl.Player().play() causes a segmentation fault.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.