summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt
diff options
context:
space:
mode:
authorSimon Rettberg2020-08-18 12:32:59 +0200
committerSimon Rettberg2020-08-18 12:32:59 +0200
commit9505f04088c473d3fa12c32213e2d6fec5b35e79 (patch)
tree98ccee0690091415b820a8f288df6fba017bb477 /core/modules/run-virt/data/opt
parent[run-virt] Use special blackboxrc (diff)
downloadmltk-9505f04088c473d3fa12c32213e2d6fec5b35e79.tar.gz
mltk-9505f04088c473d3fa12c32213e2d6fec5b35e79.tar.xz
mltk-9505f04088c473d3fa12c32213e2d6fec5b35e79.zip
[run-virt] Only restart WM if a different one is requested
Diffstat (limited to 'core/modules/run-virt/data/opt')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc29
1 files changed, 20 insertions, 9 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc
index 59d5d3bc..bedb9feb 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/start_windowmanager.inc
@@ -6,27 +6,29 @@
# Some problems may arise with windows opening in background when
# using eg. vmware without a window manager.
start_wm() {
- # Sanity checks
- unset RUNVIRT_DM
# xfwm4 and metacity make the VM appear frozen after openslx.exe
# tries to change the resolution
- for DM in "$@" openbox blackbox kwin; do
- if type "${DM}" >/dev/null 2>&1 ; then
- declare -g RUNVIRT_DM="${DM}"
+ local i dm
+ dm=
+ for i in "$@" openbox blackbox kwin; do
+ if command -v "${i}" &> /dev/null ; then
+ dm="$i"
break
fi
done
- if ! isset RUNVIRT_DM; then
+ if isempty dm; then
# not fatal, so do not exit but report via slxlog
slxlog "runvirt-wm" "Could not find any window manager to use!"
notify_user "Konnte keinen Window Manager finden. (Das ist schlecht!)"
return 1
fi
- # start RUNVIRT_DM determined above
- writelog "Starting ${RUNVIRT_DM}."
+ # If it's the same, do nothing
+ is_wm_runnning "${dm}" && return 0
+
+ # start DM determined above
declare -a OPTS=()
- case "$RUNVIRT_DM" in
+ case "${dm}" in
openbox|kwin|xfwm4|metacity)
OPTS+=( "--replace" )
;;
@@ -40,6 +42,8 @@ start_wm() {
;;
esac
stop_wm
+ writelog "Starting ${dm} ${OPTS[*]}."
+ declare -g RUNVIRT_DM="${dm}"
{
trap '[ -n "$wpid" ] && kill "$wpid"; exit' EXIT TERM INT
dc=0
@@ -71,12 +75,19 @@ start_wm() {
return 0
}
+is_wm_running() {
+ isempty RUNVIRT_DM_PID && return 1
+ ! isempty "$1" && [ "$RUNVIRT_DM" != "$1" ] && return 1
+ kill -0 "$RUNVIRT_DM_PID"
+}
+
stop_wm() {
isempty RUNVIRT_DM_PID && return 0
kill "$RUNVIRT_DM_PID"
usleep 100000
kill -9 "$RUNVIRT_DM_PID"
declare -g RUNVIRT_DM_PID=
+ declare -g RUNVIRT_DM=
}
## MAIN ##