From abfd7f3155690fae1cbbd11b764488aa6bfbcb7d Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Tue, 26 Dec 2017 22:58:37 +0100 Subject: [PATCH] dboxinfo: allow to show "neutrino uptime" Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/a98f94621a725fd474774426537900717a50bdf2 Author: Stefan Seyfried Date: 2017-12-26 (Tue, 26 Dec 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/dboxinfo.cpp | 9 ++++++++- src/gui/dboxinfo.h | 1 + src/neutrino.cpp | 2 ++ src/neutrino.h | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 94807100f..a4283181b 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -4,7 +4,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' Homepage: http://dbox.cyberphoria.org/ - (C) 2009-2011, 2013-2014 Stefan Seyfried + (C) 2009-2011, 2013-2014, 2017 Stefan Seyfried License: GPL @@ -74,6 +74,7 @@ CDBoxInfoWidget::CDBoxInfoWidget() percWidth = 3 * fm->getMaxDigitWidth() + fm->getRenderWidth("%"); //100% nameWidth = fontWidth * 17; + upmode = false; } CDBoxInfoWidget::~CDBoxInfoWidget() @@ -135,6 +136,10 @@ int CDBoxInfoWidget::exec(CMenuTarget* parent, const std::string &) res = menu_return::RETURN_EXIT_ALL; doLoop = false; } + else if (msg == CRCInput::RC_info) { + upmode = !upmode; + paint(); + } else { int mr = CNeutrinoApp::getInstance()->handleMsg( msg, data ); @@ -388,6 +393,8 @@ void CDBoxInfoWidget::paint() std::string str_now(strftime(g_Locale->getText(LOCALE_EXTRA_DBOXINFO_TIMEFORMAT), now)); struct sysinfo info; sysinfo(&info); + if (upmode) + info.uptime = time_monotonic() - CNeutrinoApp::getInstance()->getStartTime(); now -= info.uptime; std::string str_boot(strftime(g_Locale->getText(LOCALE_EXTRA_DBOXINFO_TIMEFORMAT), now)); diff --git a/src/gui/dboxinfo.h b/src/gui/dboxinfo.h index 1db13d966..9aa73d84a 100644 --- a/src/gui/dboxinfo.h +++ b/src/gui/dboxinfo.h @@ -53,6 +53,7 @@ class CDBoxInfoWidget : public CMenuTarget int sizeWidth; // width of mem / disk sizes int percWidth; int nameWidth; + bool upmode; // system or neutrino uptime void paint(); CComponentsHeader *header; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 253792cf2..893e4e2bc 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2378,6 +2378,8 @@ bool is_wakeup() int CNeutrinoApp::run(int argc, char **argv) { + neutrino_start_time = time_monotonic(); + puts("[neutrino] executing " NEUTRINO_APP_START_SCRIPT "."); if (my_system(NEUTRINO_APP_START_SCRIPT) != 0) perror(NEUTRINO_APP_START_SCRIPT " failed"); diff --git a/src/neutrino.h b/src/neutrino.h index 344154f1c..2b875ab53 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -91,6 +91,8 @@ private: int lastChannelMode; struct timeval standby_pressed_at; + time_t neutrino_start_time; + int current_muted; bool skipShutdownTimer; @@ -188,6 +190,7 @@ public: void switchTvRadioMode(const int prev_mode = NeutrinoModes::mode_unknown); void switchInfoIconsOnOff(); //NI + time_t getStartTime() { return neutrino_start_time; } bool isMuted() {return current_muted; } void setCurrentMuted(int m) { current_muted = m; }