diff --git a/HomeWidgets/README.md b/HomeWidgets/README.md index 00db02e..3d0f927 100644 --- a/HomeWidgets/README.md +++ b/HomeWidgets/README.md @@ -2,7 +2,7 @@ This scripts can be used as the backend for widgets on the home screen. They return a http response with html content that is displayed in the widget. -## AlbumsWidget +## WidgetAlbums Lists newest or random albums. @@ -11,7 +11,7 @@ Lists newest or random albums. | entries | Number of albums to list. | | view | `random` or `newest` | -## BatteryIndicatorWidget +## WidgetBatteryIndicator Reads the battery capacity from the sys filesystem. @@ -19,7 +19,19 @@ Reads the battery capacity from the sys filesystem. | -------- | ----------- | | battery | The battery sys folder, e.g. `BAT0` | -## SongsWidget +## WidgetPlaylists + +Lists newest playlists. + +| ARGUMENT | DESCRIPTION | +| -------- | ----------- | +| entries | Number of playlists to list. | + +## WidgetStats + +Show MPD database statistics. + +## WidgetSongs Lists newest or random songs. diff --git a/HomeWidgets/WidgetStats.lua b/HomeWidgets/WidgetStats.lua new file mode 100644 index 0000000..ae873c2 --- /dev/null +++ b/HomeWidgets/WidgetStats.lua @@ -0,0 +1,16 @@ +-- {"name": "WidgetStats", "file": "HomeWidgets/WidgetStats.lua", "version": 1, "desc": "Home widget for MPD DB stats.", "order":0,"arguments":[]} +local headers = "Content-type: text/html\r\n" + +local rc, result = mympd.api("MYMPD_API_STATS", {}) +local rows = {} +if rc == 0 then + table.insert(rows, "Artists" .. mympd.htmlencode(result.artists) .. "") + table.insert(rows, "Albums" .. mympd.htmlencode(result.albums) .. "") + table.insert(rows, "Songs" .. mympd.htmlencode(result.songs) .. "") +end + +local body = "" .. + table.concat(rows) .. + "
" + +return mympd.http_reply("200", headers, body)