summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2018-05-17 15:45:37 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-05-18 08:33:45 +0200
commitf3c9133c5077f0010672723ce83401337f668627 (patch)
tree6e7b0f1c1114792fbf65cce79a805a0d31a59db2 /src/login
parenta78388e1cbb3067485d9f97954fa86aba94711b4 (diff)
downloadsystemd-f3c9133c5077f0010672723ce83401337f668627.tar.gz
inhibit: use pager for systemd-inhibit --list
Diffstat (limited to 'src/login')
-rw-r--r--src/login/inhibit.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/login/inhibit.c b/src/login/inhibit.c
index 5fa3e8d960..75f5e4d30e 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"
@@ -28,6 +29,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,
@@ -69,6 +71,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",
@@ -121,6 +125,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"
@@ -141,6 +146,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_WHY,
ARG_MODE,
ARG_LIST,
+ ARG_NO_PAGER,
};
static const struct option options[] = {
@@ -151,6 +157,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 },
{}
};
@@ -190,6 +197,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;
@@ -231,6 +242,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;