File: update-desktop-file.sh

package info (click to toggle)
banshee 2.4.1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 43,392 kB
  • sloc: cs: 137,906; xml: 90,824; sh: 11,616; ansic: 4,829; makefile: 2,910; python: 38
file content (28 lines) | stat: -rwxr-xr-x 686 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash

DESKTOP_SOURCE="$1"
VERSION="$2"
UPDATE_MIME_FILE="$3"
MIMETYPES_FILE="$(basename "$DESKTOP_SOURCE" .in.in).mime"

echo "[Desktop Entry]"

(cat "$DESKTOP_SOURCE" && cat common.desktop) |
	sed "s/\@VERSION\@/${VERSION}/g"

if [[ -f "$MIMETYPES_FILE" ]]; then
	MIMETYPES=$(
		grep -vE '^[[:space:]]*(#.*|)$' "$MIMETYPES_FILE" | \
		LC_ALL=C sort | uniq | \
		awk '{printf $1 ";"}' | sed 's,;$,,'
	)

	echo "MimeType=$MIMETYPES;"

	if [[ "$UPDATE_MIME_FILE" == "yes" ]]; then
		(grep -E '^[[:space:]]*#' "$MIMETYPES_FILE";
			for t in $(echo "$MIMETYPES" | sed 's,;, ,g'); do echo $t; done) > "$MIMETYPES_FILE".tmp
		mv "$MIMETYPES_FILE".tmp "$MIMETYPES_FILE"
	fi
fi