]> sipb.mit.edu Git - wiki.git/blob - doc/barnowl_random_zsigs.mdwn
(no commit message)
[wiki.git] / doc / barnowl_random_zsigs.mdwn
1 [[!meta title="Random Zsigs for Barnowl"]]
2
3 ## Random Zsigs for Barnowl
4
5 First off, if you haven't already, take a look at Barnowl's internal documentation. Try the following two commands.
6         
7         :help
8         :show quickstart
9         
10 (Also viewable outside of Barnowl, in the form of messier-to-read source code, at [/help.c - barnowl - Trac](http://barnowl.mit.edu/browser/help.c) and the "intro" file at [/docs/intro.txt - barnowl - Trac](http://barnowl.mit.edu/browser/doc/intro.txt),
11
12 ### Intro to Zsigs
13 A "zsig" appears after your username (your Athena account name) in Zephyr (see [Using Zephyr (a.k.a. Zephyr for Dummies)](http://sipb.mit.edu/doc/zephyr) if you don't know what Zephyr is). 
14
15 By default, if your name is Jane Lillian Doe, your zsig is `(Jane L Doe)`. For instance, if you're on Zephyr, you might see
16
17         2013 / personal / jdoe  22:16  (Jane L Doe)
18                 ...hey I'm talking here.
19                 
20 Most people keep it that way, since people may not immediately know who you are by your username. Some people opt to remove the middle initial or leave it at an interesting quote. To do so, in Barnowl simply type in
21
22         :set zsig  "This is a very interestin' quote."
23         
24 (Barnowl accepts either single or double quotes to enclose your zsig, allowing you to use the other type of quote inside your zsig. Experiment, Barnowl tells you what it interpreted your command as by showing as confirmation
25
26         zsig = 'This is a very interestin' quote.'
27         
28
29
30 ### Random Zsig Generator
31 But what if you want to set up a random zsig generator?
32
33 In outline, you write some code that prints a zsig out to `stdout`, then set up Barnowl to run that code, take the [stdout](http://en.wikipedia.org/wiki/Stdout#Standard_output_.28stdout.29), and [pipe](http://en.wikipedia.org/wiki/Unix_pipe) it into your zsig. 
34 (If you're not sure what piping or stdout is, just follow along--the wikipedia articles are kind of technical. Otherwise you probably already know everything you need to know and can stop reading this).
35
36 #### Steps Outside of Barnowl: Creating the zsigs file and the zrandom program
37 Connect to Athena if you haven't already.
38
39 1. Create a file of zsigs. In this article we'll call the file `.zsigs`
40
41 2. Put zsigs in the file, separated by newlines
42         
43                 a zsig
44                 random zsig2
45                 random234
46                 
47 3. Now create a file to store your code, named for instance  `.zrandom`
48
49 4. Write a program that randomly picks zsigs from your file and prints them out (to stdout), for instance:
50
51                 #!/usr/athena/bin/python
52                 import random
53                 zfile = open('.zsigs')
54                 linelist = zfile.read().splitlines()
55                 zfile.close()
56                 print random.choice(linelist)
57         
58         If you want to use another language (e.g. perl or C), or check out what version is running on Athena, see [What Runs Where on Athena: Languages - IS&T] (http://web.mit.edu/acs/www/languages.html) and just swap out the first line with the language you want. See also [Random Zsigs - iZephyr](http://stuff.mit.edu/afs/sipb/project/doc/izephyr/html/node35.html) for more example programs (note the instructions are outdated).
59
60 5. If you want to, test your program.
61
62                 kusername@dr-wily:~$ python .zrandom
63                 random zsig2
64         
65         The second line should be one of the zsigs from your list. Run it multiple times if you want to check for randomness.
66         
67
68 #### Setting Up Barnowl: Using the zsigproc variable
69 ##### Background
70 Open up Barnowl now.
71         
72         kusername@dr-wily:~$ add barnowl; barnowl
73
74 Using the command `:show variables` inside of Barnowl we see descriptions of the variables of interest to us:
75         
76         zsig - zephyr signature (default: '')
77         zsigproc - name of a program to run that will generate zsigs (default: '<null>')     
78
79 To get more detailed descriptions we can use, respectively
80
81         :show variable zsig
82         :show variable zsigproc
83
84 We will also use the `:startup` command, which is described in
85
86         :help startup
87         
88 ##### The Steps
89
90 1. Use the `:startup` command in Barnowl to write to the "~/.owl/startup" file (or wherever you decided to put the your startup settings file for Barnowl). (Alternatively, edit the "~/.owl/startup" file directly). As mentioned in the detailed documentation, the variable `zsig` takes precedence over `zsigproc`. Make sure that `zsig` is empty. Then set `zsigproc` to your random zsig generator program's location.
91
92                 :startup set zsig ''
93                 :startup set zsigproc '~/.zrandom']
94         
95 2. Force Barnowl to reload the startup configuration file
96
97                 :source "~/.owl/startup"
98                 
99 3. Optional: Check that the correct startup file is loaded
100
101                 :show startup
102                 
103 Now you have random zsigs.