mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	rename variables to: DH_CONFIG_DIR DH_CONFIG DH_ICON_DIR
This commit is contained in:
		
							parent
							
								
									bb164b7380
								
							
						
					
					
						commit
						5d81606629
					
				
					 5 changed files with 48 additions and 47 deletions
				
			
		|  | @ -3,17 +3,17 @@ | |||
| source distrohopper.conf | ||||
| 
 | ||||
| # config path | ||||
| CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| DH_CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| 
 | ||||
| create_structure() { | ||||
|     # create default dirs | ||||
|     mkdir -p "$CONFIG_DIR" | ||||
|     sudo mkdir -p "$ICON_DIR" | ||||
|     mkdir -p "$DH_CONFIG_DIR" | ||||
|     sudo mkdir -p "$DH_ICON_DIR" | ||||
|     # copy everything to config dir | ||||
|     cp -r * "$CONFIG_DIR/" | ||||
|     cp -r * "$DH_CONFIG_DIR/" | ||||
|     # move icons | ||||
|     sudo mv "$CONFIG_DIR/icons/"* "$ICON_DIR/" | ||||
|     rm -r "$CONFIG_DIR/icons" | ||||
|     sudo mv "$DH_CONFIG_DIR/icons/"* "$DH_ICON_DIR/" | ||||
|     rm -r "$DH_CONFIG_DIR/icons" | ||||
| } | ||||
| 
 | ||||
