3 PERL_SCRIPT
="claws-mail-kdeservicemenu.pl"
4 DESKTOP
="claws-mail-attach-files.desktop"
6 function check_environ
{
7 echo "Checking for kde4-config..."
8 if [ ! -z "$(type 'kde4-config' 2> /dev/null)" ]; then
9 echo "Found kde4-config..."
10 SERVICEMENU_DIR
="share/kde4/services/ServiceMenus"
11 DESKTOP_TEMPLATE
="claws-mail-attach-files.desktop.kde4template"
12 KDECONFIG
="kde4-config"
14 echo "kde4-config not found..."
15 echo "Checking for kde-config..."
16 if [ ! -z "$(type 'kde-config' 2> /dev/null)" ]; then
17 echo "Found kde-config..."
18 SERVICEMENU_DIR
="share/apps/konqueror/servicemenus"
19 DESKTOP_TEMPLATE
="claws-mail-attach-files.desktop.template"
20 KDECONFIG
="kde-config"
22 echo "kde-config not found..."
23 echo "asking user to find kde4-config or kde-config..."
24 KDECONFIG
=$
(kdialog
--title "Locate kde-config or kde4-config" --getopenfilename / )
25 test -z $KDECONFIG && exit 1
26 if [[ $KDECONFIG == *4-config ]]; then
27 SERVICEMENU_DIR
="share/kde4/services/ServiceMenus"
28 DESKTOP_TEMPLATE
="claws-mail-attach-files.desktop.kde4template"
30 SERVICEMENU_DIR
="share/apps/konqueror/servicemenus"
31 DESKTOP_TEMPLATE
="claws-mail-attach-files.desktop.template"
37 function install_all
{
38 echo "Generating $DESKTOP ..."
39 SED_PREFIX
=${PREFIX//\//\\\/}
40 sed "s/SCRIPT_PATH/$SED_PREFIX\\/bin\\/$PERL_SCRIPT/" $DESKTOP_TEMPLATE > $DESKTOP
41 echo "Installing $PREFIX/$SERVICEMENU_DIR/$DESKTOP"
42 mv -f $DESKTOP $PREFIX/$SERVICEMENU_DIR/$DESKTOP
45 kdialog
--error "Could not complete installation."
48 echo "Installing $PREFIX/bin/$PERL_SCRIPT"
49 cp -f $PERL_SCRIPT $PREFIX/bin
/
50 echo "Setting permissions ..."
51 chmod 0644 $PREFIX/$SERVICEMENU_DIR/$DESKTOP
52 chmod 0755 $PREFIX/bin
/$PERL_SCRIPT
53 echo "Finished installation."
54 kdialog
--msgbox "Finished installation."
57 function uninstall_all
{
58 echo "Removing $PREFIX/$SERVICEMENU_DIR/$DESKTOP"
59 rm $PREFIX/$SERVICEMENU_DIR/$DESKTOP
62 kdialog
--error "Could not complete uninstall."
65 echo "Removing $PREFIX/bin/$PERL_SCRIPT"
66 rm $PREFIX/bin
/$PERL_SCRIPT
67 echo "Finished uninstall."
68 kdialog
--msgbox "Finished uninstall."
72 echo "Usage: $0 [--global|--local|--uninstall-global|--uninstall-local]"
74 echo " --global attempts a system-wide installation."
75 echo " --local attempts to install in your home directory."
76 echo " --uninstall-global attempts a system-wide uninstallation."
77 echo " --uninstall-local attempts to uninstall in your home directory."
83 then option
="--$(kdialog --menu "Please
select installation
type" \
84 local "install for you only
" \
85 global "install for all users
" \
86 uninstall-local "uninstall
for you only
" \
87 uninstall-global "uninstall
for all users
" 2> /dev/null)"
94 PREFIX
=$
($KDECONFIG --prefix)
95 echo "Installing in $PREFIX/$SERVICEMENU_DIR ..."
96 if [ "$(id -u)" != "0" ]; then
97 exec kdesu
"$0 --global"
103 PREFIX
=$
($KDECONFIG --localprefix)
104 echo "Installing in $PREFIX$SERVICEMENU_DIR ..."
105 if [ ! -d $PREFIX/bin
]; then
108 if [ ! -d $PREFIX/$SERVICEMENU_DIR ]; then
109 mkdir
$PREFIX/$SERVICEMENU_DIR
113 "--uninstall-global" )
115 PREFIX
=$
($KDECONFIG --prefix)
116 echo "Uninstalling from $PREFIX/$SERVICEMENU_DIR ..."
117 if [ "$(id -u)" != "0" ]; then
118 exec kdesu
"$0 --uninstall-global"
122 "--uninstall-local" )
124 PREFIX
=$
($KDECONFIG --localprefix)
125 echo "Uninstalling from $PREFIX$SERVICEMENU_DIR ..."