diff options
-rw-r--r-- | bash-completion/rtcwake | 2 | ||||
-rw-r--r-- | sys-utils/rtcwake.8.in | 5 | ||||
-rw-r--r-- | sys-utils/rtcwake.c | 18 |
3 files changed, 22 insertions, 3 deletions
diff --git a/bash-completion/rtcwake b/bash-completion/rtcwake index 51566a2a2..23c774c1f 100644 --- a/bash-completion/rtcwake +++ b/bash-completion/rtcwake @@ -12,7 +12,7 @@ _rtcwake_module() return 0 ;; '-m'|'--mode') - COMPREPLY=( $(compgen -W "standby mem disk off no on disable show" -- $cur) ) + COMPREPLY=( $(compgen -W "$(rtcwake --list-modes)" -- $cur) ) return 0 ;; '-s'|'--seconds') diff --git a/sys-utils/rtcwake.8.in b/sys-utils/rtcwake.8.in index be4a88f4d..d8acd0aa1 100644 --- a/sys-utils/rtcwake.8.in +++ b/sys-utils/rtcwake.8.in @@ -16,7 +16,7 @@ .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA .\" 02110-1301, USA. .\" -.TH RTCWAKE 8 "July 2014" "util-linux" "System Administration" +.TH RTCWAKE 8 "June 2015" "util-linux" "System Administration" .SH NAME rtcwake \- enter a system sleep state until specified wakeup time .SH SYNOPSIS @@ -78,6 +78,9 @@ You may specify \fBrtc1\fP, \fBrtc2\fP, ... here. Assume that the hardware clock is set to local time, regardless of the contents of the \fIadjtime\fP file. .TP +.B \-\-list\-modes +List available \-\-mode option arguments. +.TP .BR \-m , " \-\-mode " \fImode Go into the given standby state. Valid values for \fImode\fP are: .RS diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c index 4b9483cc5..1044c86db 100644 --- a/sys-utils/rtcwake.c +++ b/sys-utils/rtcwake.c @@ -117,6 +117,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(_(" -d, --device <device> select rtc device (rtc0|rtc1|...)\n"), out); fputs(_(" -n, --dry-run does everything, but suspend\n"), out); fputs(_(" -l, --local RTC uses local timezone\n"), out); + fputs(_(" --list-modes list available modes\n"), out); fputs(_(" -m, --mode <mode> standby|mem|... sleep mode\n"), out); fputs(_(" -s, --seconds <seconds> seconds to sleep\n"), out); fputs(_(" -t, --time <time_t> time to wake\n"), out); @@ -395,6 +396,15 @@ static int open_dev_rtc(const char *devname) return fd; } +static void list_modes(void) +{ + int i = ARRAY_SIZE(mode_str); + + while (i--) + printf("%s%s", mode_str[i], i == 0 ? "" : " "); + putchar('\n'); +} + int main(int argc, char **argv) { struct rtcwake_control ctl = { @@ -413,7 +423,8 @@ int main(int argc, char **argv) time_t alarm = 0; enum { - OPT_DATE = CHAR_MAX + 1 + OPT_DATE = CHAR_MAX + 1, + OPT_LIST }; static const struct option long_options[] = { @@ -430,6 +441,7 @@ int main(int argc, char **argv) {"seconds", required_argument, 0, 's'}, {"time", required_argument, 0, 't'}, {"date", required_argument, 0, OPT_DATE}, + {"list-modes", no_argument, 0, OPT_LIST}, {0, 0, 0, 0 } }; @@ -458,6 +470,10 @@ int main(int argc, char **argv) ctl.clock_mode = CM_LOCAL; break; + case OPT_LIST: + list_modes(); + return EXIT_SUCCESS; + case 'm': if ((suspend = get_mode(optarg)) < 0) errx(EXIT_FAILURE, _("unrecognized suspend state '%s'"), optarg); |