@@ -18,6 +18,27 @@ echo "$MSG_RUNNING"
1818
1919while true
2020do
21+ function variables_set() {
22+ # DEBUG mod
23+ # bash -x ./dh 2>&1 | tee output.log
24+ # progname="${progname:="${0##*/}"}"
25+ progname=" DistroHopper"
26+ version=" 0.80"
27+ # GTK_THEME="alt-dialog"
28+ DH_CONFIG_DIR=" $HOME /.config/distrohopper"
29+ DH_CONFIG=" $DH_CONFIG_DIR /distrohopper.conf"
30+ DH_ICON_DIR=" /usr/share/icons/distrohopper"
31+ PATH_PREFIX=" /usr/bin/"
32+ TMP_DIR=" /tmp"
33+ terminal=" sakura"
34+ replace=' "!"'
35+ # export "DH_CONFIG_DIR" "DH_CONFIG" "replace" "DH_ICON_DIR" "PATH_PREFIX" "TMP_DIR" "terminal"
36+ check_and_set_mode
37+ # Set traps to catch the signals and exit gracefully
38+ trap " exit" INT
39+ trap " exit" EXIT
40+ }
41+
2142 function bugs_notice_show() {
2243 echo " "
2344 echo " $MSG_DONE "
92113 [ -f " $PATH_PREFIX /fzf" ] || echo " $MSG_FZF "
93114 }
94115
95- function variables_set() {
96- # DEBUG mod
97- # bash -x ./dh 2>&1 | tee output.log
98- # progname="${progname:="${0##*/}"}"
99- progname=" DistroHopper"
100- version=" 0.80"
101- # GTK_THEME="alt-dialog"
102- DH_CONFIG_DIR=" $HOME /.config/distrohopper"
103- DH_CONFIG=" $DH_CONFIG_DIR /distrohopper.conf"
104- DH_ICON_DIR=" /usr/share/icons/distrohopper"
105- PATH_PREFIX=" /usr/bin/"
106- TMP_DIR=" /tmp"
107- terminal=" sakura"
108- replace=' "!"'
109- # export "DH_CONFIG_DIR" "DH_CONFIG" "replace" "DH_ICON_DIR" "PATH_PREFIX" "TMP_DIR" "terminal"
110- check_and_set_mode
111- # Set traps to catch the signals and exit gracefully
112- trap " exit" INT
113- trap " exit" EXIT
114- }
115-
116116 function desktop_entry_create() {
117117 cat << EOF > ${DESKTOP_FILE}
118118[Desktop Entry]
149149 type=' Application'
150150 name=' DistroHopper'
151151 comment=' Quickly download, create and run VM of any#TODO operating system.'
152- version=' 0.77b '
152+ version=" ${version} "
153153 execmd=" sh -c 'cd ${VMS_DIR} && dh g'"
154154 if [ " $interminal " == " yes" ]; then
155155 terminal=' true'
@@ -241,16 +241,13 @@ EOF
241241
242242 function virtual_machines_update_ready() {
243243 cd " $VMS_DIR " || exit 1
244- rm " $DH_CONFIG_DIR " /ready/* .desktop
245- # for files in "$VMS_DIR"/*; do
246- # if [ ! -e *.conf ]; then
247- # echo $"No .conf files found"
248- # return
249- # fi
250- for vm_conf in * .conf; do
251- if [ " $vm_conf " == " distrohopper.conf" ]; then
252- continue # skip processing distrohopper.conf
244+ rm " $DH_CONFIG_DIR " /ready/* .desktop 2> /dev/null
245+ for vm_conf in $( pwd)
246+ do
247+ if [ " ${vm_conf} " == " distrohopper.conf" ]; then
248+ echo " continue" # skip processing distrohopper.conf
253249 fi
250+ echo " creating..."
254251 vm_desktop=$( basename " $VMS_DIR /$vm_conf " .conf)
255252 # Use fuzzy matching to find the best matching icon file (ready to run VMs)
256253 icon_name=$( basename " $VMS_DIR /$vm_conf " .conf | cut -d' -' -f -2)
@@ -266,16 +263,51 @@ EOF
266263 type=' Application'
267264 name=" ${vm_desktop} "
268265 comment=' Quickly download, create and run VM of any#TODO operating system.'
269- version=' 0.77b '
266+ version=" ${version} "
270267 execmd=" sh -c 'cd ${VMS_DIR} && ${portable_prefix} quickemu -vm ${vm_conf} ;$SHELL '"
271268 icon=" ${icon_file} "
272269 categories=' System;Virtualization;'
273270 desktop_entry_create
274271 done
275272 }
276273
274+ function renew_ready() {
275+ cd " $VMS_DIR " || exit 1
276+ # for files in "$VMS_DIR"/*; do
277+ # if [ ! -e *.conf ]; then
278+ # echo $"No .conf files found"
279+ # return
280+ # fi
281+ for vm_conf in * .conf; do
282+ if [ " $vm_conf " == " distrohopper.conf" ]; then
283+ continue # skip processing distrohopper.conf
284+ fi
285+ vm_desktop=$( basename " $VMS_DIR /$vm_conf " .conf)
286+ # Use fuzzy matching to find the best matching icon file (ready to run VMs)
287+ icon_name=$( basename " $VMS_DIR /$vm_conf " .conf | cut -d' -' -f -2)
288+ icon_file=$( find " $DH_ICON_DIR " -type f -iname " ${icon_name// / } .*" )
289+ # If no icon was found, try shorter name (ready to run VMs)
290+ if [ -z " $icon_file " ]; then
291+ icon_name=$( basename " $VMS_DIR /$vm_conf " .conf | cut -d' -' -f1)
292+ icon_file=$( find " $DH_ICON_DIR " -type f -iname " ${icon_name// / } .*" )
293+ elif [ -z " $icon_file " ]; then
294+ icon_file=" $DH_ICON_DIR /tux.svg"
295+ fi
296+ # content of desktop files (ready to run VMs)
297+ cat << EOF > "$DH_CONFIG_DIR "/ready/"$vm_desktop ".desktop
298+ [Desktop Entry]
299+ Type=Application
300+ Name=$vm_desktop
301+ Exec=sh -c 'cd ${VMS_DIR} && ${portable_prefix} quickemu -vm ${vm_conf} '
302+ Icon=$icon_file
303+ Categories=System;Virtualization;
304+
305+ EOF
306+ done
307+ }
308+
277309 function virtual_machines_update_supported() {
278- rm " $DH_CONFIG_DIR " /supported/* .desktop
310+ rm " $DH_CONFIG_DIR " /supported/* .desktop
279311 echo " $MSG_INTERM "
280312 run_in_terminal
281313 # get supported VMs
692724 ;;
693725 r|ready)
694726 echo " $MSG_U_READY "
695- virtual_machines_update_ready
727+ # virtual_machines_update_ready
728+ renew_ready
696729 shift
697730 ;;
698731 t|tui)
0 commit comments