add kdeservicemenu script
authorPaul Mangan <paul@claws-mail.org>
Mon, 25 Oct 2004 13:41:12 +0000 (13:41 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 25 Oct 2004 13:41:12 +0000 (13:41 +0000)
tools/Makefile.am
tools/kdeservicemenu/README [new file with mode: 0644]
tools/kdeservicemenu/install.sh [new file with mode: 0644]
tools/kdeservicemenu/sylpheed-kdeservicemenu.pl [new file with mode: 0644]
tools/kdeservicemenu/template_sylpheed-attach-files.desktop [new file with mode: 0644]
tools/kdeservicemenu/template_sylpheed-compress-attach.desktop [new file with mode: 0644]

index 49a181e..3ab224c 100644 (file)
@@ -29,6 +29,11 @@ EXTRA_DIST = \
        README \
        README.sylprint \
        multiwebsearch.conf \
+       kdeservicemenu/README \
+       kdeservicemenu/install.sh \
+       kdeservicemenu/sylpheed-kdeservicemenu.pl \
+       kdeservicemenu/template_sylpheed-attach-files.desktop \
+       kdeservicemenu/template_sylpheed-compress-attach.desktop \
        $(EXTRA_TOOLS)
 
 MAKE_EXE = chmod u+x $(EXTRA_TOOLS)
diff --git a/tools/kdeservicemenu/README b/tools/kdeservicemenu/README
new file mode 100644 (file)
index 0000000..a463054
--- /dev/null
@@ -0,0 +1,40 @@
+sylpheed-kdeservicemenu.pl 
+Version: 1.0
+Sylpheed servicemenu for Konqueror
+
+FILES
+o README                       You're reading it
+o install.sh                   installer script
+o sylpheed-kdeservicemenu.pl   perl program
+o template_sylpheed-attach-files.desktop
+o template_sylpheed-compress-attach.desktop
+                               .desktop file templates
+
+DESCRIPTION
+Enables attaching files from Konqueror to a new compose window
+or compression of files/directories and then attaching of
+the archive to a new compose window.
+
+Adds the following menu items to Konqueror's 'Actions' menu:
+/Actions/Sylpheed/Attach file(s)
+/Actions/Sylpheed/Attach as GZip File(s)
+/Actions/Sylpheed/Attach as BZip File(s)
+/Actions/Sylpheed/Attach as Tar Archive
+/Actions/Sylpheed/Attach as Bzipped Tar Archive
+/Actions/Sylpheed/Attach as Gzipped Tar Archive
+/Actions/Sylpheed/Attach as Zip Archive
+
+INSTALL
+o cd sylpheed-claws/tools/kdeservicemenu
+o ./install.sh --global
+  ./install.sh --local
+       (systemwide or home directory installation)
+
+LICENSE
+GPL
+               
+THANKS
+install.sh was written by Dylan Schrader (dschrader@conception.edu) 
+and is released under the GPL. It was originally part of his
+'Attach to email' service Menu for Konqueror, version 0.6.13 
+<http://themes.kde.org/content/show.php?content=11234>
diff --git a/tools/kdeservicemenu/install.sh b/tools/kdeservicemenu/install.sh
new file mode 100644 (file)
index 0000000..c334d80
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+PERL_SCRIPT="sylpheed-kdeservicemenu.pl"
+DESKTOP_TEMPLATE_ONE="template_sylpheed-attach-files.desktop"
+DESKTOP_ONE="sylpheed-attach-files.desktop"
+DESKTOP_TEMPLATE_TWO="template_sylpheed-compress-attach.desktop"
+DESKTOP_TWO="sylpheed-compress-attach.desktop"
+
+function check_environ {
+#Check to see if we can coax kde-config into the PATH
+echo "Checking for kde-config..."
+if [ -z "$(type 'kde-config' 2> /dev/null)" ]; then #Odd way of checking if kde-config is in $PATH
+  echo "kde-config not found, checking for \$KDEDIR to compensate..."
+  if [ ! -z $KDEDIR ]; then
+    export PATH=$PATH:$KDEDIR/bin
+  else
+    echo "***"
+    echo "***$0 cannot figure out where KDE is installed."
+    echo "***kde-config is not in \$PATH, and \$KDEDIR is not set."
+    echo "***To fix this, manually change \$PATH to add the KDE executables."
+    echo "***E.g. export PATH=\$PATH:/opt/kde/bin"
+    echo "***It would also be a good idea to add this line to your shell login/profile."
+    echo "***"
+    echo
+    echo "Nothing was installed or removed."
+    exit 1
+  fi
+fi
+echo "Okay."
+}
+
+function install_all {
+#Go ahead and install
+echo "Generating $DESKTOP_ONE ..."
+SED_PREFIX=${PREFIX//\//\\\/} #Replace forward slashes in $PREFIX with \/ so that sed doesn't freak out
+sed "s/SCRIPT_PATH/$SED_PREFIX\\/bin\\/sylpheed-kdeservicemenu.pl/" $DESKTOP_TEMPLATE_ONE > $DESKTOP_ONE
+cp -f $DESKTOP_ONE $PREFIX/share/apps/konqueror/servicemenus/sylpheed-attach-files.desktop
+echo "Generating $DESKTOP_TWO ..."
+SED_PREFIX=${PREFIX//\//\\\/} #Replace forward slashes in $PREFIX with \/ so that sed doesn't freak out
+sed "s/SCRIPT_PATH/$SED_PREFIX\\/bin\\/sylpheed-kdeservicemenu.pl/" $DESKTOP_TEMPLATE_TWO > $DESKTOP_TWO
+cp -f $DESKTOP_TWO $PREFIX/share/apps/konqueror/servicemenus/sylpheed-compress-attach.desktop
+cp -f $PERL_SCRIPT $PREFIX/bin/
+echo "Setting permissions ..."
+chmod 0644 $PREFIX/share/apps/konqueror/servicemenus/sylpheed-attach-files.desktop
+chmod 0644 $PREFIX/share/apps/konqueror/servicemenus/sylpheed-compress-attach.desktop
+chmod 0755 $PREFIX/bin/$PERL_SCRIPT
+}
+
+case $1 in
+  "--global" )
+    check_environ
+    PREFIX=$(kde-config --prefix)
+    echo "Installing in $PREFIX ..."
+    if [ "$(id -u)" != "0" ]; then
+      echo "You are not root, as would be expected."
+      echo "However, we will still attempt a system-wide install."
+      echo "But, you probably don't have permission."
+    fi
+    install_all
+    ;;
+  "--local" )
+    check_environ
+    PREFIX=$(kde-config --localprefix)
+    echo "Installing in $PREFIX ..."
+    if [ ! -d $PREFIX/bin ]; then
+      mkdir $PREFIX/bin
+    fi
+    if [ ! -d $PREFIX/share/apps/konqueror/servicemenus ]; then
+      mkdir $PREFIX/share/apps/konqueror/servicemenus
+    fi
+    install_all
+    ;;
+  * )
+    echo "Usage: $0 [--global|--local]"
+    echo
+    echo "--global  attempts a system-wide installation."
+    echo "--local   attempts to install in your home directory."
+    echo
+    exit 0
+    ;;
+esac
+
+echo "Done."
diff --git a/tools/kdeservicemenu/sylpheed-kdeservicemenu.pl b/tools/kdeservicemenu/sylpheed-kdeservicemenu.pl
new file mode 100644 (file)
index 0000000..4ff144a
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+#  * Copyright 2004 Paul Mangan <claws@thewildbeast.co.uk>
+#  *
+#  * This file is free software; you can redistribute it and/or modify it
+#  * under the terms of the GNU General Public License as published by
+#  * the Free Software Foundation; either version 2 of the License, or
+#  * (at your option) any later version.
+#  *
+#  * This program is distributed in the hope that it will be useful, but
+#  * WITHOUT ANY WARRANTY; without even the implied warranty of
+#  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  * General Public License for more details.
+#  *
+#  * You should have received a copy of the GNU General Public License
+#  * along with this program; if not, write to the Free Software
+#  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+unless ($ARGV[0]) { exit; }
+
+$count = $#ARGV;
+
+($str,$strpt) = split_parts();
+
+if ($ARGV[0] eq "zip") {
+       exec "zip -r archive.zip $str;"
+           ."sylpheed --compose --attach \"archive.zip\"";
+} elsif ($ARGV[0] eq "tar") {
+       exec "tar -c -f archive.tar $str;"
+           ."sylpheed --compose --attach \"archive.tar\"";
+} elsif ($ARGV[0] eq "tarbz2") {
+       exec "tar -cj -f archive.tar.bz2 $str;"
+           ."sylpheed --compose --attach \"archive.tar.bz2\"";
+} elsif ($ARGV[0] eq "targz") {
+       exec "tar -cz -f archive.tar.gz $str;"
+           ."sylpheed --compose --attach \"archive.tar.gz\"";
+} elsif ($ARGV[0] eq "gzip") {
+       exec "gzip  $str;"
+           ."sylpheed --compose --attach $strpt";
+} elsif ($ARGV[0] eq "bzip2") {
+       exec "bzip2  $str;"
+           ."sylpheed --compose --attach $strpt";
+} elsif ($ARGV[0] eq "attachfile") {
+       exec "sylpheed --compose --attach $str";
+}
+exit;
+
+sub split_parts {
+       local $selectedParts = "";
+       local $sParts = "";
+       while ($count > 0) {
+               @s = split("/", $ARGV[$count]);
+               $count--;
+               $p = pop(@s);
+               $selectedParts .= "\"$p\" ";
+               if ($ARGV[0] eq "gzip") {
+                       $sParts .= "\"$p.gz\" ";
+               } elsif ($ARGV[0] eq "bzip2") {
+                       $sParts .= "\"$p.bz2\" ";
+               }
+       }
+       return ($selectedParts,$sParts);
+}
\ No newline at end of file
diff --git a/tools/kdeservicemenu/template_sylpheed-attach-files.desktop b/tools/kdeservicemenu/template_sylpheed-attach-files.desktop
new file mode 100644 (file)
index 0000000..8bc8564
--- /dev/null
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Actions=AttachFiles;GZipAndAttach;BZipAndAttach;
+Encoding=UTF8
+X-KDE-Submenu=Sylpheed
+ServiceTypes=all/allfiles
+
+[Desktop Action AttachFiles]
+Name=Attach File(s)
+Icon=sylpheed
+Exec=SCRIPT_PATH attachfile %F
+
+[Desktop Action GZipAndAttach]
+Name=Attach as GZip File(s)
+Icon=sylpheed
+Exec=SCRIPT_PATH gzip %F
+
+[Desktop Action BZipAndAttach]
+Name=Attach as BZip File(s)
+Icon=sylpheed
+Exec=SCRIPT_PATH bzip2 %F
diff --git a/tools/kdeservicemenu/template_sylpheed-compress-attach.desktop b/tools/kdeservicemenu/template_sylpheed-compress-attach.desktop
new file mode 100644 (file)
index 0000000..1142308
--- /dev/null
@@ -0,0 +1,25 @@
+[Desktop Entry]
+Actions=TarAndAttach;TarBzipAndAttach;TarGzipAndAttach;ZipAndAttach;
+Encoding=UTF8
+X-KDE-Submenu=Sylpheed
+ServiceTypes=all/all
+
+[Desktop Action TarAndAttach]
+Name=Attach as Tar Archive
+Icon=sylpheed
+Exec=SCRIPT_PATH tar %F
+
+[Desktop Action TarBzipAndAttach]
+Name=Attach as Bzipped Tar Archive
+Icon=sylpheed
+Exec=SCRIPT_PATH tarbzip2 %F
+
+[Desktop Action TarGzipAndAttach]
+Name=Attach as Gzipped Tar Archive
+Icon=sylpheed
+Exec=SCRIPT_PATH targz %F
+
+[Desktop Action ZipAndAttach]
+Name=Attach as Zip Archive
+Icon=sylpheed
+Exec=SCRIPT_PATH zip %F