#!/usr/bin/perl -w my $no_file = 'Could not open file:'; my $t0_trip_points = '/proc/acpi/thermal_zone/TZS0/trip_points'; my $hot1 = 0; if (open TEMP,'<',$t0_trip_points) { while () { /^([^:]*) *:\s*(\d*)\s*C.*/; $hot1 = $2 if ($1 eq "critical (S5)"); } close TEMP; } else { warn "$0: $no_file $t0_trip_points\n"; } my $t1_trip_points = '/proc/acpi/thermal_zone/TZS1/trip_points'; my $hot2 = 0; if (open TEMP,'<',$t1_trip_points) { while () { /^([^:]*) *:\s*(\d*)\s*C.*/; $hot2 = $2 if ($1 eq "critical (S5)"); } close TEMP; } else { warn "$0: $no_file $t1_trip_points\n"; } my $batt = '/proc/acpi/battery/BAT0/info'; my $full = 0; if (open BAT,'<',$batt) { while () { /^([^:]*) *:\s*(\d*)/; $full = $2 if ($1 eq "design capacity"); } close BAT; } else { warn "$0: $no_file $batt\n"; } my $temp1=0; my $temp2=0; my $remain=0; my $charge='n/a'; my $percent=0; my $cpu=''; while (1) { die unless open TEMP,'<','/proc/acpi/thermal_zone/TZS0/temperature'; while () { /^([^:]*) *:\s*(\d*)\s*C.*/; $temp1 = $2 if ($1 eq "temperature"); } close TEMP; die unless open TEMP,'<','/proc/acpi/thermal_zone/TZS1/temperature'; while () { /^([^:]*) *:\s*(\d*)\s*C.*/; $temp2 = $2 if ($1 eq "temperature"); } close TEMP; die "No Battery? $!" unless open BAT,'<','/proc/acpi/battery/BAT0/state'; while () { /^([^:]*) *:\s*([^\s]*)/; $remain = $2 if ($1 eq "remaining capacity"); $charge = $2 if ($1 eq "charging state"); } close BAT; $percent = int ($remain / $full * 100) unless $full==0; $date = `date +'[%a.%V] [%Y-%m-%d] [%H:%M:%S]'`; chomp $date; $cpu_max = `cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq` / 1000; $cpu_cur = `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` / 1000; $cpu = $cpu_cur.'/'.$cpu_max; system "larsremote message \"[$cpu] [$remain/$full]". " [".$percent."%] [$charge] [$temp2/$hot2] [$temp1/$hot1] $date\""; sleep 1; } # vim:ts=2: