Simple macro for printing system uptime.

If you have macros or EventGhost Configuration Tree items you wish to share this is the place to do it.

Simple macro for printing system uptime.

Postby kgschlosser » Sat Aug 05, 2017 3:45 am

this macro will print the system up time as well as a formatted time/date for when the computer was booted last to the log but it also sets eg.result to the same text that is printed so another action like the OSD can be used with {eg.result} in the text field.

Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4" Guid="{5EE4F107-2AA3-4802-8DB8-604BD73F8D36}" Time="1501852367.14">
    <Macro Name="Show System Up Time" XML_Guid="{DDC306AD-25DB-4231-AE05-51AA27B63CA8}" Expanded="True">
        <Action Name="Show Up Time" XML_Guid="{9DAC812D-9A06-4DA5-8D8E-092028692520}">
            EventGhost.PythonScript(u'import time\n\ndef suffix(d):\n    return \n\ndef custom_strftime(format, t):\n    return \n\nt = time.localtime(eg.plugins.System.GetBootTimestamp(True))\nday = time.strftime(\'%d\', t)\nday += \'th\' if 11&lt;=int(day)&lt;=13 else {1:\'st\',2:\'nd\',3:\'rd\'}.get(int(day)%10, \'th\')\n\nm, s = divmod(eg.plugins.System.GetUpTime(True), 60)\nh, m = divmod(m, 60)\nd, h = divmod(h, 24)\n\nlast_reboot = "Last Reboot - " + time.strftime(\'%H:%M:%S on %A %B {0} %Y\'.format(day), t)\nuptime = "Uptime - %d Days, %d Hours, %02d Minutes, %02d Seconds" % (d, h, m, s)\n\neg.result = last_reboot + \'\\n\' + uptime\nprint eg.result')
        </Action>
    </Macro>
</EventGhost>
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
 
Posts: 2699
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Return to Sharing Macros/Configuration Trees

Who is online

Users browsing this forum: No registered users and 1 guest