xsay: add support for sselp and xclip; output error message
[grml-scripts.git] / usr_bin / grml-slrn
1 #!/bin/sh
2 # Filename:      grml-slrn
3 # Purpose:       configuration script for slrn
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Son Mär 18 17:23:34 CET 2007 [mika]
8 ################################################################################
9
10 PATH=${PATH:-'/bin/:/sbin/:/usr/local/bin:/usr/bin:/usr/sbin'}
11 PN=$(basename "$0")
12 USER=$(grep \`whoami\` /etc/passwd | cut -d: -f5 | cut -d, -f1)
13 HOST=$(hostname -f)
14
15 if [ -r /etc/grml/script-functions ] ; then
16    . /etc/grml/script-functions
17    check4progs dialog slrn || { echo "Sorry, can't continue. Exiting.">&2 ; exit 1 ; }
18 fi
19
20 [ -z "$EDITOR" ] && EDITOR='vim'
21 [ -z "$NNTPSERVER" ] && NNTPSERVER="news.`hostname`"
22
23 # some functions used in the interactive part
24 testfiles() {
25   [ -d $HOME/News ] || mkdir $HOME/News
26   [ -f $HOME/.slrn_scoring ] || touch $HOME/.slrn_scoring
27 }
28
29 writeslrnrc() {
30 cat > $SLRNRC << EOF
31 % Filename:      .slrnrc
32 % Purpose:       configuration for newsreader slrn, created by 'grml-slrn'
33 % Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
34 % Bug-Reports:   see http://grml.org/bugs/
35 % License:       This file is licensed under the GPL v2.
36 % Latest change: Son Nov 28 22:38:30 CET 2004 [mika]
37 %###############################################################################
38
39 %###############################################################################
40 % Ressources:
41 % TFM:                         http://slrn.sourceforge.net/manual/slrn-manual.html
42 % Andrew Preater's .slrnrc:    http://www.preater.f9.co.uk/slrn/slrnrc.gz
43 % Jurriaan's page:             http://www.xs4all.nl/~thunder7/
44 % Emmanuele's page:            http://digilander.libero.it/ebassi/slrn.html
45 % Sven's site:                 http://www.guckes.net/slrn/
46 % tsca's s-lang macros:        http://www.geocities.com/tsca.geo/slang.html
47 % Tomasz K³oczko's slrn-stuff: http://cvs.pld.org.pl/slrn-pl/
48 % Tomasz K³oczko's macros:     http://cvs.pld.org.pl/slrn-pl/macros
49 % jbn's S-Lang code:           http://forestfield.org/slrn/
50 % S-lang regexps:              http://www.s-lang.org/doc/html/slang-18.html
51 %###############################################################################
52
53 % important variables - adjust them if necessary
54   set username "$USERNAME_SLRN"
55   set hostname "$HOSTNAME_SLRN"
56   set realname "$REALNAME_SLRN"
57   set organization "www.grml.org"
58 % set replyto  "devnull@grml.org"
59
60 % set signature "signature_ng"
61 % set signoff_string "-mika-"
62
63   server "$NEWSSERVER"  ".newsrc_$NEWSSERVER"
64
65 % If a server requires authentication, add a nnrpaccess line for it.
66 % If you leave username and/or password empty, slrn will prompt for it.
67 % nnrpaccess "news.isp.tld" "username" "password"
68
69   set write_newsrc_flags 0
70
71   set generate_message_id 0
72   set generate_date_header 1
73   set read_active 1
74
75   set editor_command "$EDITOR -f +%d '%s'"
76   set mail_editor_command "mutt -H '%s'"
77   set score_editor_command "$EDITOR '%s'" % $HOME/.slrn_scoring"
78   set abort_unmodified_edits 1
79   set metamail_command "metamail"
80   set non_Xbrowser "screen -t 'url' $BROWSER %s"
81   set Xbrowser "screen -t 'url' $BROWSER %s"
82
83 % Command to use for printing
84 #ifdef UNIX
85         set printer_name "muttprint"
86 #elifdef WIN32
87         % set printer_name "MyPrinter"
88 #endif
89
90   set save_posts "News/My_Posts"
91   set save_replies "News/My_Replies"
92   set failed_posts_file "~/dead.letter"
93
94   set scorefile "$HOME/.slrn_scoring"
95   set decode_directory "News"
96   set save_directory "News"
97   set postpone_directory "News/postponed"
98   set followup_string "* %r <%f> wrote:"
99   set followup_strip_signature 0
100   ignore_quotes "^ *[a-zA-Z-]*>" "^ *[\]|)]" "^ *:[^-()^]"
101   set reply_string "* %r <%f> [%n]:
102   set cc_followup 1
103   set cc_post_string "[This message has also been posted to %n.]"
104
105   header_display_format 0 "%F%-5S%-5l: [%20r] %t %70s %-12g[%10d]"
106   header_display_format 1 "%F%G%-5l:[%12r]%t%s"
107   header_display_format 2 "%F%-5l:%t%s"
108   header_display_format 3 "%F%-5S%-5l:%t%50s %r"
109   header_display_format 4 "%F%-5S [%10r]:%t%49s %-19g[%17d]"
110
111 % How to display the groups index
112   group_display_format 0 "  %F%-5u  %n%45g%d"
113   group_display_format 1 "  %F%-5u [%-6t]  %n"
114   group_display_format 2 "  %F [%-5u|%-6t] %n%45g%d"
115   group_display_format 3 "  %F%-5u  %n%50g%-8l-%h"
116
117   set spoiler_display_mode 1
118
119   set use_mime 1
120 %  set charset isolatin
121 %  set mime_charset "iso-8859-15"
122
123   set sorting_method 5
124   set check_new_groups 1         % let slrn check for new newsgroups
125   set unsubscribe_new_groups 1   % new groups are unsubscribed by default
126
127   set beep 2
128   set new_subject_breaks_threads 0 % No, no!
129
130   visible_headers "Subject:,From:,Organization:,Newsgroups:,Date:,Followup-To:,Mail-Copies-To:,Reply-To:,Message-ID:,Supersedes:,User-Agent,Approved,X-Mailer,X-Newsreader:,X-Posting-Agent:,X-Http-User-Agent:,X-,!X-Trace:,!X-Complaints-To:,!X-Face:,!X-MSMail-Priority:,!X-MimeOLE:,!X-Priority:,!X-Accept-Language:"
131
132   set process_verbatim_marks 1
133   set simulate_graphic_chars 1
134   set display_cursor_bar 0
135   set scroll_by_page 0
136   set color_by_score 3
137   set highlight_unread_subjects 2
138   set highlight_urls 1
139   set confirm_actions 31   % 1 & 2 & 4 & 8 & 16
140   set warn_followup_to 2
141   set emphasized_text_mask 1 % message only
142   set emphasized_text_mode 3 % Display text as text!
143   set query_next_article 0 % Very annoying until I turned it off.
144   set wrap_flags 7  % _Automatically_ wrap quoted material and body
145   set wrap_method 2
146 EOF
147 }
148
149 lightcolors() {
150 cat >> $SLRNRC << EOF
151
152 % color setup
153 color article              "blue"         "white"
154 color author               "red"          "white"
155 color boldtext             "black"        "white"
156 color box                  "black"        "white"
157 color cursor               "yellow"       "red"
158 color date                 "brightblue"   "black"
159 color description          "black"        "white"
160 color error                "red"          "white"
161 color frame                "yellow"       "blue"
162 color from_myself          "brightred"    "black"
163 color group                "blue"         "white"
164 color grouplens_display    "yellow"       "red"
165 color header_name          "green"        "white"
166 color header_number        "green"        "white"
167 color headers              "blue"         "white"
168 color high_score           "brightred"    "white"
169 color italicstext          "magenta"      "white"
170 color menu                 "yellow"       "red"
171 color menu_press           "blue"         "yellow"
172 color message              "black"        "white"
173 color neg_score            "magenta"      "white"
174 color normal               "black"        "white"
175 color pgpsignature         "brown"        "white"
176 color pos_score            "blue"         "white"
177 color quotes               "red"          "white"
178 color quotes1              "magenta"      "white"
179 color quotes2              "brown"        "white"
180 color quotes3              "red"          "white"
181 color quotes4              "brown"        "white"
182 color quotes5              "blue"         "white"
183 color quotes6              "black"        "white"
184 color quotes7              "brown"        "white"
185 color response_char        "green"        "white"
186 color selection            "yellow"       "white"
187 color signature            "black"        "white"
188 color status               "yellow"       "red"
189 color subject              "black"        "white"
190 color thread_number        "blue"         "white"
191 color tilde                "green"        "white"
192 color tree                 "red"          "white"
193 color underlinetext        "cyan"         "white"
194 color verbatim             "red"          "white"
195
196 % This color object is only used when highlight_unread_subjects is set to 2
197 % (see the reference manual for details)
198 color unread_subject    "red"        "white"
199 mono  unread_subject    "bold"
200
201 % These attributes are for terminals that cannot display color:
202 mono article            "none"
203 mono author             "none"
204 mono boldtext           "bold"
205 mono cursor             "bold"  "reverse"
206 mono date               "none"
207 mono description        "none"
208 mono error              "blink" "bold"
209 mono frame              "reverse"
210 mono from_myself        "bold"
211 mono group              "bold"
212 mono grouplens_display  "none"
213 mono header_number      "none"
214 mono headers            "bold"
215 mono high_score         "bold"
216 mono italicstext        "bold"
217 mono menu               "reverse"
218 mono menu_press         "none"
219 mono normal             "none"
220 mono pgpsignature       "none"
221 mono quotes             "underline"
222 mono quotes1            "underline"
223 mono quotes2            "underline"
224 mono quotes3            "underline"
225 mono quotes4            "underline"
226 mono quotes5            "underline"
227 mono quotes6            "underline"
228 mono quotes7            "underline"
229 mono response_char      "bold"
230 mono selection          "bold"  
231 mono signature          "none"
232 mono status             "reverse"
233 mono subject            "none"
234 mono thread_number      "bold"
235 mono tree               "bold"
236 mono underlinetext      "underline"
237 mono url                "bold"
238 mono verbatim           "none"
239 EOF
240 }
241
242 # FIXME TODO
243 darkcolors() {
244 cat >> $SLRNRC << EOF
245 % dark color setup
246 % ....
247 EOF
248 }
249
250 infoscreen() {
251 dialog --stdout --title "$PN" --msgbox "Thanks for using $PN!
252
253 More information on slrn:
254
255 Manual: man 1 slrn
256
257 Webpages:
258 www.slrn.org
259 www.michael-prokop.at/slrn/
260
261 #######################################################
262
263 Report bugs, send wishes and feedback to the grml team:
264 http://www.grml.org/ - contact (at) grml.org
265 " 20 65
266 }
267
268 # interactive part
269 dialog --stdout --title "$PN" --msgbox "Welcome to $PN!
270
271 This script will create a simple base
272 configuration for the newsreader slrn.
273
274 Report bugs, send wishes and feedback to the grml team:
275 http://www.grml.org/ - contact (at) grml.org
276 " 13 65
277
278 GETREALNAME_SLRN=$(dialog --stdout --title "$PN" --inputbox "Your real name (eg 'John GRML User'):" 0 65 "$USER" ) || exit 0
279 REALNAME_SLRN=${GETREALNAME_SLRN%/*}
280
281 GETMAILADDR=$(dialog --stdout --title "$PN" --inputbox "Your main mail address (eg 'joedoe@grml.org'):" 0 65 `whoami`@$HOST ) || exit 0
282 MAILADDR=${GETMAILADDR}
283 USERNAME_SLRN=$(echo "$MAILADDR" | sed "s/@.*//")
284 HOSTNAME_SLRN=$(echo "$MAILADDR" | sed "s/.*@//")
285
286 GETNEWSSERVER=$(dialog --stdout --title "$PN" --inputbox "What's the newsserver you want to use?
287 (eg 'news."$HOSTNAME_SLRN"'):" 8 65 "$HOST" ) || exit 0
288 NEWSSERVER=${GETNEWSSERVER}
289
290 GETCOLOR=$(dialog --stdout --title "$PN" \
291           --radiolist "Which color setup do you want to use?" 10 65 2 \
292           dark   "dark color setup (default)" on \
293           light  "light color setup" off)
294 retval=$?
295 case $retval in
296   0) COLOR=$GETCOLOR ;;
297   *) exit 1 ;;
298 esac
299
300 writecolors() {
301   if [ "$COLOR" = 'light' ] ; then
302     lightcolors
303   fi
304   if [ "$COLOR" = 'dark' ] ; then
305     darkcolors
306   fi
307 }
308
309 GETSLRNRC=$(dialog --stdout --title "$PN" --inputbox "Choose a filename for this configuration:" 0 65 "$HOME/.slrnrc") || exit 0
310 SLRNRC=${GETSLRNRC}
311
312 WRITESLRNRC=$(dialog --stdout --title "$PN" --yesno "Write $SLRNRC?" 5 65)
313 retval=$?
314
315 case $retval in
316   0) 
317     if [ -f "$SLRNRC" ] ; then
318       dialog --stdout --title "$PN" --yesno "$SLRNRC exists. Overwrite?" 5 65
319       retval=$?
320       case $retval in
321         0) 
322           writeslrnrc && writecolors && \
323           dialog --stdout --title "$PN" --msgbox "Writing $SLRNRC was successful." 7 65 || \
324           { dialog --stdout --title "$PN" --msgbox "Error $?: writing $SLRNRC failed." 7 65 ; exit 1 ; }
325           ;;
326       esac
327     else
328        writeslrnrc && writecolors && \
329        dialog --stdout --title "$PN" --msgbox "Writing $SLRNRC was successfull." 7 65 || \
330        { dialog --stdout --title "$PN" --msgbox "Error $?: writing $SLRNRC failed." 7 65 ; exit 1 ; }
331     fi
332     ;;
333 esac
334
335 infoscreen
336
337 ASKRUN=$(dialog --stdout --title "$PN" --yesno "Run slrn now?" 0 0)
338 retval=$?
339
340 case $retval in
341   0) 
342      slrn -create -h $NEWSSERVER -f $HOME/.newsrc_$NEWSSERVER -i $SLRNRC && \
343      echo "
344 Start slrn with taken settings via:
345 % slrn -h $NEWSSERVER -f $HOME/.newsrc_$NEWSSERVER -i $SLRNRC
346
347 Thanks for using $PN and have fun with slrn!"
348      ;;
349 esac
350
351
352 ## END OF FILE #################################################################