#!/usr/bin/perl

use strict;
use warnings FATAL => 'all';

my $value = `cat /sys/class/backlight/apple-panel-bl/brightness`;
chomp($value);

if ($ARGV[0] eq 'up') {
        $value += 42;
} else {
        $value -= 42;
}

if ($value < 0) {
        $value = 0;
}

if (420 < $value) {
        $value = 420;
}

system("echo $value > /sys/class/backlight/apple-panel-bl/brightness");
