lcpz / awesome-copycats

Awesome WM themes
3.08k stars 522 forks source link

control remote MPD using Lain widget #309

Closed zenodotus280 closed 11 months ago

zenodotus280 commented 11 months ago

I am trying to control a remote MPD instance using the PowerArrow Dark theme. I modified the mpd.lua with the correct MPD_HOST value. I can connect without issue using mpc -h example.com -p 6600 but I can't convince Awesome to pull the artist and title info into the status bar. I have created an mpd.conf and tried to direct the localhost instance to my example.com instance but it hasn't had any effect.

Any help would be greatly appreciated. I have not found anyone attempting to do this and no closed issues address this.

Awesome v4.3 (Too long) • Compiled against Lua 5.3.6 (running with Lua 5.3) • D-Bus support: ✔ • execinfo support: ✔ • xcb-randr version: 1.6 • LGI version: 0.9.2

Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio

lcpz commented 11 months ago

You're not supposed to modify mpd.lua, but rather write a Lain MPD widget in theme.lua. Example:

theme.mpd = lain.widget.mpd {
    host = "example.com",
    port = "6600",
    music_dir = "path/to/your/music/directory",
    settings = function()
        widget:set_markup(mpd_now.artist .. " " .. mpd_now.title)
    end
}

Reference: Lain MPD widget documentation.

zenodotus280 commented 11 months ago

Thank you! I thought I had tried that already but I didn't put the host, port, and music directory high enough in the widget. The music dir wasn't needed in the end as MPD must handle that remotely and the default is also port 6600 so I could have omitted that too.

For anyone else wanting confirmation on what's needed (the first part is so I can 'super+left-click' to open a TUI music controller):

-- MPD
local mpc_remote = " -h moode.home.arpa -p 6600"
local musicplr = awful.util.terminal .. " -e ncmpcpp" .. mpc_remote
local mpdicon = wibox.widget.imagebox(theme.widget_music)

[...]

theme.mpd = lain.widget.mpd({
    host = "moode.home.arpa",
    port = "6600",
    settings = function()

[...]