add support for Ayatana indicator to Notification plugin
[claws.git] / tools / kdeservicemenu / install.sh
blobe3560ebdea45c6494a37cf67358eb7a209cadb86
1 #!/usr/bin/env bash
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"
13 else
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"
21 else
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"
29 else
30 SERVICEMENU_DIR="share/apps/konqueror/servicemenus"
31 DESKTOP_TEMPLATE="claws-mail-attach-files.desktop.template"
32 fi
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
43 if [[ $? -ne 0 ]]
44 then
45 kdialog --error "Could not complete installation."
46 exit
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
60 if [[ $? -ne 0 ]]
61 then
62 kdialog --error "Could not complete uninstall."
63 exit
65 echo "Removing $PREFIX/bin/$PERL_SCRIPT"
66 rm $PREFIX/bin/$PERL_SCRIPT
67 echo "Finished uninstall."
68 kdialog --msgbox "Finished uninstall."
71 function show_help {
72 echo "Usage: $0 [--global|--local|--uninstall-global|--uninstall-local]"
73 echo
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."
78 echo
79 exit 0
82 if [ -z $1 ]
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)"
88 else option=$1
91 case $option in
92 "--global" )
93 check_environ
94 PREFIX=$($KDECONFIG --prefix)
95 echo "Installing in $PREFIX/$SERVICEMENU_DIR ..."
96 if [ "$(id -u)" != "0" ]; then
97 exec kdesu "$0 --global"
99 install_all
101 "--local" )
102 check_environ
103 PREFIX=$($KDECONFIG --localprefix)
104 echo "Installing in $PREFIX$SERVICEMENU_DIR ..."
105 if [ ! -d $PREFIX/bin ]; then
106 mkdir $PREFIX/bin
108 if [ ! -d $PREFIX/$SERVICEMENU_DIR ]; then
109 mkdir $PREFIX/$SERVICEMENU_DIR
111 install_all
113 "--uninstall-global" )
114 check_environ
115 PREFIX=$($KDECONFIG --prefix)
116 echo "Uninstalling from $PREFIX/$SERVICEMENU_DIR ..."
117 if [ "$(id -u)" != "0" ]; then
118 exec kdesu "$0 --uninstall-global"
120 uninstall_all
122 "--uninstall-local" )
123 check_environ
124 PREFIX=$($KDECONFIG --localprefix)
125 echo "Uninstalling from $PREFIX$SERVICEMENU_DIR ..."
126 uninstall_all
128 "-h" )
129 show_help
131 "--help" )
132 show_help
135 show_help
136 esac
138 echo "Done."