Usage: ./entry.sh downloads.conf (below)
------------------------------------------------------------------------------
# entry.sh contents - line 1 = #!/bin/bash
#!/bin/bash
clear
echo "Check if a configuration file is provided as an argument"
echo .
echo .
if [ -z "$1" ]; then
echo "Error: No configuration file provided."
echo "Usage: $0 <config-file>"
exit 1
fi
sleep 2
echo "Reading the configuration file into a variable"
echo .
echo .
config_file="$1"
if [[ ! -f "$config_file" ]]; then
echo "Error: Configuration file '$config_file' not found."
exit 1
fi
echo "Loading Configuratrion file: $config_file"
echo .
echo .
sleep 2
echo "exporting $config_file to \$output_file"
export output_file=$config_file
echo .
echo .
sleep 2
# Print or use the configuration as needed
echo "The following Configuration settings have been loaded:"
cat "$output_file"
sleep 2
# You can now use the $output_file variable in your script
# For example, process the configuration or perform other tasks
# Read the current data from the output file (if it exists)
if [[ -f "$output_file" ]]; then
item1=$(sed -n '1p' "$output_file")
item2=$(sed -n '2p' "$output_file")
item3=$(sed -n '3p' "$output_file")
item4=$(sed -n '4p' "$output_file")
else
item2=""
item3=""
item4=""
fi
# Display the yad dialog with four entry boxes and a checkbox
result=$(yad --form -on-top --title="Customize your Claudemods Installer" \
--image=/home/linux/2024-DEV-WORK/yad/test/entry-input-flat-file/logo.png \
--width=550 \
--center \
--field="Save to New filename:CHK" "FALSE" \
--field="Current Filename" "$item1" \
--field="Main Title" "$item2" \
--field="Description" "$item3" \
--field="Version" "$item4" \
--button="OK:0" --button="Cancel:1")
# Check if the user clicked OK
if [[ $? -eq 0 ]]; then
# Extract the entered values from the result
IFS='|' read -r save_to_new_filename new_output_filename item2 item3 item4 <<< "$result"
# If the checkbox is checked, save to the new output filename
if [[ "$save_to_new_filename" == "TRUE" ]]; then
output_file="$new_output_filename"
echo "$new_output_filename" > "$output_file"
echo "$item2" >> "$output_file"
echo "$item3" >> "$output_file"
echo "$item4" >> "$output_file"
fi
if [[ "$save_to_new_filename" == "FALSE" ]]; then
echo "$item1" > "$output_file"
echo "$item2" >> "$output_file"
echo "$item3" >> "$output_file"
echo "$item4" >> "$output_file"
fi
echo "Data saved to $output_file"
else
echo "Operation cancelled."
fi
-------------------------------------------------------
# config filename for above code: download-window.conf
# downloads.conf contents: Line 1 = ./download-window.conf
./download-window.conf
Title of Download Window2
Description of Download Window2
Version of Download Window2