| 1 |
Basic MPD |
| 2 |
========= |
| 3 |
|
| 4 |
This widget's purpose is to provide a simple interface to MPD, the Music Player |
| 5 |
Daemon. The widget will output track/album/artist information, formatted |
| 6 |
according to your wishes. |
| 7 |
|
| 8 |
Note, because Basic MPD runs on top of Obvious' MPD library, you do have access |
| 9 |
to features like pause/next/previous and everything else. However, this is done |
| 10 |
through the library directly rather than through Basic MPD. |
| 11 |
|
| 12 |
Note, because Basic MPD runs on top of Obvious' MPD library, access to advanced |
| 13 |
features is done using calls to the library via Basic MPD's connection to the |
| 14 |
MPD server. |
| 15 |
|
| 16 |
Settings available: |
| 17 |
------------------- |
| 18 |
- set_format: Takes a string/function to use to format the Basic MPD display |
| 19 |
output. If a function is given, then a table with keys "artist", "album", and |
| 20 |
"title" will be given to this function, and whatever string it returns will |
| 21 |
be displayed. If a string is given to set_format, then it will be displayed |
| 22 |
with substitutions done on it. The format understands "$artist", "$album" and |
| 23 |
"$title" to do the replacement. For example, you could have a format string |
| 24 |
like: "$artist//$album//$title". The slashes are literal slashes, and the |
| 25 |
special variables will be replaced. If you're using a format string, the |
| 26 |
length is respected. If you're using a function, handling length is up to |
| 27 |
you. See set_length documentation about how it handles length. |
| 28 |
- set_length: Setting length only works for when using a format string for |
| 29 |
set_format (this is the default if you never call set_format). It would be |
| 30 |
somewhat silly to have the length just cut off the end of the string. This |
| 31 |
could land you in a situation where you know the title and album but not the |
| 32 |
artist, for example. Instead, what happens is that the formatter tries to |
| 33 |
shorten the longest components of format first and even out the lengths of |
| 34 |
the fields. So for example, imagine you have the output "Matisse The Cat - |
| 35 |
Jesse Cook - Frontiers" in your widget, but want this to be cut down to 32 |
| 36 |
characters max. The system would reformat this as "Matisse T - Jesse Coo - |
| 37 |
Frontiers". |
| 38 |
- set_unknown: If some metadata is not available, this is the string that |
| 39 |
should be displayed in that metadata's place. So for example, if you don't |
| 40 |
know the album, it might be "Matisse The Cat - Jesse Cook - (Unknown)". |
| 41 |
|
| 42 |
To set one of these settings, simply do something like: |
| 43 |
obvious.basic_mpd.set_format("MPD: $title") |
| 44 |
|
| 45 |
Implementation: |
| 46 |
--------------- |
| 47 |
To use it, include it into your rc.lua by inserting this line (near the top |
| 48 |
preferably): |
| 49 |
|
| 50 |
```lua |
| 51 |
local mpd = require("obvious.basic_mpd") |
| 52 |
``` |
| 53 |
|
| 54 |
Then add it to your wibox's widgets list: |
| 55 |
|
| 56 |
```lua |
| 57 |
mpd() |
| 58 |
``` |
| 59 |
|
| 60 |
It's also possible to create binds to control MPD via Obvious' MPD library: |
| 61 |
-- mod-p to pause/play. |
| 62 |
awful.key({ modkey }, "p", function() |
| 63 |
mpd.connection:toggle_play() |
| 64 |
end), |
| 65 |
|
| 66 |
-- mod-plus/minus to decrease and increase volume by increments of 5. |
| 67 |
awful.key({ modkey, "Shift" }, "=", function () |
| 68 |
mpd.connection:volume_up(5) |
| 69 |
end), |
| 70 |
awful.key({ modkey }, "-", function () |
| 71 |
mpd.connection:volume_down(5) |
| 72 |
end), |
| 73 |
|
| 74 |
-- mod-> and mod-< to go forward/backward a song. |
| 75 |
bind({ modkey, "Shift" }, ",", function () |
| 76 |
mpd.connection:previous() |
| 77 |
mpd.update() |
| 78 |
end) |
| 79 |
bind({ modkey, "Shift" }, ".", function () |
| 80 |
mpd.connection:next() |
| 81 |
mpd.update() |
| 82 |
end) |