mirror of
				https://github.com/oSoWoSo/DistroHopper.git
				synced 2024-08-14 22:46:53 +00:00 
			
		
		
		
	custom quickemu command
This commit is contained in:
		
							parent
							
								
									be9933defb
								
							
						
					
					
						commit
						5e977e05ee
					
				
					 1 changed files with 22 additions and 14 deletions
				
			
		
							
								
								
									
										36
									
								
								quickfzf
									
										
									
									
									
								
							
							
						
						
									
										36
									
								
								quickfzf
									
										
									
									
									
								
							|  | @ -6,46 +6,42 @@ | ||||||
| 
 | 
 | ||||||
| # Define variables | # Define variables | ||||||
| progname="${progname:="${0##*/}"}" | progname="${progname:="${0##*/}"}" | ||||||
| version="0.23" | version="0.24" | ||||||
| #EDITOR="nano" | #EDITOR="nano" | ||||||
|  | configfile=~/.config/quickfzf/config | ||||||
| vms=(*.conf) | vms=(*.conf) | ||||||
| 
 |  | ||||||
| # Set traps to catch the signals and exit gracefully | # Set traps to catch the signals and exit gracefully | ||||||
| trap "exit" INT | trap "exit" INT | ||||||
| trap "exit" EXIT | trap "exit" EXIT | ||||||
| 
 |  | ||||||
| # Dependency check: check if fzf is installed and can be executed | # Dependency check: check if fzf is installed and can be executed | ||||||
| if ! command -v fzf >/dev/null 2>&1; then | if ! command -v fzf >/dev/null 2>&1; then | ||||||
|     echo "You are missing fzf..." && exit 255 |     echo "You are missing fzf..." && exit 255 | ||||||
| fi | fi | ||||||
| 
 |  | ||||||
| if ! command -v quickemu >/dev/null 2>&1; then | if ! command -v quickemu >/dev/null 2>&1; then | ||||||
|     echo "You are missing quickemu..." && exit 255 |     echo "You are missing quickemu..." && exit 255 | ||||||
| fi | fi | ||||||
| 
 |  | ||||||
| QUICKGET=$(command -v quickget) || exit 255 | QUICKGET=$(command -v quickget) || exit 255 | ||||||
| 
 | 
 | ||||||
| # Display header | # Display header | ||||||
| printf '%s: v.%s\nquickemu: v.%s\n' "$progname" "$version" "$(quickemu --version)" | printf 'Simple TUI for quickemu\n%s: v.%s\nquickemu: v.%s\n' "$progname" "$version" "$(quickemu --version)" | ||||||
|  | if [ -f "$configfile" ]; then | ||||||
|  | 	printf 'custom command:\nquickemu %s\n' "$(cat "$configfile")" | ||||||
|  | fi | ||||||
| if [ -z "$EDITOR" ]; then | if [ -z "$EDITOR" ]; then | ||||||
|     echo "editor: Not set! edit configs will not work!" |     echo "editor: Not set! edit configs will not work!" | ||||||
| else | else | ||||||
|     echo "editor: $EDITOR" |     echo "editor: $EDITOR" | ||||||
| fi | fi | ||||||
| printf '\n Workdir: %s\n\n Prepared VMs:\n-------------\n' "$(pwd)" | printf '\n Workdir: %s\n\n Prepared VMs:\n-------------\n' "$(pwd)" | ||||||
| 
 |  | ||||||
| # Check if there are any VMs | # Check if there are any VMs | ||||||
| if [ ${#vms[@]} -eq 0 ]; then | if [ ${#vms[@]} -eq 0 ]; then | ||||||
|     echo "No VMs found." |     echo "No VMs found." | ||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
| 
 |  | ||||||
| # Print the names of the available VMs | # Print the names of the available VMs | ||||||
| printf "%s\n" "${vms[@]%.*}" | printf "%s\n" "${vms[@]%.*}" | ||||||
| echo "-------------" | echo "-------------" | ||||||
| 
 | printf '\nPress CTRL+c anytime to kill %s\n\n' "$progname" | ||||||
| printf 'Press CTRL+c anytime to kill %s\n\n' "$progname" |  | ||||||
| 
 |  | ||||||
| # Action prompt | # Action prompt | ||||||
| printf " Do you want to create a new VM? (c) | printf " Do you want to create a new VM? (c) | ||||||
|  edit VM's config file (e) |  edit VM's config file (e) | ||||||
|  | @ -87,7 +83,16 @@ elif [ "$todo" = "edit" ]; then | ||||||
| 
 | 
 | ||||||
| # create quickemu custom command | # create quickemu custom command | ||||||
| elif [ "$todo" = "custom" ]; then | elif [ "$todo" = "custom" ]; then | ||||||
| 	echo "custom" | 	custom=$(echo "edit delete"| grep -o '[^ ]*' | fzf --cycle --header='Edit or delete custom command?') | ||||||
|  | 	if [ "$custom" = "edit" ]; then | ||||||
|  | 		quickemu | ||||||
|  | 		printf '\nEnter quickemu custom command:\n' | ||||||
|  | 		read -r qcommand | ||||||
|  | 		mkdir -p ~/.config/quickfzf | ||||||
|  | 		echo "$qcommand" > "$configfile" | ||||||
|  | 	elif [ "$custom" = "delete" ]; then | ||||||
|  | 		rm -r ~/.config/quickfzf | ||||||
|  | 	fi | ||||||
| 
 | 
 | ||||||
| # run VM | # run VM | ||||||
| elif [ "$todo" = "run" ]; then | elif [ "$todo" = "run" ]; then | ||||||
|  | @ -96,7 +101,10 @@ elif [ "$todo" = "run" ]; then | ||||||
| 
 | 
 | ||||||
| 	# Run chosen VM | 	# Run chosen VM | ||||||
| 	printf '\n Starting %s...\n\n' "$chosen" | 	printf '\n Starting %s...\n\n' "$chosen" | ||||||
| 	quickemu -vm "$chosen.conf" | 	if [ -f "$configfile" ]; then | ||||||
|  | 		quickemu $(cat "$configfile") -vm "$chosen".conf | ||||||
|  | 	else | ||||||
|  | 		quickemu -vm "$chosen".conf | ||||||
|  | 	fi | ||||||
| fi | fi | ||||||
| 
 |  | ||||||
| exit 0 | exit 0 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue