{"id":5227,"date":"2018-04-01T10:09:42","date_gmt":"2018-04-01T10:09:42","guid":{"rendered":"https:\/\/really.zonky.org\/?p=5227"},"modified":"2018-04-01T10:09:42","modified_gmt":"2018-04-01T10:09:42","slug":"an-awesome-window-manager-ecc-widget","status":"publish","type":"post","link":"https:\/\/really.zonky.org\/?p=5227","title":{"rendered":"An Awesome Window Manager ECC Widget"},"content":{"rendered":"<p>This is a continuation of an earlier <a href=\"https:\/\/really.zonky.org\/?p=3391\">post<\/a> regarding ECC memory under Linux, and is how I added a little widget to display the current ECC memory status. Because I don&#8217;t really know lua, most of the work is carried out with a shell script that is run via\u00a0<em>cron<\/em> on a frequent basis.<\/p>\n<p>The shell script simply runs\u00a0<em>edac-util<\/em> to obtain the number of correctable errors and uncorrectable errors, and formats the numbers in a way suitable for setting the text of a widget :-<\/p>\n<pre>#!\/bin\/zsh\r\n#\r\n# Use edac-util to report some numbers to display ...\r\n\r\ncorrectables=$(edac-util --report=ce | awk '{print $NF}')\r\nuncorrectables=$(edac-util --report=ue | awk '{print $NF}')\r\n\r\nc=\"chartreuse\"\r\nif [[ \"$correctables\" != \"0\" ]]\r\nthen \r\n  c=\"orange\"\r\nfi\r\nif [[ \"$uncorrectables\" != \"0\" ]]\r\nthen\r\n  c=\"red\"\r\nfi\r\n\r\necho \"ECC: $correctables\/$uncorrectables \"\r\n<\/pre>\n<p>This is run with a <em>crontab<\/em> entry :-<\/p>\n<pre>*\/7 * * * * \/site\/scripts\/gen-ecc-wtext &gt; \/home\/mike\/lib\/awesome\/widget-texts\/ecc-status\r\n<\/pre>\n<p>Once the file is being generated, the Awesome configuration can take effect :-<\/p>\n<pre>-- The following function does what it says and is used in a number of dumb widgets\r\n-- to gather strings from shell scripts\r\nfunction readfiletostring (filename)\r\n  file = io.open(filename, \"r\")\r\n  io.input(file)\r\n  s = io.read()\r\n  io.close(file)\r\n  return s\r\nend\r\n\r\neccstatus = wibox.widget.textbox()\r\neccstatus:set_markup(readfiletostring(homedir .. \"\/lib\/awesome\/widget-texts\/ecc-status\"))\r\neccstatustimer = timer({ timeout = 60 })\r\neccstatustimer:connect_signal(\"timeout\",\r\n  function()\r\n      eccstatus:set_markup(readfiletostring(homedir .. \"\/lib\/awesome\/widget-texts\/ecc-status\"))\r\n  end\r\n)\r\neccstatustimer:start()\r\n...\r\nlayout = wibox.layout.fixed.horizontal, ... eccstatus, ...\r\n<\/pre>\n<p>There plenty of ways this could be improved &#8211; there&#8217;s nothing really that requires a separate shell script, but this\u00a0<em>works<\/em> which is good enough for now.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3904\" src=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?resize=695%2C463&#038;ssl=1\" alt=\"\" width=\"695\" height=\"463\" srcset=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?w=792&amp;ssl=1 792w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a continuation of an earlier post regarding ECC memory under Linux, and is how I added a little widget to display the current ECC memory status. Because I don&#8217;t really know lua, most of the work is carried out with a shell script that is run via\u00a0cron on a frequent basis. The shell <a href='https:\/\/really.zonky.org\/?p=5227' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_share_on_mastodon":"0"},"categories":[4,209],"tags":[1048,1167,725],"class_list":["post-5227","post","type-post","status-publish","format-standard","hentry","category-it","category-linux-it","tag-awesome","tag-ecc","tag-window-manager","category-4-id","category-209-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1f2KI-1mj","_links":{"self":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5227"}],"version-history":[{"count":2,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5227\/revisions"}],"predecessor-version":[{"id":5229,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5227\/revisions\/5229"}],"wp:attachment":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}