diff options
author | David Tardon <dtardon@redhat.com> | 2018-05-17 15:45:37 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | 8094890c09f56ae20d4b6923e9fce29c28d66aea (patch) | |
tree | d1a47cfa2b5930fce48fceeac44d34eb87160176 /src/login | |
parent | 018c562eab6d0d431c1675af6740baaa915611c3 (diff) |
inhibit: use pager for systemd-inhibit --list
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/inhibit.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/login/inhibit.c b/src/login/inhibit.c index f3a209bfb..aabfdbde4 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -18,6 +18,7 @@ #include "bus-util.h" #include "fd-util.h" #include "format-util.h" +//#include "pager.h" #include "process-util.h" #include "signal-util.h" #include "strv.h" @@ -31,6 +32,7 @@ static const char* arg_what = "idle:sleep:shutdown"; static const char* arg_who = NULL; static const char* arg_why = "Unknown reason"; static const char* arg_mode = NULL; +static bool arg_no_pager = false; static enum { ACTION_INHIBIT, @@ -72,6 +74,8 @@ static int print_inhibitors(sd_bus *bus, sd_bus_error *error) { unsigned n = 0; int r; + (void) pager_open(arg_no_pager, false); + r = sd_bus_call_method( bus, "org.freedesktop.login1", @@ -124,6 +128,7 @@ static void help(void) { "Execute a process while inhibiting shutdown/sleep/idle.\n\n" " -h --help Show this help\n" " --version Show package version\n" + " --no-pager Do not pipe output into a pager\n" " --what=WHAT Operations to inhibit, colon separated list of:\n" " shutdown, sleep, idle, handle-power-key,\n" " handle-suspend-key, handle-hibernate-key,\n" @@ -144,6 +149,7 @@ static int parse_argv(int argc, char *argv[]) { ARG_WHY, ARG_MODE, ARG_LIST, + ARG_NO_PAGER, }; static const struct option options[] = { @@ -154,6 +160,7 @@ static int parse_argv(int argc, char *argv[]) { { "why", required_argument, NULL, ARG_WHY }, { "mode", required_argument, NULL, ARG_MODE }, { "list", no_argument, NULL, ARG_LIST }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, {} }; @@ -193,6 +200,10 @@ static int parse_argv(int argc, char *argv[]) { arg_action = ACTION_LIST; break; + case ARG_NO_PAGER: + arg_no_pager = true; + break; + case '?': return -EINVAL; @@ -235,6 +246,7 @@ int main(int argc, char *argv[]) { if (arg_action == ACTION_LIST) { r = print_inhibitors(bus, &error); + pager_close(); if (r < 0) { log_error("Failed to list inhibitors: %s", bus_error_message(&error, -r)); return EXIT_FAILURE; |