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.
Post Reply
User avatar
Site Admin
Posts: 4873
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Simple macro for printing system uptime.

Post by 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<=int(day)<=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')
If you like the work I have been doing then feel free to Image

Post Reply