Browse files

added usage examples, cleaned up some code that was for setuid

  • Loading branch information...
1 parent 14bd10b commit b87b9a9815a3bf77eb845c9359e93c59e532a5a6 @teleshoes committed Jan 8, 2012
Showing with 15 additions and 8 deletions.
  1. +15 −8 led-controls/led
View
23 led-controls/led
@@ -14,11 +14,20 @@ s/^tpacpi(::|:)//g foreach @validLeds;
chomp foreach @validLeds;
@validLeds = sort @validLeds;
my $usage = ''
- . "Usage: $0 <led> [<on|off|toggle> | brightness]\n"
- . " LED name must be [a-zA-Z0-9:_-]+\n"
- . " {only letters, numbers, colons, underscores or hyphens}\n"
- . " tpacpi: is automatically prepended if it is not present\n"
- . " available LEDs: @validLeds\n"
+ . "Usage: $0 <led-name> [<on|off|toggle> | brightness-integer]\n"
+ . " led-name must be [a-zA-Z0-9:_-]+\n"
+ . " {only letters, numbers, colons, underscores or hyphens}\n"
+ . " LED devices are in $LED_DIR/<led-name>/brightness\n"
+ . " the prefix 'tpacpi:' is removed from name if present, and either-\n"
+ . " 1) tpacpi:: is prepended if name does NOT have a colon in it\n"
+ . " 2) tpacpi: is prepended if name DOES have a colon in it\n"
+ . " e.g.:\n"
+ . " 'tpacpi:green:batt' => 'tpacpi:green:batt'\n"
+ . " 'green:batt' => 'tpacpi:green:batt'\n"
+ . " 'mute_mic' => 'tpacpi::mute_mic'\n"
+ . " 'tpacpi:mute_mic' => 'tpacpi::mute_mic'\n"
+ . " 'tpacpi::mute_mic' => 'tpacpi::mute_mic'\n"
+ . " available LEDs: @validLeds\n"
;
my $name = shift;
@@ -34,12 +43,10 @@ if($name !~ /^([a-zA-Z0-9:_-]+)$/){
}
$name = $1; #untaint
-my $brightness = shift;
-$brightness = 'toggle' if not defined $brightness;
+my $brightness = shift() || 'toggle';
if(@ARGV > 0 or $brightness !~ /^(on|off|toggle|\d+)$/i){
die $usage;
}
-$brightness = $1; #untaint
my $dev = "$LED_DIR/$name/brightness";

0 comments on commit b87b9a9

Please sign in to comment.