{"id":186,"date":"2009-02-15T12:29:19","date_gmt":"2009-02-15T19:29:19","guid":{"rendered":"http:\/\/www.threshold-zero.com\/cblog\/?p=186"},"modified":"2020-09-07T18:22:17","modified_gmt":"2020-09-07T23:22:17","slug":"conky-dell-i8k-modules-and-my-first-ubuntu-bash-script","status":"publish","type":"post","link":"https:\/\/www.threshold-zero.com\/cblog\/2009\/02\/conky-dell-i8k-modules-and-my-first-ubuntu-bash-script\/","title":{"rendered":"Conky, Dell i8k Modules, and My First Ubuntu Bash Script"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-188 alignleft\" title=\"Conky Screenshot\" src=\"http:\/\/www.threshold-zero.com\/cblog\/wp-content\/uploads\/2009\/02\/screenshot.png\" alt=\"Conky Screenshot\" width=\"215\" height=\"139\" \/><\/p>\n<p>Well, I started playing around with <a href=\"http:\/\/lifehacker.com\/5152819\/to+dos-weather-and-twitter-on-a-linux-desktop\">Conky<\/a> yesterday &#8212; if you haven&#8217;t heard of it before, just know that it&#8217;s a neat little Linux program that runs in your background and uses very little resources that displays a very neat desktop overlay.\u00c2\u00a0 (Like in the picture in the Lifehacker article.)<\/p>\n<p>Now, some of the stock Conky scripts were more than adequate, but I had always wanted my laptop&#8217;s CPU temperature to be displayed as well, so I had to figure out a way to do that.<\/p>\n<p>Now, if you&#8217;re somewhat familiar with tinkering in Linux, you&#8217;ve probably heard of the wonderful &#8220;lm_sensors&#8221; package &#8212; it&#8217;s a neat package for Linux that helps display lots of information about motherboard temps and whatnot.\u00c2\u00a0 Unfortunately, due to most laptops &#8220;prorietary-ness,&#8221; lm_sensors does very little for you if you&#8217;re trying to get it to work on a laptop.<\/p>\n<p>Now, I had heard of the &#8220;i8kutils&#8221; package for Linux &#8212; this was a package designed for Dell laptops in particular, to display and control fan and temperature information.<\/p>\n<p>So, with that, I was off to work!<\/p>\n<p>(Note &#8212; these instructions are mostly for Ubuntu\/Debian installations, because that&#8217;s what I use.)<\/p>\n<p>First, install the package &#8220;i8kutils&#8221; using your Linux computer&#8217;s package manager (Synaptic, if you&#8217;re using Ubuntu).<\/p>\n<p>Second, add the module &#8220;i8k&#8221; to your &#8220;\/etc\/modules&#8221; file.\u00c2\u00a0 (This will start the process at boottime.)\u00c2\u00a0 Restart your laptop.<\/p>\n<p>Third, you&#8217;ll have to create some Conky script files.\u00c2\u00a0 I assume you&#8217;ve already had a bit of experience at least installing Conky and starting it up.\u00c2\u00a0 If not, play around with the instructions in that Lifehacker article and come back here afterwards.<\/p>\n<p>Now, I noticed that one of my conky script files was a file called &#8220;hddmonit.sh&#8221; which contained the text:<\/p>\n<blockquote><p>#!\/bin\/bash<br \/>\necho &#8220;$(nc localhost 7634 | cut -d&#8217;|&#8217; -f4)&#8221;<\/p><\/blockquote>\n<p>Now, using a little bit of deduction, I figured that this file used a command called &#8220;nc localhost 7634&#8221; to display a little bit of information, and then used pipe commands (the little &#8220;|&#8221; symbol) to further splice the info, extracting just the temperature of my laptop&#8217;s hard drive.<\/p>\n<p>So, while &#8220;nc localhost 7634&#8221; outputted this:<\/p>\n<blockquote><p>|\/dev\/sda|ST980815A|43|C|<\/p><\/blockquote>\n<p>Using the command &#8220;(nc localhost 7634 | cut -d&#8217;|&#8217; -f4&#8221; would output just &#8220;43&#8221;, which was the temperature of my hard drive.<\/p>\n<p>(The &#8220;cut&#8221; command splices out specific text from a string it&#8217;s given, in this case the fourth (-f4) chunk of text seperated by a &#8220;|&#8221; chracter.)<\/p>\n<p>Now, I learned that the &#8220;i8k&#8221; module, once loaded, could be accessed with the file at\u00c2\u00a0 &#8220;\/proc\/i8k&#8221;, which just contains a string like:<\/p>\n<blockquote><p>1.0 A32 7GGGGGG 53 -22 1 -22 90300 -1 2<\/p><\/blockquote>\n<p>From this you can see various Dell-specific information, the important part being &#8220;53&#8221;, which was my current processor temp.\u00c2\u00a0 (The items in the string are separated by spaces.)<\/p>\n<p>So, I quickly made myself a new script file called &#8220;i8ktemps.sh&#8221; copying the contents of &#8220;hddmonit.sh&#8221; and changing them to:<\/p>\n<blockquote><p>#!\/bin\/bash<br \/>\necho &#8220;$(head \/proc\/i8k | cut -d&#8217; &#8216; -f4)&#8221;<\/p><\/blockquote>\n<p>This file, when executed, will just output the fourth &#8220;chunk&#8221; in the file &#8220;\/proc\/i8k&#8221;, which as you remember is my current processor temp.<\/p>\n<p>Now, I needed to edit my Conky configuration file, which is located in your home folder and is called &#8220;.conkyrc&#8221;.<\/p>\n<p>Then I simply located the line:<\/p>\n<blockquote><p>${font weather:size=28}x ${font}HDD ${execi 1 ~\/scripts\/hddmonit.sh}C<\/p><\/blockquote>\n<p>Which displayed my hard drive temperature, and changed it to:<\/p>\n<blockquote><p>${font weather:size=28}x ${font}CPU ${execi 1 ~\/scripts\/i8ktemps.sh}C HDD ${execi 1 ~\/scripts\/hddmonit.sh}C<\/p><\/blockquote>\n<p>Which, when Conky was restarted, would display my hard drive temperature <em>and<\/em> my current processor temperature.<\/p>\n<p>See?\u00c2\u00a0 It&#8217;s not that hard to program this stuff!\u00c2\u00a0 I did this all, both programming in the Linux &#8220;Bash&#8221; shell and coding in Conky&#8217;s personal configuration code, without any experience in either.\u00c2\u00a0 I just looked at what was there, and changed it.<\/p>\n<p>Relevant Links:<\/p>\n<p><a href=\"http:\/\/www.arachnoid.com\/linux\/shell_programming.html\">http:\/\/www.arachnoid.com\/linux\/shell_programming.html<\/a><\/p>\n<p><a href=\"http:\/\/ubuntuforums.org\/showthread.php?t=411800\">http:\/\/ubuntuforums.org\/showthread.php?t=411800<\/a><\/p>\n<p><a href=\"http:\/\/www.linuxcommand.org\/wss0010.php\">http:\/\/www.linuxcommand.org\/wss0010.php<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, I started playing around with Conky yesterday &#8212; if you haven&#8217;t heard of it before, just know that it&#8217;s a neat little Linux program that runs in your background and uses very little resources that displays a very neat desktop overlay.\u00c2\u00a0 (Like in the picture in the Lifehacker article.) Now, some of the stock [&hellip;]<\/p>\n","protected":false},"author":4,"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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[11,18,15],"tags":[32,30,34,139,33,140],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-linux","category-programming","category-science-and-technology","tag-bash","tag-conky","tag-i8kutils","tag-linux","tag-shell","tag-ubuntu"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2ZUZG-30","_links":{"self":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":1,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":4686,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/posts\/186\/revisions\/4686"}],"wp:attachment":[{"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.threshold-zero.com\/cblog\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}