df-install.in revision e39b573c
1e39b573cSmrg#!/bin/sh
2e39b573cSmrg# $XTermId: df-install.in,v 1.5 2011/07/07 09:41:14 tom Exp $
3e39b573cSmrg# -----------------------------------------------------------------------------
4e39b573cSmrg# this file is part of xterm
5e39b573cSmrg#
6e39b573cSmrg# Copyright 2011 by Thomas E. Dickey
7e39b573cSmrg#
8e39b573cSmrg#                         All Rights Reserved
9e39b573cSmrg#
10e39b573cSmrg# Permission is hereby granted, free of charge, to any person obtaining a
11e39b573cSmrg# copy of this software and associated documentation files (the
12e39b573cSmrg# "Software"), to deal in the Software without restriction, including
13e39b573cSmrg# without limitation the rights to use, copy, modify, merge, publish,
14e39b573cSmrg# distribute, sublicense, and/or sell copies of the Software, and to
15e39b573cSmrg# permit persons to whom the Software is furnished to do so, subject to
16e39b573cSmrg# the following conditions:
17e39b573cSmrg#
18e39b573cSmrg# The above copyright notice and this permission notice shall be included
19e39b573cSmrg# in all copies or substantial portions of the Software.
20e39b573cSmrg#
21e39b573cSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22e39b573cSmrg# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23e39b573cSmrg# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24e39b573cSmrg# IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
25e39b573cSmrg# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26e39b573cSmrg# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27e39b573cSmrg# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28e39b573cSmrg#
29e39b573cSmrg# Except as contained in this notice, the name(s) of the above copyright
30e39b573cSmrg# holders shall not be used in advertising or otherwise to promote the
31e39b573cSmrg# sale, use or other dealings in this Software without prior written
32e39b573cSmrg# authorization.
33e39b573cSmrg# -----------------------------------------------------------------------------
34e39b573cSmrg#
35e39b573cSmrg# Install desktop-files, substituting the category to customize the file
36e39b573cSmrg# to the current system's conventions.
37e39b573cSmrg#
38e39b573cSmrg# Parameters are passed to the desktop-file-install program.  The last
39e39b573cSmrg# parameter is the name of the ".desktop" file to install.
40e39b573cSmrgOPTS=
41e39b573cSmrg
42e39b573cSmrgif test $# != 0
43e39b573cSmrgthen
44e39b573cSmrg	APP_NAME=$1
45e39b573cSmrg	shift 1
46e39b573cSmrgfi
47e39b573cSmrg
48e39b573cSmrgCDPATH=:
49e39b573cSmrgexport CDPATH
50e39b573cSmrg
51e39b573cSmrgwhile test $# != 0
52e39b573cSmrgdo
53e39b573cSmrg	case .$1 in #(vi
54e39b573cSmrg	*.desktop) #(vi
55e39b573cSmrg		if test $# = 1
56e39b573cSmrg		then
57e39b573cSmrg			OLD_FILE=$1
58e39b573cSmrg		else
59e39b573cSmrg			OPTS="$OPTS $1"
60e39b573cSmrg		fi
61e39b573cSmrg		;;
62e39b573cSmrg	*)
63e39b573cSmrg		OPTS="$OPTS $1"
64e39b573cSmrg		;;
65e39b573cSmrg	esac
66e39b573cSmrg	shift 1
67e39b573cSmrgdone
68e39b573cSmrg
69e39b573cSmrgMY_TEMP=tempdir$$
70e39b573cSmrgrm -rf $MY_TEMP
71e39b573cSmrg
72e39b573cSmrgif test -z "$OLD_FILE"
73e39b573cSmrgthen
74e39b573cSmrg	echo "? not found: $OLD_FILE"
75e39b573cSmrg	exit 1
76e39b573cSmrgelif ! mkdir $MY_TEMP
77e39b573cSmrgthen
78e39b573cSmrg	echo "? cannot mkdir: $MY_TEMP"
79e39b573cSmrg	exit 1
80e39b573cSmrgfi
81e39b573cSmrg
82e39b573cSmrgNEW_FILE=`basename $OLD_FILE`
83e39b573cSmrgsed \
84e39b573cSmrg	-e '/^[^#]/s%xterm%'$APP_NAME'%g' \
85e39b573cSmrg	-e '/^[^#]/s%XTerm%@APP_CLASS@%g' \
86e39b573cSmrg	-e '/^Category=/s%=.*%@DESKTOP_CATEGORY@%' \
87e39b573cSmrg	$OLD_FILE >$MY_TEMP/$NEW_FILE
88e39b573cSmrgcd $MY_TEMP
89e39b573cSmrg
90e39b573cSmrgdesktop-file-install $OPTS $NEW_FILE
91e39b573cSmrg
92e39b573cSmrgcd ..
93e39b573cSmrgrm -rf $MY_TEMP
94e39b573cSmrg
95e39b573cSmrg# vi:ts=4 sw=4
96