summaryrefslogtreecommitdiffstats
path: root/core/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/command.c')
-rw-r--r--core/command.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/command.c b/core/command.c
index 416fbcd06a..c5c818e6b7 100644
--- a/core/command.c
+++ b/core/command.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdbool.h>
#include <assert.h>
+#include <time.h>
#include "config.h"
#include "talloc.h"
@@ -579,6 +580,18 @@ static int mp_property_cache(m_option_t *prop, int action, void *arg,
return m_property_int_ro(prop, action, arg, cache);
}
+static int mp_property_clock(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ char outstr[6];
+ time_t t = time(NULL);
+ struct tm *tmp = localtime(&t);
+
+ if ((tmp != NULL) && (strftime(outstr, sizeof(outstr), "%k:%M", tmp) == 5))
+ return m_property_strdup_ro(prop, action, arg, outstr);
+ return M_PROPERTY_UNAVAILABLE;
+}
+
/// Volume (RW)
static int mp_property_volume(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
@@ -1405,6 +1418,8 @@ static const m_option_t mp_properties[] = {
{ "cache", mp_property_cache, CONF_TYPE_INT },
M_OPTION_PROPERTY("pts-association-mode"),
M_OPTION_PROPERTY("hr-seek"),
+ { "clock", mp_property_clock, CONF_TYPE_STRING,
+ 0, 0, 0, NULL },
// Audio
{ "volume", mp_property_volume, CONF_TYPE_FLOAT,
@@ -1544,6 +1559,7 @@ static struct property_osd_display {
{ "pts-association-mode", "PTS association mode" },
{ "hr-seek", "hr-seek" },
{ "speed", _("Speed") },
+ { "clock", _("Clock") },
// audio
{ "volume", _("Volume"), .osd_progbar = OSD_VOLUME },
{ "mute", _("Mute") },