]> git.sur5r.net Git - i3/i3status/blob - testcases/022-cpu-usage-tenth-cpu/setup.pl
Fix for issue 300: Correctly print usage for cpu 10
[i3/i3status] / testcases / 022-cpu-usage-tenth-cpu / 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 for (my $i = 0; $i < $cpu_count; $i++) {
17     print $fh "cpu$i 0 0 0 0 0 0 0 0 0 0\n";
18 }
19 close $fh;