]> git.sur5r.net Git - i3/i3status/blob - testcases/011-cpu-usage/setup.pl
Detect interface type on DragonFly BSD
[i3/i3status] / testcases / 011-cpu-usage / setup.pl
1 #!/usr/bin/env perl
2
3 use v5.10;
4 use strict;
5 use warnings;
6
7 if ($#ARGV != 0 || ! -d $ARGV[0]) {
8     say "Error with setup script: argument not provided or not a directory";
9     exit 1;
10 }
11
12 chomp(my $cpu_count = `grep -c -P '^processor\\s+:' /proc/cpuinfo`);
13 my $output_file = "$ARGV[0]/stat";
14 open(my $fh, '>', $output_file) or die "Could not open file '$output_file' $!";
15 print $fh "cpu  0 0 0 0 0 0 0 0 0 0\n";
16 print $fh "cpu0 0 0 0 300 0 0 0 0 0 0\n";
17 if ($cpu_count > 1) {
18     print $fh "cpu1 100 100 100 0 0 0 0 0 0 0\n";
19 }
20 for (my $i = 2; $i <= $cpu_count; $i++) {
21     print $fh "cpu$i 0 0 0 0 0 0 0 0 0 0\n";
22 }
23 close $fh;