diff --git a/htdocs/index.html b/htdocs/index.html
index 3ba6a7e..a035d4f 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -144,6 +144,9 @@
+
+ Save queue
+
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index 49a4656..9ff7a81 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -576,6 +576,13 @@ function addStream() {
$('#addstream').modal('hide');
}
+function saveQueue() {
+ if($('#playlistname').val().length > 0) {
+ socket.send('MPD_API_SAVE_QUEUE,'+$('#playlistname').val());
+ }
+ $('#savequeue').modal('hide');
+}
+
function confirmSettings() {
if($('#mpd_pw').val().length + $('#mpd_pw_con').val().length > 0) {
if ($('#mpd_pw').val() !== $('#mpd_pw_con').val())
diff --git a/src/mpd_client.c b/src/mpd_client.c
index ee49c84..8e5454e 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -169,6 +169,18 @@ out_play_track:
out_playlist:
free(p_charbuf);
break;
+ case MPD_API_SAVE_QUEUE:
+ p_charbuf = strdup(c->content);
+ if(strcmp(strtok(p_charbuf, ","), "MPD_API_SAVE_QUEUE"))
+ goto out_save_queue;
+
+ if((token = strtok(NULL, ",")) == NULL)
+ goto out_save_queue;
+
+ mpd_run_save(mpd.conn, token);
+out_save_queue:
+ free(p_charbuf);
+ break;
case MPD_API_SEARCH:
p_charbuf = strdup(c->content);
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEARCH"))
diff --git a/src/mpd_client.h b/src/mpd_client.h
index 165bb5b..001cfdc 100644
--- a/src/mpd_client.h
+++ b/src/mpd_client.h
@@ -44,6 +44,7 @@
X(MPD_API_ADD_PLAY_TRACK) \
X(MPD_API_ADD_PLAYLIST) \
X(MPD_API_PLAY_TRACK) \
+ X(MPD_API_SAVE_QUEUE) \
X(MPD_API_RM_TRACK) \
X(MPD_API_RM_ALL) \
X(MPD_API_SEARCH) \