diff --git a/src/bin/screenmode/Jamfile b/src/bin/screenmode/Jamfile index 1f6da18ccb..69d2e049ef 100644 --- a/src/bin/screenmode/Jamfile +++ b/src/bin/screenmode/Jamfile @@ -16,4 +16,5 @@ BinCommand screenmode : ScreenMode.cpp : be [ TargetLibsupc++ ] libaccelerantscommon.a + : screenmode.rdef ; diff --git a/src/bin/screenmode/screenmode.cpp b/src/bin/screenmode/screenmode.cpp index a1585fc7e9..02683b35f3 100644 --- a/src/bin/screenmode/screenmode.cpp +++ b/src/bin/screenmode/screenmode.cpp @@ -25,6 +25,7 @@ static struct option const kLongOptions[] = { {"short", no_argument, 0, 's'}, {"list", no_argument, 0, 'l'}, {"help", no_argument, 0, 'h'}, + {"brightness", required_argument, 0, 'b'}, {NULL} }; @@ -96,6 +97,8 @@ usage(int status) "\t\t\tprinted in short form.\n" " -l --list\t\tdisplay a list of the available modes.\n" " -q --dont-confirm\tdo not confirm the mode after setting it.\n" + " -b --brightness f\tset brightness (range 0 to 1).\n" + " -b --brightness +/-f\tchange brightness by given amount.\n" " -m --modeline\taccept and print X-style modeline modes:\n" "\t\t\t \n" "\t\t\t [flags] " @@ -120,13 +123,15 @@ main(int argc, char** argv) int height = -1; int depth = -1; float refresh = -1; + float brightness = std::nanf("0"); + bool relativeBrightness = false; display_mode mode; // TODO: add a possibility to set a virtual screen size in addition to // the display resolution! int c; - while ((c = getopt_long(argc, argv, "shlfqm", kLongOptions, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "shlfqmb:", kLongOptions, NULL)) != -1) { switch (c) { case 0: break; @@ -147,6 +152,12 @@ main(int argc, char** argv) case 'q': confirm = false; break; + case 'b': + if (optarg[0] == '+' || optarg[0] == '-') + relativeBrightness = true; + brightness = atof(optarg); + printf("b %f rel %d\n", brightness, relativeBrightness); + break; case 'h': usage(0); break; @@ -234,6 +245,25 @@ main(int argc, char** argv) screen_mode currentMode; screenMode.Get(currentMode); + if (!isnan(brightness)) { + BScreen screen; + if (relativeBrightness) { + float previousBrightness; + screen.GetBrightness(&previousBrightness); + brightness = previousBrightness + brightness; + printf("new %f\n", brightness); + + // Clamp to min/max values + if (brightness < 0.f) + brightness = 0.f; + + if (brightness > 1.f) + brightness = 1.f; + printf("clamp %f\n", brightness); + } + screen.SetBrightness(brightness); + } + if (listModes) { // List all reported modes if (!shortOutput) diff --git a/src/bin/screenmode/screenmode.rdef b/src/bin/screenmode/screenmode.rdef new file mode 100644 index 0000000000..023ec6ba57 --- /dev/null +++ b/src/bin/screenmode/screenmode.rdef @@ -0,0 +1,3 @@ +resource app_signature "application/x-vnd.haiku.screenmode"; + +resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP;