mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-19 11:15:40 +02:00
Added 'MPRIS' module
This commit adds the ability to display status information for MPRIS compatible music players. Closes #53
This commit is contained in:
parent
b5450c3918
commit
c27de56bea
9 changed files with 1266 additions and 1 deletions
|
@ -31,6 +31,7 @@
|
|||
([#404][404]).
|
||||
* pipewire: added `spacing`, `left-spacing` and `right-spacing`
|
||||
attributes.
|
||||
* mpris: new module ([#53][53]).
|
||||
|
||||
[96]: https://codeberg.org/dnkl/yambar/issues/96
|
||||
[380]: https://codeberg.org/dnkl/yambar/issues/380
|
||||
|
@ -38,6 +39,7 @@
|
|||
[400]: https://codeberg.org/dnkl/yambar/pulls/400
|
||||
[428]: https://codeberg.org/dnkl/yambar/pulls/428
|
||||
[404]: https://codeberg.org/dnkl/yambar/issues/404
|
||||
[53]: https://codeberg.org/dnkl/yambar/issues/53
|
||||
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -34,6 +34,9 @@ endif
|
|||
if plugin_mpd_enabled
|
||||
plugin_pages += ['yambar-modules-mpd.5.scd']
|
||||
endif
|
||||
if plugin_mpris_enabled
|
||||
plugin_pages += ['yambar-modules-mpris.5.scd']
|
||||
endif
|
||||
if plugin_i3_enabled
|
||||
plugin_pages += ['yambar-modules-i3.5.scd']
|
||||
plugin_pages += ['yambar-modules-sway.5.scd']
|
||||
|
|
95
doc/yambar-modules-mpris.5.scd
Normal file
95
doc/yambar-modules-mpris.5.scd
Normal file
|
@ -0,0 +1,95 @@
|
|||
yambar-modules-mpris(5)
|
||||
|
||||
# NAME
|
||||
mpris - This module provides MPRIS status such as currently playing artist/album/song
|
||||
|
||||
# TAGS
|
||||
|
||||
[[ *Name*
|
||||
:[ *Type*
|
||||
:< *Description*
|
||||
| state
|
||||
: string
|
||||
: One of *offline*, *stopped*, *paused* or *playing*
|
||||
| shuffle
|
||||
: bool
|
||||
: True if the *shuffle* flag is set
|
||||
| repeat
|
||||
: string
|
||||
: One of *none*, *track* or *paylist*
|
||||
| volume
|
||||
: range
|
||||
: Volume in percentage
|
||||
| album
|
||||
: string
|
||||
: Currently playing album
|
||||
| artist
|
||||
: string
|
||||
: Artist of currently playing song
|
||||
| title
|
||||
: string
|
||||
: Title of currently playing song
|
||||
| file
|
||||
: string
|
||||
: Filename or URL of currently playing song
|
||||
| pos
|
||||
: string
|
||||
: *%M:%S*-formatted string describing the song's current position
|
||||
(also see _elapsed_)
|
||||
| end
|
||||
: string
|
||||
: *%M:%S*-formatted string describing the song's total length (also
|
||||
see _duration_)
|
||||
| elapsed
|
||||
: realtime
|
||||
: Position in currently playing song, in milliseconds. Can be used
|
||||
with a _progress-bar_ particle.
|
||||
|
||||
# CONFIGURATION
|
||||
|
||||
[[ *Name*
|
||||
:[ *Type*
|
||||
:[ *Req*
|
||||
:< *Description*
|
||||
| identities
|
||||
: list of string
|
||||
: yes
|
||||
: A list of MPRIS client identities
|
||||
|
||||
# EXAMPLES
|
||||
|
||||
```
|
||||
bar:
|
||||
center:
|
||||
- mpris:
|
||||
identities:
|
||||
- "spotify"
|
||||
- "firefox"
|
||||
content:
|
||||
map:
|
||||
conditions:
|
||||
state != offline && state != stopped:
|
||||
- string: {text: "{artist}", max: 30 }
|
||||
- string: {text: "-" }
|
||||
- string: {text: "{title}", max: 30 }
|
||||
```
|
||||
|
||||
# NOTE
|
||||
|
||||
The 'identity' refers a part of your clients DBus bus name.
|
||||
You can obtain a list of available bus names using:
|
||||
|
||||
```
|
||||
Systemd: > busctl --user --list
|
||||
Playerctl: > playerctl --list-all
|
||||
Libdbus: > dbus-send --session --print-reply --type=method_call --dest='org.freedesktop.DBus' /org org.freedesktop.DBus.ListNames ... | grep 'org.mpris.MediaPlayer2'
|
||||
```
|
||||
|
||||
The identity refers to the part after 'org.mpris.MediaPlayer2'.
|
||||
For example, firefox may use the bus name
|
||||
'org.mpris.MediaPlayer2.firefox.instance_1_7' and its identity would be
|
||||
'firefox'
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
*yambar-modules*(5), *yambar-particles*(5), *yambar-tags*(5), *yambar-decorations*(5)
|
10
meson.build
10
meson.build
|
@ -4,13 +4,15 @@ project('yambar', 'c',
|
|||
meson_version: '>=0.59.0',
|
||||
default_options: ['c_std=c18',
|
||||
'warning_level=1',
|
||||
'werror=true',
|
||||
'b_ndebug=if-release'])
|
||||
|
||||
is_debug_build = get_option('buildtype').startswith('debug')
|
||||
plugs_as_libs = get_option('core-plugins-as-shared-libraries')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
cc_flags = [
|
||||
'-Werror=all'
|
||||
]
|
||||
|
||||
if cc.has_function('memfd_create',
|
||||
args: ['-D_GNU_SOURCE=200809L'],
|
||||
|
@ -75,7 +77,12 @@ backend_wayland = wayland_client.found() and wayland_cursor.found()
|
|||
tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')
|
||||
fcft = dependency('fcft', version: ['>=3.0.0', '<4.0.0'], fallback: 'fcft')
|
||||
|
||||
# DBus dependency. Used by 'modules/mpris'
|
||||
sdbus_library = dependency('libsystemd', 'libelogind', 'basu', required: get_option('plugin-mpris'))
|
||||
sdbus = declare_dependency(compile_args: ['-DHAVE_' + sdbus_library.name().to_upper()], dependencies:[sdbus_library])
|
||||
|
||||
add_project_arguments(
|
||||
cc_flags +
|
||||
['-D_GNU_SOURCE'] +
|
||||
(is_debug_build ? ['-D_DEBUG'] : []) +
|
||||
(backend_x11 ? ['-DENABLE_X11'] : []) +
|
||||
|
@ -180,6 +187,7 @@ summary(
|
|||
'Foreign toplevel (window tracking for Wayland)': plugin_foreign_toplevel_enabled,
|
||||
'Memory monitoring': plugin_mem_enabled,
|
||||
'Music Player Daemon (MPD)': plugin_mpd_enabled,
|
||||
'Media Player Remote Interface Specificaion (MPRIS)': plugin_mpris_enabled,
|
||||
'i3+Sway': plugin_i3_enabled,
|
||||
'Label': plugin_label_enabled,
|
||||
'Network monitoring': plugin_network_enabled,
|
||||
|
|
|
@ -26,6 +26,8 @@ option('plugin-mem', type: 'feature', value: 'auto',
|
|||
description: 'Memory monitoring support')
|
||||
option('plugin-mpd', type: 'feature', value: 'auto',
|
||||
description: 'Music Player Daemon (MPD) support')
|
||||
option('plugin-mpris', type: 'feature', value: 'enabled',
|
||||
description: 'Media Player Remote Interface Specificaion (MPRIS) support')
|
||||
option('plugin-i3', type: 'feature', value: 'auto',
|
||||
description: 'i3+Sway support')
|
||||
option('plugin-label', type: 'feature', value: 'auto',
|
||||
|
|
13
modules/dbus.h
Normal file
13
modules/dbus.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
// This header provides an generic interface for different versions of
|
||||
// systemd-sdbus.
|
||||
|
||||
#if defined(HAVE_LIBSYSTEMD)
|
||||
#include <systemd/sd-bus.h>
|
||||
#elif defined(HAVE_LIBELOGIND)
|
||||
#include <elogind/sd-bus.h>
|
||||
#elif defined(HAVE_BASU)
|
||||
#include <basu/sd-bus.h>
|
||||
#endif
|
||||
|
|
@ -22,6 +22,9 @@ plugin_mem_enabled = get_option('plugin-mem').allowed()
|
|||
mpd = dependency('libmpdclient', required: get_option('plugin-mpd'))
|
||||
plugin_mpd_enabled = mpd.found()
|
||||
|
||||
mpris = sdbus
|
||||
plugin_mpris_enabled = sdbus.found()
|
||||
|
||||
json_i3 = dependency('json-c', required: get_option('plugin-i3'))
|
||||
plugin_i3_enabled = json_i3.found()
|
||||
|
||||
|
@ -95,6 +98,10 @@ if plugin_mpd_enabled
|
|||
mod_data += {'mpd': [[], [mpd]]}
|
||||
endif
|
||||
|
||||
if plugin_mpris_enabled
|
||||
mod_data += {'mpris': [[], [mpris]]}
|
||||
endif
|
||||
|
||||
if plugin_i3_enabled
|
||||
mod_data += {'i3': [['i3-common.c', 'i3-common.h'], [dynlist, json_i3]]}
|
||||
endif
|
||||
|
|
1129
modules/mpris.c
Normal file
1129
modules/mpris.c
Normal file
File diff suppressed because it is too large
Load diff
6
plugin.c
6
plugin.c
|
@ -57,6 +57,9 @@ EXTERN_MODULE(mem);
|
|||
#if defined(HAVE_PLUGIN_mpd)
|
||||
EXTERN_MODULE(mpd);
|
||||
#endif
|
||||
#if defined(HAVE_PLUGIN_mpris)
|
||||
EXTERN_MODULE(mpris);
|
||||
#endif
|
||||
#if defined(HAVE_PLUGIN_i3)
|
||||
EXTERN_MODULE(i3);
|
||||
#endif
|
||||
|
@ -193,6 +196,9 @@ static void __attribute__((constructor)) init(void)
|
|||
#if defined(HAVE_PLUGIN_mpd)
|
||||
REGISTER_CORE_MODULE(mpd, mpd);
|
||||
#endif
|
||||
#if defined(HAVE_PLUGIN_mpris)
|
||||
REGISTER_CORE_MODULE(mpris, mpris);
|
||||
#endif
|
||||
#if defined(HAVE_PLUGIN_i3)
|
||||
REGISTER_CORE_MODULE(i3, i3);
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue