This commit is contained in:
zenobit 2023-03-21 15:29:47 +01:00
parent d9bd69fc27
commit 37736cf4e6

View file

@ -1,20 +1,15 @@
#!/bin/bash #!/bin/bash
# shellcheck source=./distrohopper.conf
export LC_ALL=C # config path
echo "Updating VMs..."
# distrohopper config file
CONFIG_DIR="$HOME/.config/distrohopper" CONFIG_DIR="$HOME/.config/distrohopper"
source "$CONFIG_DIR/distrohopper.conf" source "$CONFIG_DIR"/distrohopper.conf
# shellcheck source=distrohopper.conf # Renew VMs
# remove desktop files (ready to run VMs) renew_ready() {
rm -r "$CONFIG_DIR/ready" echo "Updating VMs..."
mkdir "$CONFIG_DIR/ready" # Enter ditrohopper VMs dir
# Enter ditrohopper VMs dir cd "$VMS_DIR" || exit
cd "$VMS_DIR" || exit # check for VMs .conf files (ready to run VMs)
# check for VMs .conf files (ready to run VMs) for vm_conf in *.conf; do
for vm_conf in *.conf; do
vm_desktop=$(basename "$VMS_DIR/$vm_conf" .conf) vm_desktop=$(basename "$VMS_DIR/$vm_conf" .conf)
# Use fuzzy matching to find the best matching icon file (ready to run VMs) # 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_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f -2)
@ -37,14 +32,13 @@ Icon=$icon_file
Categories=System;Virtualization;" Categories=System;Virtualization;"
# create desktop files (ready to run VMs) # create desktop files (ready to run VMs)
echo "$desktop_file_content" > "$CONFIG_DIR"/ready/"$vm_desktop".desktop echo "$desktop_file_content" > "$CONFIG_DIR"/ready/"$vm_desktop".desktop
done done
}
# remove desktop files (supported VMs) renew_supported() {
rm -r "$CONFIG_DIR/supported" # get supported VMs
mkdir "$CONFIG_DIR/supported" quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$CONFIG_DIR/supported.md"
# get supported VMs while read -r get_name; do
quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' > "$CONFIG_DIR/supported.md"
while read -r get_name; do
vm_desktop=$(echo "$get_name" | tr ' ' '_') vm_desktop=$(echo "$get_name" | tr ' ' '_')
releases=$(quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //') releases=$(quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //')
editions=$(quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //') editions=$(quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //')
@ -63,7 +57,7 @@ while read -r get_name; do
Type=Application Type=Application
Name=$get_name Name=$get_name
releases=$releases releases=$releases
replace='\"!\"' 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 {}\"' 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 Icon=$icon_file
Categories=System;Virtualization;" Categories=System;Virtualization;"
@ -81,4 +75,10 @@ Icon=$icon_file
Categories=System;Virtualization;" Categories=System;Virtualization;"
echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop
fi fi
done < "$CONFIG_DIR"/supported.md done < "$CONFIG_DIR"/supported.md
}
renew_supported
renew_ready
echo "Done"