3 # * Copyright © 2001 Paul Mangan <claws@thewildbeast.co.uk>
5 # * This file is free software; you can redistribute it and/or modify it
6 # * under the terms of the GNU General Public License as published by
7 # * the Free Software Foundation; either version 2 of the License, or
8 # * (at your option) any later version.
10 # * This program is distributed in the hope that it will be useful, but
11 # * WITHOUT ANY WARRANTY; without even the implied warranty of
12 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # * General Public License for more details.
15 # * You should have received a copy of the GNU General Public License
16 # * along with this program; if not, write to the Free Software
17 # * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Script Name: The Nasnas
23 ######################################################
24 ######################################################
26 ### FOR USAGE INSTRUCTIONS RUN THIS SCRIPT WITH ###
27 ### THE FOLLOWING OPTION: ###
29 ### ./sylpheed-switcher --help ###
31 ######################################################
32 ######################################################
44 GetOptions("main" => \$sylpheed,
46 "main-path=s" => \$sylphpath,
47 "claws-path=s" => \$clawspath,
49 "help" => \$YouWantHelp);
51 chdir; ## use $HOME for the working directory
53 unless (-e ".sylpheed") { ## check for the .sylpheed directory
54 print "Your '.sylpheed' directory is missing. This probably means that ";
55 print "you have never run sylpheed before.\n";
56 print "Before running sylpheed-switcher run sylpheed normally at least once.\n";
60 open (SYLSWIT, "<.sylpheed-switcher"); ## read the config file
61 @conf_file = <SYLSWIT>;
64 if ($sylphpath && $clawspath) { ## this is the initial set-up part
65 ## write the config file
66 $PATH_INFO = "$clawspath\n$sylphpath";
67 open (CONFFILE, ">.sylpheed-switcher");
68 print CONFFILE $PATH_INFO;
70 ## it appears that you'd run this script before, but the config file was missing
71 $DIR_CHECK = opendir(CHECKDIR, ".sylpheed-claws");
73 if ($DIR_CHECK == 1) {
74 print "\nNow you can run either the main branch or the claws\n";
75 print "branch by using one of the following options:\n\n";
76 print "./sylpheed-switcher --main\n./sylpheed-switcher --claws\n\n";
79 ## copy the directory tree
80 system "cp -R .sylpheed .sylpheed-main";
81 system "cp -R .sylpheed .sylpheed-claws";
82 ## when setting-up is done print a little message
83 print "\nNow you can run either the main branch or the claws\n";
84 print "branch by using one of the following options:\n\n";
85 print "./sylpheed-switcher --main\n./sylpheed-switcher --claws\n\n";
88 ## the --help option stuff
90 print "\n The SYLPHEED<->CLAWS SWITCHER\n\n";
91 print "If you are running this script for the first time you will need \n";
92 print "to set up the configuration. Here is an example, adjust the paths\n";
93 print "to suit your set-up, but remember you need the full path with the\n";
94 print "executable included:\n";
95 print "./sylpheed-switcher --main-path=/usr/local/bin/sylpheed --claws-path=/usr/bin/sylpheed\n\n";
96 print "When you have done the initial set-up, you run either the main branch\n";
97 print "or the claws branch by using one of the following switches:\n\n";
98 print "./sylpheed-switcher --main\n./sylpheed-switcher --claws\n\n";
99 print "Add --debug to run sylpheed in debug mode\n\n";
102 ## if the config file doesn't exist...
104 print "Use the following set-up options first, or --help for more info:\n";
105 print "--claws-path=PATH # path to (and including) the claws sylpheed executable\n";
106 print "--main-path=PATH # path to (and including) the main sylpheed executable\n";
109 ## check that the chosen execuatble exists
110 ## get rid of the old symbolic link, make a new one, and run the required executable
113 unless (-e $conf_file[0]) {
114 print "\n$conf_file[0] does not exist\n\n";
118 symlink(".sylpheed-claws",".sylpheed");
120 exec "$conf_file[0] --debug";
122 exec "$conf_file[0]";
125 } elsif ($sylpheed) {
127 unless (-e $conf_file[1]) {
128 print "\n$conf_file[1] does not exist\n\n";
132 symlink(".sylpheed-main",".sylpheed");
134 exec "$conf_file[1] --debug";
136 exec "$conf_file[1]";
139 } elsif (!$claws && !$sylpheed && @conf_file) { ## you've got the config file but haven't said
140 print "\nUse one of the following switches:\n"; ## which version you want to run
141 print " --main # to run sylpheed main\n";
142 print " --claws # to run sylpheed claws\n";
143 print " --help # to view the help message\n";
144 print "Optionally, you can also use:\n";
145 print " --debug # to run in debug mode [optional]\n\n";
148 ###############################