This is very much a rough prototype, still evolving.
Hope to add selection of Application Category to load list relevant to each Category.
FUTURES: Checklist of Windows Tools, a selection of "QuarkXPress" would offer a list of alternates for the Linux environment.
Prototype [WindowsApplicationAlternateOffer.sh] :
#!/bin/bash
echo -e "\n
This script starts a GUI for selecting, and installing,
Applications that are suitable alternates to applications
which are currently the User's preferred tools within the
Windows environment.\n
The selections are offered in functional or task-oriented groupings."
###
### Function to present options and capture selected actions
###
selectForInstall()
{
# Read the output from YAD (selected items only)
# --print-column=3 ensures only the hidden action command is output
# --separator='\n' sets a newline separator for multiple selections
yad --list \
--title="Choose Applications to install" \
--text="\n Click on box next to application to select install on your computer ..." \
--checklist \
--border=20 \
--column="Select:CHK" \
--column="Cost:TEXT" \
--column="Application Name:TEXT" \
--column="Command:HD" \
--height=400 --width=500 \
--button="OK:0" --button="Cancel:1" \
--print-column=4 \
--separator=$'\n' \
"${yad_list_data[@]}"
}
confirmDataIimport()
{
echo "Count of items in imported data list = $count"
indx=0
while [ ${indx} -lt ${count} ]
do
echo ${yad_list_data[${indx}]}
indx=$(expr ${indx} + 1 )
done
exit
}
initDirective_publweb()
{
###
### Directive: publweb
###
defltBrowserRef="$(xdg-settings get default-web-browser)"
#echo ${defltBrowserRef}
if [ -n "${defltBrowserRef}" ]
then
defltBrowser=$(
{
grep '^Exec=' "${HOME}/.local/share/applications/${defltBrowserRef}" ;
grep '^Exec=' "/usr/local/share/applications/${defltBrowserRef}"
} 2>>/dev/null | head -1 | cut -f2- -d"=" | sed 's+[%]u$++' )
#echo ${defltBrowser}
fi
}
initDirective_repdist()
{
echo "holding pattern for future logic" >>/dev//null
}
######################################################################################
######################################################################################
appLocn="$(dirname "$0" )"
appBase="$(basename "$0" ".sh" )"
###
### Function to load attributes applicable to various Application choices offered
### FUTURES: load data array for applications specific to an Application Category i.e. Desktop Publishing
###
applGroupingData="${applLocn}/${appBase}.DesktopPublishing.txt"
if [ -s "${applGroupingData}" ]
then
echo "Building array/list variable from external data file ..."
yad_list_data=( $(awk '{ printf("%s ", $0 ) ; }' <"${applGroupingData}" ) )
else
###
### Initialize array of list items and their associated actions
### Format: CHECK_STATE "COST" "APPLICATION" "ACTION_DIRECTIVE"
###
yad_list_data=(
FALSE "" "Scribus" "repdist|scribus"
FALSE "" "Inkscape" "repdist|inkscape"
FALSE "" "Laidout" "publweb|https://github.com/Laidout/laidout/releases"
FALSE "$" "VivaDesigner" "publweb|https://viva.systems/designer/"
)
fi
count=${#yad_list_data[@]}
if [ "${count}" -eq 0 ]
then
echo "\n\t Unable to initialize form to present software options for selection. Abandoning!\n" ; exit 1
fi
#confirmDataIimport()
###
### Initialize facilitators for action directives
###
tmp="/tmp/$( basename "$0" ".sh" ).$$"
selectForInstall >"${tmp}.selections" 2>>/dev/null
# Confirm acCheck the exit code of yad
if [ $? -gt 0 ]
then
echo "Dialog cancelled."
exit 1
fi
cut -f1 -d"|" "${tmp}.selections" | sort | uniq >"${tmp}.applclasses"
for applClass in $( cat "${tmp}.applclasses" )
do
initDirective_${applClass}
case "${applClass}" in
"repdist" )
origin="Distro-Originating"
actionForm="apt-get install"
actionPrep="apt-cache search APPLN | awk -v appl=\"\${action}\" '{ if( \$1 == appl ){ print \$1 ; } ; }'"
echo -e "\n INITIALIZED: For ${origin} packages, '${actionForm}' action to be applied ..."
#echo "" | awk -v dum="${actionPrep}" '{ print dum ; }'
;;
"publweb" )
origin="Web Self-Published"
actionForm="${defltBrowser}"
echo -e "\n INITIALIZED: For ${origin} packages, browser identified as '${actionForm}' ..."
;;
###
### FUTURES: Add logic to handle LaunchPad PPAs
### FUTURES: Add logic to handle Publisher Debian Repositories
###
* ) echo -e "\n\t Logic to handle Application Class '${applClass}' has not been coded. Abandoning!\n" ; exit 1 ;;
esac
echo -e "\n Processing selected ${origin} Applications [${applClass}] ..."
# Iterate over each selected action (separated by newline)
#while IFS= read -r action
grep '^'${applClass} "${tmp}.selections" | cut -f2- -d"|" |
while IFS="|" read -r action
do
if [ -n "${action}" ]
then
if [ -n "${actionPrep}" ]
then
prepAction=$( echo ${actionPrep} | sed 's+APPLN+'${action}'+' )
testor=$(eval ${prepAction} )
if [ -n "${testor}" ]
then
#echo -e "Executing: ${action}"
# Run the command
echo -e "${actionForm} ${action}"
#eval "${actionForm} ${action}"
else
echo -e "Unable to install '${action}'. That package appears to have been removed from the repository."
fi
else
#echo -e "Executing: ${action}"
# Run the command
echo -e "${actionForm} ${action}"
#eval "${actionForm} ${action}"
fi
fi
done
done
exit 0