项目作者: mariusor

项目描述 :
Basic mpris player control for linux command line
高级语言: C
项目地址: git://github.com/mariusor/mpris-ctl.git
创建时间: 2017-03-21T17:17:11Z
项目社区:https://github.com/mariusor/mpris-ctl

开源协议:MIT License

下载


mpris-ctl

MIT Licensed
Build status
AUR package
Coverity Scan status
Latest build

Is a minimalistic cli tool for controlling audio players exposing a MPRIS DBus interface, targeted at keyboard based WMs.

Its only build/run dependency is on the C dbus library.

Build

To build from source just clone the repository and run make.
By default the binary is installed in /usr/local/bin, but you can provide your own DESTDIR and INSTALL_PREFIX.

  1. $ git clone https://git.sr.ht/~mariusor/mpris-ctl
  2. $ cd mpris-ctl
  3. $ make release
  4. # make install

Usage

An example of configuration for i3/sway:

  1. bindsym XF86AudioPlay exec "mpris-ctl --player active --player inactive pp"
  2. bindsym XF86AudioStop exec "mpris-ctl --player active stop"
  3. bindsym XF86AudioNext exec "mpris-ctl --player active next"
  4. bindsym XF86AudioPrev exec "mpris-ctl --player active prev"

The --player flag supports passing multiple player names, or the values active or inactive.
The active players are considered to be the ones which have the play_status be Playing,
and the inactive ones are the ones with the play_status Stopped or Paused.

Eg:

  1. mpris-ctl --player Rhythmbox play
  2. mpris-ctl --player active pp
  3. mpris-ctl --player inactive play

A more advanced example could be (this requires a notify daemon to be running):

  1. set $mpris_notify notify-send "$(mpris-ctl info "%play_status")" \
  2. "$(mpris-ctl info "%artist_name: %track_name\nOn album '%album_name'")"
  3. bindsym $mod+XF86AudioPlay exec $mpris_notify
  4. # or even:
  5. bindsym XF86AudioPlay exec mpris-ctl pp && $mpris_notify

Supported format specifiers for mpris-ctl info command:

  1. Format specifiers:
  2. %player_name prints the player name
  3. %track_name prints the track name
  4. %track_number prints the track number
  5. %track_length prints the track length (seconds)
  6. %artist_name prints the artist name
  7. %album_name prints the album name
  8. %album_artist prints the album artist
  9. %play_status prints the playback status
  10. %shuffle prints the shuffle mode
  11. %volume prints the volume
  12. %loop_status prints the loop status
  13. %position prints the song position (seconds)
  14. %bitrate prints the track's bitrate
  15. %comment prints the track's comment
  16. %full prints all available information

Example:

  1. $ mpris-ctl info "%track_name"
  2. Song 42
  3. $ mpris-ctl info
  4. Song 42 - Bloor - The Best of Bloor

Resources

For discussions related to the project without requiring a Github account please see our mailing list: https://lists.sr.ht/~mariusor/mpris-tools.