From c6384b556c76a6a8e13ee4562664230fe1a3c3a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Mon, 25 Nov 2019 23:48:52 +0100 Subject: [PATCH] Let brightness command handle delta changes --- src/kaka/cakelight/Commands.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kaka/cakelight/Commands.java b/src/kaka/cakelight/Commands.java index 75b1b10..048e6c6 100644 --- a/src/kaka/cakelight/Commands.java +++ b/src/kaka/cakelight/Commands.java @@ -64,7 +64,12 @@ class Commands { static Console.Command brightness() { return command(new String[] {"b", "brightness"}, (console, args) -> { if (args.length == 1) { - int b = Integer.parseInt(args[0]); + int b = Integer.parseInt(args[0].replaceAll("\\+-", "")); + if (args[0].startsWith("+")) { + b = Math.min(console.getConfig().leds.brightness + b, 31); + } else if (args[0].startsWith("-")) { + b = Math.max(console.getConfig().leds.brightness - b, 0); + } console.getConfig().leds.brightness = b; console.out("setting brightness to " + b); return true; -- 2.11.0