-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfvwm-menu-virtualbox
executable file
·71 lines (51 loc) · 1.77 KB
/
fvwm-menu-virtualbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# fvwm-menu-virtualbox
# by greatant
# https://github.com/greatant/fvwm-pipemenus/
#
# Requires: virtualbox
#====================================================
dif() {
awk 'BEGIN{RS=ORS=" "}
{NR==FNR?a[$0]++:a[$0]--}
END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}
main() {
ActiveIcon="online.png"
InactiveIcon="offline.png"
All=( $(VBoxManage list vms | awk '{print $1}') )
Active=( $(VBoxManage list runningvms | awk '{print $1}') )
Inactive=( $(dif All[@] Active[@]) )
# MissingSubmenuFunction
echo "DestroyFunc FuncFvwmMenuVBox"
echo "AddToFunc FuncFvwmMenuVBox I Piperead '${0} \$0'"
echo "DestroyMenu recreate FvwmMenuVBox"
echo "AddToMenu FvwmMenuVBox MissingSubmenuFunction FuncFvwmMenuVBox"
for vm in ${Active[@]}; do
echo "+ \"${vm}%$ActiveIcon%\" Popup \"${vm}\""; done
for vm in ${Inactive[@]}; do
echo "+ \"${vm}%$InactiveIcon%\" Exec exec VBoxManage startvm ${vm} --type sdl"; done
echo "+ \"\" Nop"
echo "+ \"Pause All\" Exec for vm in ${Active[@]}; do VBoxManage controlvm ${vm} pause; done"
echo "+ \"Resume All\" Exec for vm in ${Active[@]}; do VBoxManage controlvm ${vm} resume; done"
if [ ${#Active[@]} -gt 0 ]; then
echo "+ \"Shutdown All\" Exec for vm in ${Active[@]}; do VBoxManage controlvm ${vm} acpipowerbutton; done"
fi
}
submenu() {
State=$(VBoxManage showvminfo ${1} | grep State | awk '{print $2}')
echo "DestroyMenu recreate ${1}"
echo "AddToMenu ${1}"
#if [ $State=="running" ]; then
# echo "+ \"Pause\" Exec exec VBoxManage controlvm ${1} pause"
# else
# if [ $State=="paused" ]; then
# echo "+ \"Resume\" Exec exec VBoxManage controlvm ${1} resume"
# fi
#fi
echo "+ \"Shutdown\" Exec exec VBoxManage controlvm ${1} acpipowerbutton"
}
case "${1}" in
"") main;;
"WinXP") submenu;;
esac