Skip to content

Commit b23728e

Browse files
Add simple usage message to systemd-backlight (systemd#16709)
1 parent 677bb05 commit b23728e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

man/systemd-backlight@.service.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
<refsynopsisdiv>
2525
<para><filename>systemd-backlight@.service</filename></para>
26-
<para><filename>/usr/lib/systemd/systemd-backlight</filename></para>
26+
<para><filename>/usr/lib/systemd/systemd-backlight</filename> save [backlight|leds]:DEVICE</para>
27+
<para><filename>/usr/lib/systemd/systemd-backlight</filename> load [backlight|leds]:DEVICE</para>
2728
</refsynopsisdiv>
2829

2930
<refsect1>

src/backlight/backlight.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,36 @@
1313
#include "main-func.h"
1414
#include "mkdir.h"
1515
#include "parse-util.h"
16+
#include "pretty-print.h"
17+
#include "terminal-util.h"
1618
#include "reboot-util.h"
1719
#include "string-util.h"
1820
#include "strv.h"
1921
#include "util.h"
2022

23+
static int help(void) {
24+
_cleanup_free_ char *link = NULL;
25+
int r;
26+
27+
r = terminal_urlify_man("systemd-backlight", "8", &link);
28+
if (r < 0)
29+
return log_oom();
30+
31+
printf("%s save [backlight|leds]:DEVICE\n"
32+
"%s load [backlight|leds]:DEVICE\n"
33+
"\n%sSave and restore backlight brightness at shutdown and boot.%s\n\n"
34+
" save Save current brightness\n"
35+
" load Set brightness to be the previously saved value\n"
36+
"\nSee the %s for details.\n"
37+
, program_invocation_short_name
38+
, program_invocation_short_name
39+
, ansi_highlight(), ansi_normal()
40+
, link
41+
);
42+
43+
return 0;
44+
}
45+
2146
static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) {
2247
const char *subsystem, *sysname, *value;
2348
sd_device *parent;
@@ -334,6 +359,9 @@ static int run(int argc, char *argv[]) {
334359

335360
log_setup_service();
336361

362+
if (strv_contains(strv_skip(argv, 1), "--help"))
363+
return help();
364+
337365
if (argc != 3)
338366
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program requires two arguments.");
339367

0 commit comments

Comments
 (0)