2020-09-25, 22:10
Hi,
I'm about to run Kodi 18.8 on Raspberry Pi boards and looking for a way to enable the Shutdown Timer for a user that doesn't have the right to shutdown the system.
There should be an "Exit Timer" enabled by default in such a case, when the user can't shutdown the system, but that's something that will take time & will to implement.
My use case is simple, I'm trying to turn Kodi into an actual MediaCenter and not only use it as a playback application. Shutting down the system running Kodi is really dumb IMO, because you need to power it back on manually after this and the remote control won't help.
I managed to get this done in Kodi 17.x by hacking the /xbmc/powermanagement/PowerManager.cpp, setting all validations on true, but the code in Kodi 17.x was simpler.
I'm starting Kodi 17.x with the help of lircd and irexec (launching a script) and keeping the underlying Linux system always on. The simple script (it lacks a check to figure if Kodi is already running):
When Kodi exits (even triggered by the Shutdown Timer), the lircd & irexec remain active and waiting for my remote control input to start Kodi again. This way I managed to have an actual Media Center that I'm controlling with the help of my remote control.
Now, Kodi 18.8 has some new, enhanced, PowerManagement code and I'm failing to hack it, that's override the checks for identifying if the user with which kodi was launched has shutdown permissions and set the validation on true by default and get the ShutDown Timer menu option displayed (active).
This is what I tried so far and failed - I only get the Exit menu option.
Original file:
https://github.com/xbmc/xbmc/blob/Leia/x...anager.cpp
My hacking attempt - diff -u PowerManager-orig.cpp PowerManager.cpp
I'm not very good in coding, failing to understand the logic in PowerManager.cpp and would be very thankful if some of the Kodi devs could help me with a simple way to override the shutdown validations/checks for the user that launched Kodi and get ShutDown Timer menu option displayed.
Many thanks in advance!
I'm about to run Kodi 18.8 on Raspberry Pi boards and looking for a way to enable the Shutdown Timer for a user that doesn't have the right to shutdown the system.
There should be an "Exit Timer" enabled by default in such a case, when the user can't shutdown the system, but that's something that will take time & will to implement.
My use case is simple, I'm trying to turn Kodi into an actual MediaCenter and not only use it as a playback application. Shutting down the system running Kodi is really dumb IMO, because you need to power it back on manually after this and the remote control won't help.
I managed to get this done in Kodi 17.x by hacking the /xbmc/powermanagement/PowerManager.cpp, setting all validations on true, but the code in Kodi 17.x was simpler.
I'm starting Kodi 17.x with the help of lircd and irexec (launching a script) and keeping the underlying Linux system always on. The simple script (it lacks a check to figure if Kodi is already running):
Code:
#turning HDMI on - will bring the Monitor/TV on
/opt/vc/bin/vcgencmd display_power 1
#starting Kodi
/usr/bin/kodi
#turning HDMI off - will bring the Monitor/TV down
/opt/vc/bin/vcgencmd display_power 0
Now, Kodi 18.8 has some new, enhanced, PowerManagement code and I'm failing to hack it, that's override the checks for identifying if the user with which kodi was launched has shutdown permissions and set the validation on true by default and get the ShutDown Timer menu option displayed (active).
This is what I tried so far and failed - I only get the Exit menu option.
Original file:
https://github.com/xbmc/xbmc/blob/Leia/x...anager.cpp
My hacking attempt - diff -u PowerManager-orig.cpp PowerManager.cpp
cpp:
--- PowerManager-orig.cpp 2020-09-24 21:35:46.725570076 +0300
+++ PowerManager.cpp 2020-09-24 21:37:30.495570037 +0300
@@ -52,14 +52,15 @@
void CPowerManager::SetDefaults()
{
- int defaultShutdown = m_settings->GetInt(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE);
+ int defaultShutdown = POWERSTATE_SHUTDOWN;
switch (defaultShutdown)
{
case POWERSTATE_QUIT:
case POWERSTATE_MINIMIZE:
// assume we can shutdown if --standalone is passed
- if (g_application.IsStandAlone())
+// comment this to enable shutdown menu
+// if (g_application.IsStandAlone())
defaultShutdown = POWERSTATE_SHUTDOWN;
break;
case POWERSTATE_HIBERNATE:
@@ -81,13 +82,16 @@
}
break;
case POWERSTATE_SHUTDOWN:
- if (!CServiceBroker::GetPowerManager().CanPowerdown())
- {
- if (CServiceBroker::GetPowerManager().CanSuspend())
- defaultShutdown = POWERSTATE_SUSPEND;
- else
- defaultShutdown = CServiceBroker::GetPowerManager().CanHibernate() ? POWERSTATE_HIBERNATE : POWERSTATE_QUIT;
- }
+// add this to enable shutdown menu
+ defaultShutdown = POWERSTATE_SHUTDOWN;
+// comment this to enable shutdown menu
+// if (!CServiceBroker::GetPowerManager().CanPowerdown())
+// {
+// if (CServiceBroker::GetPowerManager().CanSuspend())
+// defaultShutdown = POWERSTATE_SUSPEND;
+// else
+// defaultShutdown = CServiceBroker::GetPowerManager().CanHibernate() ? POWERSTATE_HIBERNATE : POWERSTATE_QUIT;
+// }
break;
}
@@ -96,7 +100,12 @@
bool CPowerManager:owerdown()
{
- if (CanPowerdown() && m_instance->Powerdown())
+// comment this to enable shutdown menu
+// if (CanPowerdown() && m_instance->Powerdown())
+// add :
+ bool blabla = true;
+ if (blabla)
+// done add
{
CGUIDialogBusy* dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogBusy>(WINDOW_DIALOG_BUSY);
if (dialog)
@@ -118,6 +127,7 @@
return (CanHibernate() && m_instance->Hibernate());
}
+
bool CPowerManager::Reboot()
{
bool success = CanReboot() ? m_instance->Reboot() : false;
@@ -136,7 +146,7 @@
bool CPowerManager::CanPowerdown()
{
- return m_instance ? m_instance->CanPowerdown() : false;
+ return m_instance ? m_instance->CanPowerdown() : true;
}
bool CPowerManager::CanSuspend()
{
I'm not very good in coding, failing to understand the logic in PowerManager.cpp and would be very thankful if some of the Kodi devs could help me with a simple way to override the shutdown validations/checks for the user that launched Kodi and get ShutDown Timer menu option displayed.
Many thanks in advance!