Skip to content

Commit

Permalink
loginctl: also show idle hint in session-status
Browse files Browse the repository at this point in the history
(cherry picked from commit 82449055af97cf92466dbe132a89c9d889440c3d)

Related: #2156786
  • Loading branch information
YHNdnzj authored and systemd-rhel-bot committed Jul 13, 2023
1 parent ea3d852 commit 0d3f481
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/login/loginctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
{ "Remote", "b", NULL, offsetof(SessionStatusInfo, remote) },
{ "Timestamp", "t", NULL, offsetof(SessionStatusInfo, timestamp.realtime) },
{ "TimestampMonotonic", "t", NULL, offsetof(SessionStatusInfo, timestamp.monotonic) },
{ "IdleHint", "b", NULL, offsetof(SessionStatusInfo, idle_hint) },
{ "IdleSinceHint", "t", NULL, offsetof(SessionStatusInfo, idle_hint_timestamp) },
{ "User", "(uo)", prop_map_first_of_struct, offsetof(SessionStatusInfo, uid) },
{ "Seat", "(so)", prop_map_first_of_struct, offsetof(SessionStatusInfo, seat) },
{}
Expand Down Expand Up @@ -571,6 +573,14 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
if (i.state)
printf("\t State: %s\n", i.state);

if (i.idle_hint && i.idle_hint_timestamp > 0) {
s1 = format_timestamp_relative(since1, sizeof(since1), i.idle_hint_timestamp);
s2 = format_timestamp(since2, sizeof(since2), i.idle_hint_timestamp);

printf("\t Idle: %s since %s (%s)\n", yes_no(i.idle_hint), s2, s1);
} else
printf("\t Idle: %s\n", yes_no(i.idle_hint));

if (i.scope) {
printf("\t Unit: %s\n", i.scope);
show_unit_cgroup(bus, "org.freedesktop.systemd1.Scope", i.scope, i.leader);
Expand Down

0 comments on commit 0d3f481

Please sign in to comment.