summaryrefslogtreecommitdiff
path: root/src/libsystemd-terminal/sysview.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-09-29 14:59:01 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-09-29 15:37:31 +0200
commit1c7830cc105bfe217abe6f304f4785bbeab209f6 (patch)
tree42cbbd89f7cc63ae80dac83f98f20a951c3741d3 /src/libsystemd-terminal/sysview.c
parentf0c5e28e58215682c832e1667b346b59c804f6a5 (diff)
terminal: add sysview_seat_switch_to()
Add helper to perform session switches on a specific seat whenever we retrieve a VT-switch keyboard event.
Diffstat (limited to 'src/libsystemd-terminal/sysview.c')
-rw-r--r--src/libsystemd-terminal/sysview.c28
1 files changed, 28 insertions, 0 deletions
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
*/