udev example: handle all 12 vt switches

This commit is contained in:
Victor Berger 2018-02-20 18:33:37 +01:00 committed by Drakulix
parent 9058f37a6a
commit 6560e413c0
1 changed files with 6 additions and 4 deletions

View File

@ -113,12 +113,14 @@ impl InputHandler<LibinputInputBackend> for LibinputInputHandler {
info!(log, "Stopping example using Logo+Q"); info!(log, "Stopping example using Logo+Q");
running.store(false, Ordering::SeqCst); running.store(false, Ordering::SeqCst);
false 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 && state == KeyState::Pressed
{ {
info!(log, "Trying to switch to vt 1"); let vt = (keysym - xkb::KEY_XF86Switch_VT_1 + 1) as i32;
if let Err(err) = session.change_vt(1) { info!(log, "Trying to switch to vt {}", vt);
error!(log, "Error switching to vt 1: {}", err); if let Err(err) = session.change_vt(vt) {
error!(log, "Error switching to vt {}: {}", vt, err);
} }
false false
} else if modifiers.logo && keysym == xkb::KEY_Return && state == KeyState::Pressed { } else if modifiers.logo && keysym == xkb::KEY_Return && state == KeyState::Pressed {