summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-10-11 18:07:40 +0200
committerSimon Rettberg2016-10-11 18:07:40 +0200
commit49b0840fe6f510e88d53894675784a6813cf910e (patch)
treebe07282d494db49339ddc3a06fa102714dc2ba7c
parent[pvs2] Let's try this.... (diff)
downloadtm-scripts-49b0840fe6f510e88d53894675784a6813cf910e.tar.gz
tm-scripts-49b0840fe6f510e88d53894675784a6813cf910e.tar.xz
tm-scripts-49b0840fe6f510e88d53894675784a6813cf910e.zip
[pvs2] Ship own lock script that will minimize and maximize vmware to release its mouse/keyboard grab
-rwxr-xr-xremote/modules/pvs2/data/opt/openslx/pvs2/lockDesktop.sh25
-rw-r--r--remote/modules/pvs2/module.build3
2 files changed, 27 insertions, 1 deletions
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."