From c6265f985f6ea172e966d1119b01c465b108e901 Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Mon, 26 Aug 2019 16:54:51 +0200 Subject: [PATCH] Add mpris based media menu if spotify is running --- mybindings.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mybindings.lua b/mybindings.lua index 5b6ebed..1e8702e 100644 --- a/mybindings.lua +++ b/mybindings.lua @@ -40,6 +40,12 @@ local mpdmap = { {"r", mpd.prompt.toggle_replace_on_search, "toggle replacing" }, {"h", mb.grabf{keymap=mpdhosts, name="Select MPD host"}, "Change host" } } +local mprismap = { + {"m", binder.spawn("playerctl play-pause"), "Toggle" }, + {"n", binder.spawn("playerctl next"), "Next" }, + {"N", binder.spawn("playerctl previous"), "Prev" }, + {"s", binder.spawn("playerctl stop"), "Prev" }, +} local progmap = { {"f", binder.spawn("firefox"), "Firefox" }, @@ -71,7 +77,15 @@ local myglobalkeys = awful.util.table.join( --{{{ Modal mappings - awful.key({ modkey }, "m", mb.grabf{keymap=mpdmap, name="MPD", stay_in_mode=true}), + awful.key({ modkey }, "m", function() + awful.spawn.easy_async("playerctl -p spotify status", function(stdout, stderr, reason, exitcode) + if exitcode > 0 then + mb.grab(mpdmap, "MPD", true) + else + mb.grab(mprismap, "Spotify", true) + end + end) + end), --awful.key({ modkey, "Shift" }, "m", mb.grabf(mpdpromts, "MPD - Search for")), awful.key({ modkey }, "c", mb.grabf{keymap=progmap, name="Commands"}), awful.key({ modkey }, "d", mb.grabf{keymap=docmap, name="Documents"}),