rename variables to: DH_CONFIG_DIR DH_CONFIG DH_ICON_DIR

This commit is contained in:
zenobit 2023-03-21 15:54:39 +01:00
parent bb164b7380
commit 5d81606629
5 changed files with 48 additions and 47 deletions

View file

@ -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