aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2022-11-17 10:56:25 -0800
committerclarkzjw <[email protected]>2022-11-17 10:56:25 -0800
commitd2d735742ca61b211c9b48a2209d36395daebcf4 (patch)
treebda27729a1bbac3ab354a1f10d4885899cdbf967 /dot_config/i3/scripts/executable_temperature
parenta6d2e5e6fb9adc84c32e86630b4846b1765c7d77 (diff)
downloaddotfiles-d2d735742ca61b211c9b48a2209d36395daebcf4.tar.gz
+ add existing config
Diffstat (limited to 'dot_config/i3/scripts/executable_temperature')
-rw-r--r--dot_config/i3/scripts/executable_temperature86
1 files changed, 86 insertions, 0 deletions
diff --git a/dot_config/i3/scripts/executable_temperature b/dot_config/i3/scripts/executable_temperature
new file mode 100644
index 0000000..4e31610
--- /dev/null
+++ b/dot_config/i3/scripts/executable_temperature
@@ -0,0 +1,86 @@
1#!/usr/bin/env perl
2# Copyright 2014 Pierre Mavro <[email protected]>
3# Copyright 2014 Vivien Didelot <[email protected]>
4# Copyright 2014 Andreas Guldstrand <[email protected]>
5# Copyright 2014 Benjamin Chretien <chretien at lirmm dot fr>
6
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20# Edited by Andreas Lindlbauer <[email protected]>
21
22use strict;
23use warnings;
24use utf8;
25use Getopt::Long;
26
27binmode(STDOUT, ":utf8");
28
29# default values
30my $t_warn = $ENV{T_WARN} || 70;
31my $t_crit = $ENV{T_CRIT} || 90;
32my $chip = $ENV{SENSOR_CHIP} || "";
33my $temperature = -9999;
34my $label = "😀 ";
35
36sub help {
37 print "Usage: temperature [-w <warning>] [-c <critical>] [--chip <chip>]\n";
38 print "-w <percent>: warning threshold to become yellow\n";
39 print "-c <percent>: critical threshold to become red\n";
40 print "--chip <chip>: sensor chip\n";
41 exit 0;
42}
43
44GetOptions("help|h" => \&help,
45 "w=i" => \$t_warn,
46 "c=i" => \$t_crit,
47 "chip=s" => \$chip);
48
49# Get chip temperature
50open (SENSORS, "sensors -u $chip |") or die;
51while (<SENSORS>) {
52 if (/^\s+temp1_input:\s+[\+]*([\-]*\d+\.\d)/) {
53 $temperature = $1;
54 last;
55 }
56}
57close(SENSORS);
58
59$temperature eq -9999 and die 'Cannot find temperature';
60
61if ($temperature < 45) {
62 $label = 'ï‹‹';
63} elsif ($temperature < 55) {
64 $label = 'ï‹Š';
65} elsif ($temperature < 65) {
66 $label = '';
67} elsif ($temperature < 75) {
68 $label = '';
69} else {
70 $label = '';
71}
72# Print short_text, full_text
73print "${label}";
74print " $temperature°C\n";
75print "${label}";
76print " $temperature°C\n";
77
78# Print color, if needed
79if ($temperature >= $t_crit) {
80 print "#FF0000\n";
81 exit 33;
82} elsif ($temperature >= $t_warn) {
83 print "#FFFC00\n";
84}
85
86exit 0;
Powered by cgit v1.2.3 (git 2.41.0)