Dotfiles_ArchAP/bin/.local/bin/vmware-on-demand
grayTerminal-sh 960faa2d60 update
2026-07-26 21:11:35 +02:00

48 lines
1 KiB
Bash
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -u
readonly STACK_HELPER="/usr/local/sbin/vmware-stack"
readonly LOCK_FILE="${XDG_RUNTIME_DIR:-/tmp}/vmware-on-demand.lock"
services_started=0
cleanup() {
if (( services_started == 1 )); then
notify-send "VMware" "Arrêt du réseau VMware et de Samba…"
if sudo -n "$STACK_HELPER" stop; then
notify-send "VMware" "Réseau VMware et Samba arrêtés."
else
notify-send -u critical \
"VMware" \
"Impossible darrêter les services."
fi
fi
}
exec 9>"$LOCK_FILE"
if ! flock -n 9; then
notify-send "VMware" "Une session VMware est déjà lancée."
exit 0
fi
notify-send "VMware" "Démarrage du réseau VMware et de Samba…"
if ! sudo -n "$STACK_HELPER" start; then
notify-send -u critical \
"VMware" \
"Impossible de démarrer les services."
exit 1
fi
services_started=1
trap cleanup EXIT INT TERM
vmware "$@" &
while pgrep -x vmware >/dev/null ||
pgrep -x vmware-vmx >/dev/null; do
sleep 3
done