editor
621
modifications
m (change <pre> en ajout d'un espace en début de ligne) |
m (<syntaxhighlight lang="bash" line="line">) |
||
Ligne 9 : | Ligne 9 : | ||
== Le Script == | == Le Script == | ||
<syntaxhighlight lang="bash" line="line"> | |||
#!/bin/bash | |||
# subject: VirtualBox Launcher by Zenity... | |||
# author: Stephane HUC, alias PengouinPdt | |||
# email: devs@stephane-huc.net | |||
# License texts: | |||
# | |||
# GNU General Public License version 3 (GPL-3) | |||
# | |||
#On Debian systems, the full text of the GNU General Public License version 3 | |||
#can be found in the file `/usr/share/common-licenses/GPL-3'. | |||
# | |||
vmdir="/home/$USER/VirtualBox VMs/" | |||
function display_goodbye() { | |||
zenity --notification --title="Au Revoir !" --timeout=7 \ | |||
--text="*** Au revoir ! ***" | |||
exit; | |||
} | |||
function echos_welcome() { | |||
i=0 | |||
while [ "$i" -le "$count" ]; do | |||
if [ -n "${NAME[$i]}" ]; then | |||
let j=i+1 | |||
echo "$j"; | |||
echo "${NAME[$i]}"; | |||
echo "${DESC[$i]}"; | |||
unset j; | |||
fi | |||
let i=i+1; | |||
done | |||
unset i; | |||
} | |||
function list_dir() { | |||
i=0 | |||
for dir in $(ls "${vmdir}"); do | |||
NAME[$i]="${dir}" | |||
MSSG[$i]=$(egrep "name=\"${dir}\"" "${vmdir}${dir}/${dir}.vbox" | awk -F'"' '{print $6}') | |||
DESC[$i]=$(echo ${MSSG[$i]} | sed -e "s/\_64/\ \(64\ bit\)/g") | |||
let i=i+1; | |||
done | |||
count=${#NAME[@]} | |||
unset i; | |||
} | |||
function starter_vbox() { | |||
optirun=$(which optirun) | |||
virtualbox=$(which virtualbox) | |||
if [ -e $optirun ]; then | |||
$optirun $virtualbox --startvm ${NAME[$choice]} | |||
else | |||
$virtualbox --startvm ${NAME[$choice]} | |||
fi | |||
} | |||
function welcome() { | |||
choice=$( echos_welcome | zenity --list --title="VBox Launcher" \ | |||
--text="Veuillez indiquer quelle VBox lancer :" \ | |||
--column="Choix" --column="Nom" --column="Description" ); | |||
if [ $? -eq 1 ]; then display_goodbye; fi | |||
choice=$(echo "$choice - 1" | bc) | |||
} | |||
list_dir | |||
welcome | |||
starter_vbox | |||
</syntaxhighlight> | |||
[[Catégorie:Programmation]] | [[Catégorie:Programmation]] | ||
[[Catégorie:Scripts]] | [[Catégorie:Scripts]] |