Skip to content

Commit

Permalink
Add thermal module
Browse files Browse the repository at this point in the history
  • Loading branch information
noccy80 committed Dec 16, 2016
1 parent cc22e22 commit dc80e7e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,11 @@ By default, escape sequences will be enclosed within a block of `\[ .. \]`, but
can be disabled by passing `-r`. You can also specify the working directory with `-d`
and exit code of last process with `-s`.

## ToDo/Known Issues

Things that need improving:

* The theme parser shouldn't be line-oriented nor care about whitespace.
* Icons should be customizable, maybe as icon packs.
* Better handling of 256-color and 24b-color stuff. Pragmas are in place but not active.
* Need to strip UTF-8 when outputting to a physical console as most icons fail there.
3 changes: 1 addition & 2 deletions bin/phpl-config
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ $opts = cmdl_parse("hvi:d:e:a:b:s:t:n:lLE",[
"s" => "set:",
"n" => "name:",
"N" => "no-reload",
"class:",
"l" => "list",
"L" => "list-modules",
"theme:"
Expand All @@ -51,7 +50,7 @@ if (cmdl_get($opts,'help')) {
exit(0);
}

define("VERBOSE", (int)cmdl_get($opts,'verbose'));
// define("VERBOSE", (int)cmdl_get($opts,'verbose'));
define("RELOAD", !cmdl_get($opts,'no-reload'));
define("QUIET", false);

Expand Down
19 changes: 19 additions & 0 deletions modules/thermal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

define("THERMAL_FORMAT", "format");
define("THERMAL_CLASS", "class");
define("THERMAL_ZONE", "zone");

function _thermal(array $opts) {
$attr = [];
$zone = $opts[THERMAL_ZONE];
$temp = (int)@trim(file_get_contents("/sys/class/thermal/{$zone}/temp"));
$temp = (float)$temp/1000;
$text = sprintf("🌡 ".$opts[THERMAL_FORMAT], $temp);
$attr['class'] = $opts[THERMAL_CLASS];
return panel($text, $attr, 'thermal');
}
module("thermal", "Show thermal zone info");
option("zone", THERMAL_ZONE, OPT_TYPE_STRING, "Thermal zone (from /sys/class/thermal)", "thermal_zone0");
option("format", THERMAL_FORMAT, OPT_TYPE_STRING, "Format", "%.1fºc");
option("class", THERMAL_CLASS, OPT_TYPE_STRING, "The class to use", "system");

0 comments on commit dc80e7e

Please sign in to comment.