summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-06-26 03:51:53 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-06-26 03:51:53 +0200
commit33f5ba0b60a0d60bd63e3bde1e07fc2a2ffc456a (patch)
tree4e68e9d764c14024f1155729f633cdeccd657ed4
parent4261c8146812f0e48b8090e79c05cbc5db4bbd41 (diff)
downloadnncmpp-33f5ba0b60a0d60bd63e3bde1e07fc2a2ffc456a.tar.gz
nncmpp-33f5ba0b60a0d60bd63e3bde1e07fc2a2ffc456a.tar.xz
nncmpp-33f5ba0b60a0d60bd63e3bde1e07fc2a2ffc456a.zip
Allow running arbitrary MPD commands
m---------liberty0
-rw-r--r--nncmpp.c22
2 files changed, 22 insertions, 0 deletions
diff --git a/liberty b/liberty
-Subproject 3835b6e49975039a9f72b8920238f3141e7bece
+Subproject 6e9217e5d05d95849fbaa795f92eca4ad86b150
diff --git a/nncmpp.c b/nncmpp.c
index 65435d3..735d693 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -1555,6 +1555,7 @@ app_goto_tab (int tab_index)
\
XX( MPD_ADD, "Add song to playlist" ) \
XX( MPD_REPLACE, "Replace playlist with song" ) \
+ XX( MPD_COMMAND, "Send a raw command to MPD" ) \
\
XX( CHOOSE, "Choose item" ) \
XX( DELETE, "Delete item" ) \
@@ -1844,6 +1845,22 @@ app_setvol (int value)
return result;
}
+static void
+app_on_editor_end (bool confirmed)
+{
+ struct mpd_client *c = &g.client;
+ if (!confirmed)
+ return;
+
+ size_t len;
+ char *u8 = (char *) u32_to_u8 (g.editor_line, g.editor_len + 1, NULL, &len);
+ mpd_client_send_command_raw (c, u8);
+ free (u8);
+
+ mpd_client_add_task (c, mpd_on_simple_response, NULL);
+ mpd_client_idle (c, 0);
+}
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static bool
@@ -1865,6 +1882,10 @@ app_process_action (enum action action)
clear ();
app_invalidate ();
return true;
+ case ACTION_MPD_COMMAND:
+ app_editor_start (':');
+ g.on_editor_end = app_on_editor_end;
+ return true;
default:
return false;
@@ -2071,6 +2092,7 @@ g_default_bindings[] =
{ "Backspace", ACTION_UP, {}},
{ "a", ACTION_MPD_ADD, {}},
{ "r", ACTION_MPD_REPLACE, {}},
+ { ":", ACTION_MPD_COMMAND, {}},
{ "Left", ACTION_MPD_PREVIOUS, {}},
{ "Right", ACTION_MPD_NEXT, {}},