aboutsummaryrefslogtreecommitdiff
path: root/Mk/Scripts/install-desktop-entries.sh
diff options
context:
space:
mode:
authorMathieu Arnold <mat@FreeBSD.org>2018-01-28 08:25:06 +0000
committerMathieu Arnold <mat@FreeBSD.org>2018-01-28 08:25:06 +0000
commit1aecf7b3660adacfa99ecddec3bd5dc854bf74b0 (patch)
tree77e8c30dd6dbf00e9f1db35a56396d450a032557 /Mk/Scripts/install-desktop-entries.sh
parent1dbd75825cb1cffcab772f287180a696d8ab1c7d (diff)
downloadports-1aecf7b3660adacfa99ecddec3bd5dc854bf74b0.tar.gz
ports-1aecf7b3660adacfa99ecddec3bd5dc854bf74b0.zip
Extract desktop-categories, check-desktop-entries, and install-desktop-entries into scripts.
PR: 225301 Exp-run by: antoine Reviewed by: jilles, kevans Sponsored by: Absolight Differential Revision: https://reviews.freebsd.org/D11304
Notes
Notes: svn path=/head/; revision=460160
Diffstat (limited to 'Mk/Scripts/install-desktop-entries.sh')
-rw-r--r--Mk/Scripts/install-desktop-entries.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/Mk/Scripts/install-desktop-entries.sh b/Mk/Scripts/install-desktop-entries.sh
new file mode 100644
index 000000000000..5acb4db84799
--- /dev/null
+++ b/Mk/Scripts/install-desktop-entries.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# $FreeBSD$
+#
+# MAINTAINER: portmgr@FreeBSD.org
+
+set -e
+
+. "${dp_SCRIPTSDIR}/functions.sh"
+
+validate_env dp_SED dp_ECHO_CMD dp_STAGEDIR dp_DESKTOPDIR
+
+[ -n "${DEBUG_MK_SCRIPTS}" ] || [ -n "${DEBUG_MK_SCRIPTS_INSTALL_DESKTOP_ENTRIES}" ] && set -x
+
+set -u
+
+while [ $# -ge 6 ]; do
+
+ Name="${1}"
+ Comment="${2}"
+ Icon="${3}"
+ Exec="${4}"
+ Categories="${5}"
+ StartupNotify="${6}"
+
+ shift 6
+
+ filename="$(${dp_ECHO_CMD} "${Exec}" | ${dp_SED} -e 's,^/,,g;s,[/ ],_,g;s,[^_[:alnum:]],,g').desktop"
+
+ pathname="${dp_STAGEDIR}${dp_DESKTOPDIR}/${filename}"
+
+ ${dp_ECHO_CMD} "${dp_DESKTOPDIR}/${filename}" >> "${dp_TMPPLIST}"
+
+ {
+ ${dp_ECHO_CMD} "[Desktop Entry]"
+ ${dp_ECHO_CMD} "Type=Application"
+ ${dp_ECHO_CMD} "Version=1.0"
+ ${dp_ECHO_CMD} "Name=${Name}"
+ } > "${pathname}"
+
+ if [ -n "${Comment}" ]; then
+ comment="${Comment}"
+ else
+ comment="$(cd "${dp_CURDIR}" && ${dp_MAKE} -VCOMMENT)"
+ fi
+
+ ${dp_ECHO_CMD} "GenericName=${comment}" >> "${pathname}"
+ ${dp_ECHO_CMD} "Comment=${comment}" >> "${pathname}"
+
+ if [ -n "${Icon}" ]; then
+ ${dp_ECHO_CMD} "Icon=${Icon}" >> "${pathname}"
+ fi
+
+ ${dp_ECHO_CMD} "Exec=${Exec}" >> "${pathname}"
+
+ if [ -n "${Categories}" ]; then
+ categories="${Categories}"
+ else
+ categories="$(cd "${dp_CURDIR}" && ${dp_MAKE} desktop-categories)"
+ fi
+
+ ${dp_ECHO_CMD} "Categories=${categories}" >> "${pathname}"
+
+ if [ -n "${StartupNotify}" ]; then
+ ${dp_ECHO_CMD} "StartupNotify=${StartupNotify}" >> "${pathname}"
+ fi
+done