diff options
-rw-r--r-- | src/libsystemd-terminal/sysview-internal.h | 1 | ||||
-rw-r--r-- | src/libsystemd-terminal/sysview.c | 28 | ||||
-rw-r--r-- | src/libsystemd-terminal/sysview.h | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/libsystemd-terminal/sysview-internal.h b/src/libsystemd-terminal/sysview-internal.h index d9f7fe3301..39ff933eaa 100644 --- a/src/libsystemd-terminal/sysview-internal.h +++ b/src/libsystemd-terminal/sysview-internal.h @@ -88,6 +88,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(sysview_session*, sysview_session_free); struct sysview_seat { sysview_context *context; char *name; + char *path; Hashmap *session_map; Hashmap *device_map; diff --git a/src/libsystemd-terminal/sysview.c b/src/libsystemd-terminal/sysview.c index cd776f62d8..919fadf6fe 100644 --- a/src/libsystemd-terminal/sysview.c +++ b/src/libsystemd-terminal/sysview.c @@ -391,6 +391,10 @@ int sysview_seat_new(sysview_seat **out, sysview_context *c, const char *name) { if (!seat->name) return -ENOMEM; + r = sd_bus_path_encode("/org/freedesktop/login1/seat", seat->name, &seat->path); + if (r < 0) + return r; + seat->session_map = hashmap_new(&string_hash_ops); if (!seat->session_map) return -ENOMEM; @@ -422,6 +426,7 @@ sysview_seat *sysview_seat_free(sysview_seat *seat) { hashmap_free(seat->device_map); hashmap_free(seat->session_map); + free(seat->path); free(seat->name); free(seat); @@ -434,6 +439,29 @@ const char *sysview_seat_get_name(sysview_seat *seat) { return seat->name; } +int sysview_seat_switch_to(sysview_seat *seat, uint32_t nr) { + _cleanup_bus_message_unref_ sd_bus_message *m = NULL; + int r; + + assert_return(seat, -EINVAL); + assert_return(seat->context->sysbus, -EINVAL); + + r = sd_bus_message_new_method_call(seat->context->sysbus, + &m, + "org.freedesktop.login1", + seat->path, + "org.freedesktop.login1.Seat", + "SwitchTo"); + if (r < 0) + return r; + + r = sd_bus_message_append(m, "u", nr); + if (r < 0) + return r; + + return sd_bus_send(seat->context->sysbus, m, NULL); +} + /* * Contexts */ diff --git a/src/libsystemd-terminal/sysview.h b/src/libsystemd-terminal/sysview.h index f691e492d5..31b800f698 100644 --- a/src/libsystemd-terminal/sysview.h +++ b/src/libsystemd-terminal/sysview.h @@ -137,6 +137,7 @@ void sysview_session_release_control(sysview_session *session); */ const char *sysview_seat_get_name(sysview_seat *seat); +int sysview_seat_switch_to(sysview_seat *seat, uint32_t nr); /* * Contexts |