From 6560e413c0f3bf525abd39130a17a37a6bd56644 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Tue, 20 Feb 2018 18:33:37 +0100 Subject: [PATCH] udev example: handle all 12 vt switches --- examples/udev.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/udev.rs b/examples/udev.rs index d8139db..4fd1a66 100644 --- a/examples/udev.rs +++ b/examples/udev.rs @@ -113,12 +113,14 @@ impl InputHandler for LibinputInputHandler { info!(log, "Stopping example using Logo+Q"); running.store(false, Ordering::SeqCst); false - } else if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_XF86Switch_VT_1 + } else if modifiers.ctrl && modifiers.alt && keysym >= xkb::KEY_XF86Switch_VT_1 + && keysym <= xkb::KEY_XF86Switch_VT_12 && state == KeyState::Pressed { - info!(log, "Trying to switch to vt 1"); - if let Err(err) = session.change_vt(1) { - error!(log, "Error switching to vt 1: {}", err); + let vt = (keysym - xkb::KEY_XF86Switch_VT_1 + 1) as i32; + info!(log, "Trying to switch to vt {}", vt); + if let Err(err) = session.change_vt(vt) { + error!(log, "Error switching to vt {}: {}", vt, err); } false } else if modifiers.logo && keysym == xkb::KEY_Return && state == KeyState::Pressed {