renew.sh
This commit is contained in:
parent
d9bd69fc27
commit
37736cf4e6
116
config/renew.sh
116
config/renew.sh
|
@ -1,35 +1,30 @@
|
||||||
#!/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)
|
|
||||||
icon_file=$(find "$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 "$ICON_DIR" -type f -iname "${icon_name// /}.*")
|
||||||
fi
|
# If no icon was found, try shorter name (ready to run VMs)
|
||||||
# If no icon was found, use a default icon (ready to run VMs)
|
if [ -z "$icon_file" ]; then
|
||||||
if [ -z "$icon_file" ]; then
|
icon_name=$(basename "$VMS_DIR/$vm_conf" .conf | cut -d'-' -f1)
|
||||||
icon_file="$ICON_DIR/tux.svg"
|
icon_file=$(find "$ICON_DIR" -type f -iname "${icon_name// /}.*")
|
||||||
fi
|
fi
|
||||||
# content of desktop files (ready to run VMs)
|
# If no icon was found, use a default icon (ready to run VMs)
|
||||||
desktop_file_content="[Desktop Entry]
|
if [ -z "$icon_file" ]; then
|
||||||
|
icon_file="$ICON_DIR/tux.svg"
|
||||||
|
fi
|
||||||
|
# content of desktop files (ready to run VMs)
|
||||||
|
desktop_file_content="[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=$vm_desktop
|
Name=$vm_desktop
|
||||||
Exec=sh -c 'cd \"$VMS_DIR\" && quickemu -vm \"$vm_conf\"'
|
Exec=sh -c 'cd \"$VMS_DIR\" && quickemu -vm \"$vm_conf\"'
|
||||||
|
@ -37,40 +32,39 @@ 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"
|
vm_desktop=$(echo "$get_name" | tr ' ' '_')
|
||||||
while read -r get_name; do
|
releases=$(quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //')
|
||||||
vm_desktop=$(echo "$get_name" | tr ' ' '_')
|
editions=$(quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //')
|
||||||
releases=$(quickget "$vm_desktop" | grep 'Releases' | cut -d':' -f2 | sed 's/^ //')
|
icon_name="$ICON_DIR/$get_name"
|
||||||
editions=$(quickget "$vm_desktop" | grep 'Editions' | cut -d':' -f2 | sed 's/^ //')
|
if [ -f "$icon_name.svg" ]; then
|
||||||
icon_name="$ICON_DIR/$get_name"
|
icon_file="$icon_name.svg"
|
||||||
if [ -f "$icon_name.svg" ]; then
|
elif [ -f "$icon_name.png" ]; then
|
||||||
icon_file="$icon_name.svg"
|
icon_file="$icon_name.png"
|
||||||
elif [ -f "$icon_name.png" ]; then
|
else
|
||||||
icon_file="$icon_name.png"
|
icon_file="$ICON_DIR/tux.svg"
|
||||||
else
|
fi
|
||||||
icon_file="$ICON_DIR/tux.svg"
|
# Check if there are editions
|
||||||
fi
|
if [ -z "$editions" ]; then
|
||||||
# Check if there are editions
|
# Create desktop file for VMs without editions
|
||||||
if [ -z "$editions" ]; then
|
desktop_file_content="[Desktop Entry]
|
||||||
# Create desktop file for VMs without editions
|
|
||||||
desktop_file_content="[Desktop Entry]
|
|
||||||
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;"
|
||||||
echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop
|
echo "$desktop_file_content" > "$CONFIG_DIR"/supported/"$vm_desktop".desktop
|
||||||
else
|
else
|
||||||
# Create desktop file for VMs with editions
|
# Create desktop file for VMs with editions
|
||||||
desktop_file_content="[Desktop Entry]
|
desktop_file_content="[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=$get_name
|
Name=$get_name
|
||||||
releases=$releases
|
releases=$releases
|
||||||
|
@ -79,6 +73,12 @@ 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 {}\"'
|
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
|
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"
|
||||||
|
|
Loading…
Reference in New Issue