| # Set VMs dir | ||||
|  | @ -21,7 +21,7 @@ set_dir() { | |||
|     NEWDIR="$(yad --file --directory --title="Where to save VMs?")" | ||||
|     VMS_DIR="$NEWDIR" | ||||
|     echo "VMS_DIR=\"$VMS_DIR\" | ||||
|     export \"VMS_DIR\"" >> "$CONFIG_DIR/distrohopper.conf" | ||||
|     export \"VMS_DIR\"" >> "$DH_CONFIG_DIR/distrohopper.conf" | ||||
|     export "VMS_DIR" | ||||
|     echo "New dir is: $VMS_DIR" | ||||
| } | ||||
|  | @ -40,7 +40,7 @@ install_dh() { | |||
| # Renew VMs | ||||
| renew_ready() { | ||||
|     echo "Updating VMs..." | ||||
|     source "$CONFIG_DIR/distrohopper.conf" | ||||
|     source "$DH_CONFIG_DIR/distrohopper.conf" | ||||
|     # Enter ditrohopper VMs dir | ||||
|     cd "$VMS_DIR" || exit | ||||
|     # check for VMs .conf files (ready to run VMs) | ||||
|  | @ -48,15 +48,15 @@ renew_ready() { | |||
|         vm_desktop=$(basename "$VMS_DIR/$vm_conf" .conf) | ||||
|         # Use fuzzy matching to find the best matching icon file (ready to run VMs) | ||||
|         icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f -2) | ||||
|         icon_file=$(find "$ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|         icon_file=$(find "$DH_ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|         # If no icon was found, try shorter name (ready to run VMs) | ||||
|         if [ -z "$icon_file" ]; then | ||||
|             icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f1) | ||||
|             icon_file=$(find "$ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|             icon_file=$(find "$DH_ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|         fi | ||||
|         # If no icon was found, use a default icon (ready to run VMs) | ||||
|         if [ -z "$icon_file" ]; then | ||||
|             icon_file="$ICON_DIR/tux.svg" | ||||
|             icon_file="$DH_ICON_DIR/tux.svg" | ||||
|         fi | ||||
|         # content of desktop files (ready to run VMs) | ||||
|         desktop_file_content="[Desktop Entry] | ||||
|  | @ -66,24 +66,24 @@ Exec=sh -c 'cd \"$VMS_DIR\" && quickemu -vm \"$vm_conf\"' | |||
| Icon=$icon_file | ||||
| Categories=System;Virtualization;" | ||||
|     # create desktop files (ready to run VMs) | ||||
|     echo "$desktop_file_content" > "$CONFIG_DIR"/ready/"$vm_desktop".desktop | ||||
|     echo "$desktop_file_content" > "$DH_CONFIG_DIR"/ready/"$vm_desktop".desktop | ||||
|     done | ||||
| } | ||||
| 
 | ||||
| renew_supported() { | ||||
|     # get supported VMs | ||||
|     quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$CONFIG_DIR/supported.md" | ||||
|     quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$DH_CONFIG_DIR/supported.md" | ||||
|     while read -r get_name; do | ||||
|         vm_desktop=$(echo "$get_name" | tr ' ' '_') | ||||
|         releases=$(quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //') | ||||
|         editions=$(quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //') | ||||
|         icon_name="$ICON_DIR/$get_name" | ||||
|         icon_name="$DH_ICON_DIR/$get_name" | ||||
|         if [ -f "$icon_name.svg" ]; then | ||||
|             icon_file="$icon_name.svg" | ||||
|         elif [ -f "$icon_name.png" ]; then | ||||
|             icon_file="$icon_name.png" | ||||
|         else | ||||
|             icon_file="$ICON_DIR/tux.svg" | ||||
|             icon_file="$DH_ICON_DIR/tux.svg" | ||||
|         fi | ||||
|         # Check if there are editions | ||||
|         if [ -z "$editions" ]; then | ||||
|  | @ -96,7 +96,7 @@ replace=$replace | |||
| Exec=sh -c 'cd \"$VMS_DIR\" && yad --form --field=\"Release:CB\" \"${releases// /$replace}\" | cut -d\"|\" -f1 | xargs -I{} sh -c \"quickget $get_name {}\"' | ||||
| Icon=$icon_file | ||||
| Categories=System;Virtualization;" | ||||
|             echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|             echo "$desktop_file_content" > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|         else | ||||
|             # Create desktop file for VMs with editions | ||||
|             desktop_file_content="[Desktop Entry] | ||||
|  | @ -108,9 +108,9 @@ replace=$replace | |||
| Exec=sh -c 'cd \"$VMS_DIR\" && yad --form --separator=\" \" --field=\"Release:CB\" \"${releases// /$replace}\" --field=\"Edition:CB\" \"${editions// /$replace}\" | xargs -I{} sh -c \"quickget $get_name {}\"' | ||||
| Icon=$icon_file | ||||
| Categories=System;Virtualization;" | ||||
|             echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|             echo "$desktop_file_content" > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|         fi | ||||
|     done < "$CONFIG_DIR"/supported.md | ||||
|     done < "$DH_CONFIG_DIR"/supported.md | ||||
| } | ||||
| 
 | ||||
| set_dir | ||||
|  |  | |||
|  | @ -1,5 +1,7 @@ | |||
| ICON_DIR="/usr/share/icons/distroicons" | ||||
| DH_CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| DH_CONFIG="$DH_CONFIG_DIR/distrohopper.conf" | ||||
| DH_ICON_DIR="/usr/share/icons/distroicons" | ||||
| TERMINAL=sakura | ||||
| replace='"!"' | ||||
| 
 | ||||
| export "CONFIG_DIR" "ICON_DIR" "TERMINAL" "replace" | ||||
| export "DH_CONFIG_DIR" "DH_CONFIG" "DH_ICON_DIR" "TERMINAL" "replace" | ||||
|  |  | |||
|  | @ -1,7 +1,8 @@ | |||
| #!/usr/bin/bash | ||||
| 
 | ||||
| CONFIG_DIR="$HOME"/.config/distrohopper | ||||
| source "$CONFIG_DIR"/distrohopper.conf | ||||
| DH_CONFIG_DIR="$HOME"/.config/distrohopper | ||||
| DH_CONFIG="$DH_CONFIG_DIR/distrohopper.conf" | ||||
| source "$DH_CONFIG" | ||||
| yad --file --directory > target | ||||
| echo "It will take while..." | ||||
| cd "$VMS_DIR" || exit 1 | ||||
|  |  | |||
|  | @ -1,8 +1,9 @@ | |||
| #!/bin/bash | ||||
| 
 | ||||
| # config path | ||||
| CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| source "$CONFIG_DIR"/distrohopper.conf | ||||
| DH_CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| DH_CONFIG="$DH_CONFIG_DIR/distrohopper.conf" | ||||
| source "$DH_CONFIG" | ||||
| # Renew VMs | ||||
| renew_ready() { | ||||
|     echo "Updating VMs..." | ||||
|  | @ -13,15 +14,15 @@ renew_ready() { | |||
|         vm_desktop=$(basename "$VMS_DIR/$vm_conf" .conf) | ||||
|         # Use fuzzy matching to find the best matching icon file (ready to run VMs) | ||||
|         icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f -2) | ||||
|         icon_file=$(find "$ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|         icon_file=$(find "$DH_ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|         # If no icon was found, try shorter name (ready to run VMs) | ||||
|         if [ -z "$icon_file" ]; then | ||||
|             icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f1) | ||||
|             icon_file=$(find "$ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|             icon_file=$(find "$DH_ICON_DIR" -type f -iname "${icon_name// /}.*") | ||||
|         fi | ||||
|         # If no icon was found, use a default icon (ready to run VMs) | ||||
|         if [ -z "$icon_file" ]; then | ||||
|             icon_file="$ICON_DIR/tux.svg" | ||||
|             icon_file="$DH_ICON_DIR/tux.svg" | ||||
|         fi | ||||
|         # content of desktop files (ready to run VMs) | ||||
|         desktop_file_content="[Desktop Entry] | ||||
|  | @ -31,24 +32,24 @@ Exec=sh -c 'cd \"$VMS_DIR\" && quickemu -vm \"$vm_conf\"' | |||
| Icon=$icon_file | ||||
| Categories=System;Virtualization;" | ||||
|     # create desktop files (ready to run VMs) | ||||
|     echo "$desktop_file_content" > "$CONFIG_DIR"/ready/"$vm_desktop".desktop | ||||
|     echo "$desktop_file_content" > "$DH_CONFIG_DIR"/ready/"$vm_desktop".desktop | ||||
|     done | ||||
| } | ||||
| 
 | ||||
| renew_supported() { | ||||
|     # get supported VMs | ||||
|     quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$CONFIG_DIR/supported.md" | ||||
|     quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$DH_CONFIG_DIR/supported.md" | ||||
|     while read -r get_name; do | ||||
|         vm_desktop=$(echo "$get_name" | tr ' ' '_') | ||||
|         releases=$(quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //') | ||||
|         editions=$(quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //') | ||||
|         icon_name="$ICON_DIR/$get_name" | ||||
|         icon_name="$DH_ICON_DIR/$get_name" | ||||
|         if [ -f "$icon_name.svg" ]; then | ||||
|             icon_file="$icon_name.svg" | ||||
|         elif [ -f "$icon_name.png" ]; then | ||||
|             icon_file="$icon_name.png" | ||||
|         else | ||||
|             icon_file="$ICON_DIR/tux.svg" | ||||
|             icon_file="$DH_ICON_DIR/tux.svg" | ||||
|         fi | ||||
|         # Check if there are editions | ||||
|         if [ -z "$editions" ]; then | ||||
|  | @ -61,7 +62,7 @@ replace=$replace | |||
| Exec=sh -c 'cd \"$VMS_DIR\" && yad --form --field=\"Release:CB\" \"${releases// /$replace}\" | cut -d\"|\" -f1 | xargs -I{} sh -c \"quickget $get_name {}\"' | ||||
| Icon=$icon_file | ||||
| Categories=System;Virtualization;" | ||||
|             echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|             echo "$desktop_file_content" > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|         else | ||||
|             # Create desktop file for VMs with editions | ||||
|             desktop_file_content="[Desktop Entry] | ||||
|  | @ -73,9 +74,9 @@ replace=$replace | |||
| Exec=sh -c 'cd \"$VMS_DIR\" && yad --form --separator=\" \" --field=\"Release:CB\" \"${releases// /$replace}\" --field=\"Edition:CB\" \"${editions// /$replace}\" | xargs -I{} sh -c \"quickget $get_name {}\"' | ||||
| Icon=$icon_file | ||||
| Categories=System;Virtualization;" | ||||
|             echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|             echo "$desktop_file_content" > "$DH_CONFIG_DIR"/supported/"$vm_desktop".desktop | ||||
|         fi | ||||
|     done < "$CONFIG_DIR"/supported.md | ||||
|     done < "$DH_CONFIG_DIR"/supported.md | ||||
| } | ||||
| 
 | ||||
| renew_supported | ||||
|  |  | |||
							
								
								
									
										23
									
								
								dh
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								dh
									
										
									
									
									
								
							|  | @ -3,24 +3,21 @@ export LC_ALL=C | |||
| 
 | ||||
| progname="${progname:="${0##*/}"}" | ||||
| version="0.4" | ||||
| GTK_THEME="alt-dialog" | ||||
| CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| ICON_DIR="/usr/share/icons/distroicons" | ||||
| #GTK_THEME="alt-dialog" | ||||
| DH_CONFIG_DIR="$HOME/.config/distrohopper" | ||||
| DH_CONFIG="$DH_CONFIG_DIR/distrohopper.conf" | ||||
| DH_ICON_DIR="/usr/share/icons/distroicons" | ||||
| TERMINAL=sakura | ||||
| replace='"!"' | ||||
| export "CONFIG_DIR" "ICON_DIR" "TERMINAL" "replace" | ||||
| export "DH_CONFIG_DIR" "DH_CONFIG" "DH_ICON_DIR" "TERMINAL" "replace" | ||||
| source "$DH_CONFIG" | ||||
| 
 | ||||
| cd "$VMS_DIR" || exit | ||||
| 
 | ||||
| #source "$CONFIG_DIR/distrohopper.conf" | ||||
| # Set traps to catch the signals and exit gracefully | ||||
| trap "exit" INT | ||||
| trap "exit" EXIT | ||||
| 
 | ||||
| #TODO Add homepages to right click | ||||
| 
 | ||||
| #printf '%s: v.%s\nquickemu: v.%s\n\n Work dir.: %s\n\n Prepared VMs:\n-------------\n' "$progname" "$version" "$(quickemu --version)" "$(pwd)" | ||||
| 
 | ||||
| # dependencies checks | ||||
| if ! command -v yad >/dev/null 2>&1; then | ||||
| 	echo "You are missing yad..." >&2 | ||||
|  | @ -106,10 +103,10 @@ else | |||
| 	# run GUI | ||||
| 	key=$((RANDOM % 9000 + 1000)) | ||||
| 	GTK_THEME="alt-dialog" | ||||
| 	yad --plug="$key" --tabnum=1 --monitor --icons --listen --read-dir="$CONFIG_DIR"/ready --sort-by-name --no-buttons --borders=0 --icon-size=48 --item-width=76 & | ||||
| 	yad --plug="$key" --tabnum=2 --monitor --icons --listen --read-dir="$CONFIG_DIR"/supported --sort-by-name --no-buttons --borders=0 --icon-size=48 --item-width=76 & | ||||
| 	yad --plug="$key" --tabnum=3 --monitor --icons --listen --read-dir="$CONFIG_DIR" --sort-by-name --no-buttons --borders=0 --icon-size=48 --item-width=76 & | ||||
| 	yad --dynamic --notebook --key="$key" --monitor --window-icon="$ICON_DIR"/hop.svg --width=900 --height=800 --title="DistroHopper $version" --listen --no-buttons --tab="run VM" --tab="download VM" --tab="settings" | ||||
| 	yad --plug="$key" --tabnum=1 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR"/ready --sort-by-name --no-buttons --borders=0 --icon-size=48 --item-width=76 & | ||||
| 	yad --plug="$key" --tabnum=2 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR"/supported --sort-by-name --no-buttons --borders=0 --icon-size=48 --item-width=76 & | ||||
| 	yad --plug="$key" --tabnum=3 --monitor --icons --listen --read-dir="$DH_CONFIG_DIR" --sort-by-name --no-buttons --borders=0 --icon-size=48 --item-width=76 & | ||||
| 	yad --dynamic --notebook --key="$key" --monitor --window-icon="$DH_ICON_DIR"/hop.svg --width=900 --height=800 --title="DistroHopper $version" --listen --no-buttons --tab="run VM" --tab="download VM" --tab="settings" | ||||
| fi | ||||
| 
 | ||||
| exit 0 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue