From 49b0840fe6f510e88d53894675784a6813cf910e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 11 Oct 2016 18:07:40 +0200 Subject: [pvs2] Ship own lock script that will minimize and maximize vmware to release its mouse/keyboard grab --- .../pvs2/data/opt/openslx/pvs2/lockDesktop.sh | 25 ++++++++++++++++++++++ remote/modules/pvs2/module.build | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh diff --git a/remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh b/remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh new file mode 100755 index 00000000..c9cfc421 --- /dev/null +++ b/remote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh @@ -0,0 +1,25 @@ +#!/bin/ash + +# Problem: While any application (e.g. VMware) is holding the mouse and +# keyboard grab, xscreensaver couldn't grab them, so it will ignore the +# locking request. Without the keyboard grab, all input would still go +# to the vmware window below the black screen, which is, you know, bad, +# since you cannot enter your password to unlock the workstation again. + +# So we minimize vmware, lock the screen, and then restore vmware. +# TODO: Add other virtualizers (vbox, kvm) later if needed. +WINDOWS=$(xdotool search --class vmplayer) +for window in $WINDOWS; do + xdotool windowminimize $window +done +# move mouse pointer to the center of the screen to avoid some problems with ghost clicks +xdotool mousemove --polar 0 0 --sync + +# now actually lock +xscreensaver-command --lock + +# above lock call is blocking, so now xscreensaver should be active - let's restore vmware +for window in $WINDOWS; do + xdotool windowmap $window +done + diff --git a/remote/modules/pvs2/module.build b/remote/modules/pvs2/module.build index 970c3c00..607b6d5f 100644 --- a/remote/modules/pvs2/module.build +++ b/remote/modules/pvs2/module.build @@ -26,7 +26,8 @@ build() { # copy external scripts under 'sample_configuration' mkdir -p "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" if [ -d "${SRCDIR}/sample_configuration" ]; then - cp "${SRCDIR}/sample_configuration"/{kb-lock,kb-unlock,lockDesktop,switchToManager,switchBack}.sh "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" \ + # Do not copy lockDesktop.sh - we ship a modified one + cp "${SRCDIR}/sample_configuration"/{kb-lock,kb-unlock,switchToManager,switchBack}.sh "${MODULE_BUILD_DIR}/opt/openslx/pvs2/" \ || perror "Could not copy external scripts to '${MODULE_BUILD_DIR}/opt/openslx/pvs2/'!" chmod +x "${MODULE_BUILD_DIR}/opt/openslx/pvs2"/*.sh \ || perror "Could not set executable bit for external scripts." -- cgit v1.2.3-55-g7522