3 # Copyright (C) 2011-2012 Simon Ruderich
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 my $temperature_path = '/sys/devices/virtual/hwmon/hwmon0/temp1_input';
24 my $critical_path = '/sys/devices/virtual/hwmon/hwmon0/temp1_crit';
26 # No temperature information available.
27 if (! -e $temperature_path || ! -e $critical_path) {
31 my $screen_mode = (defined $ARGV[0] and $ARGV[0] eq '-s');
32 my $tmux_mode = (defined $ARGV[0] and $ARGV[0] eq '-t');
38 open $file, '<', $temperature_path or die $!;
39 $temperature = <$file>;
41 open $file, '<', $critical_path or die $!;
45 my $value = int($temperature / 1000);
46 my $risk = ($critical - $temperature)/$critical;
48 # GNU screen mode with colors.
52 $color = 'br r'; # bold reverse
53 } elsif ($risk < 0.1) {
55 } elsif ($risk < 0.2) {
61 print "\005{+$color}$value\005{-}\n";
64 } elsif ($tmux_mode) {
69 $style = 'reverse'; # blink doesn't work for me
70 } elsif ($risk < 0.1) {
72 } elsif ($risk < 0.2) {
78 print "#[fg=$color,$style]$value#[default]\n";