return ${rc}
}
+list_id=0
+list_count=0
+menu=0
+
+PLAYLIST_DIR="/var/lib/mpd/playlists"
+
+playlists_get() {
+ files=$(ls ${PLAYLIST_DIR}/*.m3u)
+
+ # Clear list
+ pl=()
+
+ for f in ${files}; do
+ f=$(basename ${f} .m3u)
+ #log_info "f=$f"
+ pl+=("${f}")
+ done
+
+ list_count="${#pl[@]}"
+
+ ##log_info "count=${list_count}"
+ ##log_info "pl=${pl[@]}"
+}
+
keys_manager() {
while true; do
+ playlists_get
+
if key_pressed KEY_PLAYPAUSE ; then
log_info "mpc toggle"
fi
fi
+ if key_pressed KEY_UP ; then
+ menu=1
+
+ if [ ${list_id} -gt 0 ]; then
+ list_id=$((${list_id} - 1))
+ fi
+ fi
+
+ if key_pressed KEY_DOWN ; then
+ menu=1
+
+ list_id=$((${list_id} + 1))
+
+ if [ ${list_id} -ge ${list_count} ]; then
+ list_id=$((${list_id} - 1))
+ fi
+ fi
+
+ if key_pressed KEY_LEFT ; then
+ menu=1
+ fi
+
+ if key_pressed KEY_RIGHT ; then
+ menu=1
+ fi
+
+ if key_pressed KEY_ENTER ; then
+ menu=1
+ fi
+
+ if [ ${menu} -eq 1 ]; then
+ if is_mpc_playing ; then
+ mpc stop 1> /dev/null
+
+ log_info "menu = ${pl[${list_id}]}"
+ menu=0
+ fi
+
if is_mpc_playing ; then
+ menu=0
led_on
log_dbg "[playing]"
else
lcd_init
+#playlists_get
+#exit 1
+
# Start function in the background
keys_manager &