Eu retiro tudo o que eu disse. Eu reduzi meu script para o que está listado abaixo, e ao fazer isso se comportar como eu descrevi, descobri que, no momento em que meus arquivos .desktop foram criados, o conteúdo referenciado do comando Exec referenciado ainda não havia sido criado , tecnicamente, meu arquivo .desktop era inválido. Isso se tornou aparente quando mudei o comando Exec abaixo para 'data'. :) Essa é uma história consistente.
#!/usr/bin/env bash
COMMAND=$(basename $0 .sh)
SS_ROOT=$(pwd)
DESKTOP_SS=/usr/share/applications/eiospa.desktop
DESKTOP_EIO=/usr/share/applications/eioadmin.desktop
TEMPDIR=$(mktemp --directory -q)
#
# Return settings value with extra shit stripped away
#
getSettings()
{
local schema=${1}
local key=${2}
local settings=$(gsettings get ${schema} ${key} | sed -e 's/[,'\'']//g')
settings=${settings#[}
settings=${settings%]}
echo "${settings}"
}
#
# Add back the extra shit and update the settings
#
setSettings()
{
local schema=${1}
local key=${2}
local settings="['$(echo ${3} | sed -e 's/ /'\'', '\''/g')']"
gsettings set ${schema} ${key} "${settings}"
}
#
# Add any provided favorite that isn't in the settings already
#
addFavorite()
{
#local favorite=${1}
local settings=$(getSettings "com.canonical.Unity.Launcher" "favorites")
local found=0
for favorite in ${*}
do
for s in ${settings}
do
[ ${s} = ${favorite} ] && found=1
done
[ ${found} -eq 0 ] && settings="${favorite} ${settings}"
done
setSettings "com.canonical.Unity.Launcher" "favorites" "${settings}"
}
#
# Remove provided favorites if they are in the settings
#
removeFavorite()
{
local favorite=${1}
local settings=$(getSettings "com.canonical.Unity.Launcher" "favorites")
local newSettings=
local sep=
for favorite in ${*}
do
for s in ${settings}
do
[ ${s} = ${favorite} ] || {
newSettings="${newSettings}${sep}${s}"
sep=" "
}
done
settings=${newSettings}
newSettings=
sep=
done
setSettings "com.canonical.Unity.Launcher" "favorites" "${settings}"
}
createSSDesktop()
{
cat <<EOF4 >${TEMPDIR}/$(basename ${DESKTOP_SS})
[Desktop Entry]
Type=Application
Terminal=false
Name=EIO SPA
Icon=${SS_ROOT}/runtime/linux/icons/EIOSPA.ico
Exec=firefox http://localhost:8080
EOF4
sudo mv ${TEMPDIR}/$(basename ${DESKTOP_SS}) ${DESKTOP_SS}
}
createAdminDesktop()
{
cat <<EOF5 >${TEMPDIR}/$(basename ${DESKTOP_EIO})
[Desktop Entry]
Type=Application
Terminal=true
Name=EIO Admin
Icon=${SS_ROOT}/runtime/linux/icons/EIOAdmin.ico
Exec=date
EOF5
sudo mv ${TEMPDIR}/$(basename ${DESKTOP_EIO}) ${DESKTOP_EIO}
}
installLaunchers()
{
addFavorite 'application://eioadmin.desktop' 'application://eiospa.desktop'
}
uninstallLaunchers()
{
removeFavorite 'application://eioadmin.desktop' 'application://eiospa.desktop'
}
removeFiles()
{
sudo rm -f ${DESKTOP_EIO}
sudo rm -f ${DESKTOP_SS}
}
install()
{
createSSDesktop
createAdminDesktop
[ -n "${1}" ] && sleep ${1}
installLaunchers
}
uninstall()
{
uninstallLaunchers
removeFiles
}
case ${COMMAND} in
installex)
install $*
;;
uninstallex)
uninstall $*
;;
*)
;;
esac
rm -rf ${TEMPDIR}