#!/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 $full = `cat /sys/class/power_supply/BAT0/charge_full_design` / 1000; 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; $remain = `cat /sys/class/power_supply/BAT0/charge_now` / 1000; $charge = `cat /sys/class/power_supply/BAT0/status`; chomp $charge; $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: