Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1051  / 3 Years ago, wed, july 28, 2021, 6:35:55
Title: zenity hangs & .desktop files dont have the desired effect
Environment: Ubuntu Oneiric x64, gnome-shell, zfsonlinux
Motivation: Automagically save state of all VM's (and config) while virtualbox doesnt get in the way.
Approach: Use a bash script to do that (snapshot filesystem before starting virtualbox GUI and after it is closed).
Additional Detail: This basically is a One-User-System, and i allowed sudo for zfs commands to myself.

Problem(s):
+ The (zenity)-notification sometimes stays invisible and hangs the script. Thus the "workaround" function. [edit:] This one is better done using the first answer below. I changed the script to reflect that and had no hang since.
- Although the script seems to work (its only used by myself, no multi-user requirement), i was unable have it in the launcher. [edit:] No solution until now.

Failed tries:

Problem 2:
- create .desktop-file, validate it with desktop-file-validate, install with desktop-file-install, reboot => still not there although i installed to the recommended directories. I also used the suggestion from below to no effect.

Problem 1:
(disregard, as it is solved)


Files:



myvirtualbox.desktop:



[Desktop Entry]
Version=1.0
Name=my Oracle VM VirtualBox
GenericName=Virtual Machine
Type=Application
Exec=/home/datakanja/scripte/myVBoxCall.sh
TryExec=/home/datakanja/scripte/myVBoxCall.sh
Icon=virtualbox
Categories=Emulator;System;X-MandrivaLinux-System;
Comment=Run several virtual systems on a single host computer
Comment[de]=VBox mit automatischen Snapshots ausführen


myVBoxCall.sh:



#!/bin/bash
set +e # weil egrep u.U $? <> 0 gibt
# Soll VOR und NACH des Aufrufes von Virtualbox, - falls die Maschinen-Daten sauber sind - zfs-auto-snapshot ausführen.

if [ `ps -A | egrep -wc "V(irtual)?Box"` = 0 ]
then
sudo /sbin/zfs-auto-snapshot --quiet --syslog --label=vmstart --keep=10 -r RAID/backup/vbox
zenity --notification --timeout=10 --window-icon="info" --text="Der Zustand der vbox-Verzeichnisse wurde gesichert."
else
zenity --error --text="Eine VBox-Komponente läuft bereits. Daher weder Snapshot noch Programmstart möglich."
exit
fi

/usr/bin/VirtualBox

if [ `ps -A | egrep -wc "V(irtual)?Box"` = 0 ]
then
sudo /sbin/zfs-auto-snapshot --quiet --syslog --label=vmexit --keep=10 -r RAID/backup/vbox
zenity --notification --timeout=10 --window-icon="info" --text="Der Zustand der vbox-Verzeichnisse wurde gesichert."
else
zenity --error --text="Eine VBox-Komponente läuft noch. Daher konnte kein Snapshot angelegt werden."
fi

More From » 11.10

 Answers
3
Finally...

Really, i dont know why... i did not manage to solve my launcher related problem
by hand... (maybe a misspelling in the path was involved?) but what got my happy
again was:

alacarte

which is part of ubuntu by default (search for name "MAIN MENU" in the - eh -
is it called dash?). Then i entered my script in there and that was it. Easy?

[#39251] Thursday, July 29, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rillrage

Total Points: 122
Total Questions: 120
Total Answers: 103

Location: Tokelau
Member since Thu, Aug 26, 2021
3 Years ago
;