File: fvwm.html

package info (click to toggle)
lg-issue21 6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 900 kB
  • ctags: 108
  • sloc: makefile: 34; sh: 34
file content (287 lines) | stat: -rw-r--r-- 10,580 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>Fvwm Configuration in Different Environments using cpp Issue 21</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0020F0"
ALINK="#FF0000">
<!--endcut ============================================================-->

<H4>
&quot;Linux Gazette...<I>making Linux just a little more fun!</I>&quot;
</H4>

<P> <HR> <P> 
<!--===================================================================-->

<center>
<H2>Fvwm Configuration in Different Environments using cpp</H2>
<H4>By Gerd Bavendiek,
<a href="mailto:bav@rw.sni.de">bav@rw.sni.de</a></H4>
</center>
<P><HR><P>
<h1>Do you use Linux at home ? In the office ? On a laptop ? 
Do you use fvwm 2.xx or fvwm95 as your windowmanager ?</h1>

If yes, you should read on.
      <p>
	Perhaps you have read my article about <a
	  href="../issue20/laptop.html">Using a 
	  Laptop in Different Environments</a>. There I described an
	  easy way to setup a Linux laptop to boot into different
	  network configurations. I mentioned that setting up a shell
	variable called <code>PROFILE</code> is useful not only for
	configuring the network but also the windowmanager.


<h2>Why should you do that ?</h2>

Your windowmanager needs to be configured quite different when you are
using it on a laptop with 600x420 pixel or on a 17&quot;-monitor with
1024x768 pixel. This is a rather basic difference - there may be
others. Think of using your system in a network environment. There it
will be handy to have a taskbar labeled appropiate to <code>rlogin</code>-sessions.

After fiddling some time with patching different
fvwm configuration files on different machines I found this to be a
pain. A typical <code>.fvwm95rc</code> is about 900 lines. Keeping several of them
in sync is not the thing I like.

<h2>Generating ~/.fvwm95rc using cpp</h2>

My solution is simple: Use <code>cpp</code>, the C-preprocessor ! fvwm 2.xx as well
as fvwm95 are configured by a central file.  fvwm95 is derived from
fvwm, so the basic idea applies to both. Let me show you the details
using fvwm95. I keep my fvwm95 configuration in the file <code>~/.fvwm95rc-cpp</code>.
      <p>
You can use the system default setup in
<code>/etc/X11/fvwm95/system.fvwm2rc95</code> as starting point.

Look at this code fragment from my <code>.xinitrc</code> (For me, <code>.xsession</code> is
linked to <code>.xinitrc</code>):

<pre>
...
# I need the value of PROFILE for generating .fvwm95rc
# netenv contains an assignment like e.g. PROFILE=32
if [ -r /tmp/netenv ]; then
. /tmp/netenv
fi

# Now the actual .fvwm95rc is generated depending on the value of PROFILE
cpp -lang-c++ -D PROFILE=$PROFILE ~/.fvwm95rc-cpp ~/.fvwm95rc

exec fvwm95 # exec saves the extra memory for a no longer useful shell ...
...
</pre>
      
      The shell variable <code>PROFILE</code> contains the information about the current
      environment. The file <code>/tmp/netenv</code> is set up by <code>init</code> when going to run
      level 2. I described this in the article mentioned above.

Obviously you need <code>cpp</code>, which comes either as an extra package or as
part of <code>gcc</code>. Yes, I know that there is a module <code>FvwmCpp</code> (which calls
<code>cpp</code>) - but I never managed to get it work.
      <p>
      
      One advantage of the old-fashioned style of configuration files is
      that you can put comments in. <i>You really should do this !</i> All that
      hidden dot files in your home directory make up your personal
      environment (these files will never be touched by a system
      update). Having comments will make it easier to maintain this 
	environment.<p>
 <code>system.fvwm95rc</code> comes in shell style comment syntax (so does
 fvwm). You can't feed this into <code>cpp</code>. I didn't like
      traditional c-style comments in a configuration file, so I switched
      all these comment lines
      
      <pre>
# this is a useful comment
      </pre>

      into c++-style comments
      
      <pre>
// this is a useful comment
      </pre>
      
      (hail emacs !). Calling <code>cpp</code> with 

      <pre>
-lang-c++
      </pre>

      tells <code>cpp</code> to preprocess c++-code. A hint for those, who are not
      familiar with <code>cpp</code>: <code>cpp</code> strips off the comment lines of the input
      file. You probably will get output with a lot of blank lines.


<h2>Examples how to use cpp-syntax</h2>

      Now let us have a look inside my <a href="../issue21/fvwm95rc-cpp.html"><code>.fvwm95rc-cpp</code></a>.
      Of course, everything herein is strongly a matter of personal taste.
      <p>
	I don't like to stress my eyes. So I hate small letters, I barely can
	read them in the evening of a long day ... So my desktop has 4x2 pages.
	Each page is assigned to one application (or a few). I use
	<code>&lt;Alt&gt;&lt;F1&gt;</code> to <code>&lt;F8&gt;</code> to 
	switch quickly between pages. Using the fabulous fvwm95 mini icons my
	screen holds the <code>FvwmTaskBar</code> and on the right hand side a column
	holding some icons. This way I can maximize the application window.
      <p>
	The <a href="./gx/fvwm/page-1.gif">screenshot</a> should make it clear.


<h3>Defining geometry</h3>

      One important application is xemacs for me. So I define a mini button
      in the <code>FvwmButtons</code> section like this:
      
      <pre>
*MiniButtons -   mini-edit.xpm        Exec  "Xemacs" /usr/bin/xemacs \
                                      -geometry EMACS_GEO &
      </pre>
      
      <code>EMACS_GEO</code> is to be substituted by
      <code>cpp</code>. I put all the <code>#define</code> in the 
      beginning of my <code>.fvwm95rc-cpp</code>. Basically it reads like this
      
      <pre>
#if PROFILE == 30 || PROFILE == 31 || PROFILE == 32 
#define EMACS_GEO 80x25+0+480
#else
#define EMACS_GEO 96x31+0+767
#endif
      </pre>
      
      Whenever I'm on my laptop, <code>PROFILE</code> equals 30, 31
      oder 32 (at home, in the office, on customers site). The
      LCD-Display has 600x420 pixel. My other systems have 17&quot; monitors and
      there I use 1024x768. The +0+480 or +0+767 pops up the xemacs window
      on the leftmost page on the bottom row of my 4x2 desktop. But this is
      true only when being on the very first page while clicking the
      icon. I'm shure, this could be improved.
      <p>

      With defining

      <pre>
Key F5		A	M	GotoPage 0 1
      </pre>
      
      I can conveniently switch to my xemacs window using <code><ALT><F5></code> without
      leaving the keyboard.
      
      
      <h3>Launching applications</h3>
      
      
Being at home or in the office, I have usually some <code>rlogin</code> sessions to
      some well known machines. Being on a customers site I frequently have
      to work with high availability configurations mostly consisting of two
      machines. I call them always abba and bebe. See how this can be set
      up (shortened for clarity):

<pre>
DestroyFunc "InitFunction" 
#if PROFILE == 30
AddToFunc "InitFunction" \
  "I" Exec xsetroot -solid turquoise4 -cursor_name top_left_arrow &
+ "I" Exec xconsole -font 6x10 -geometry XCONSOLE_GEO -sb -file /dev/xconsole &
+ "I" Exec rxvt -geometry 94x28+0+0 -fn DEF_FONT -ls -sb -vb \ 
                          -title TERMWIN_ID1 -n TERMWIN_ID1 -cr Yellow3 &
+ "I" Exec rxvt -geometry TERMWIN_GEO2 -fn DEF_FONT -ls -sb  -vb \
                          -title TERMWIN_ID2 -n TERMWIN_ID2 -cr Red3 &
+ "I" Exec rxvt -geometry TERMWIN_GEO3 -fn DEF_FONT -ls -sb  -vb \
                          -title TERMWIN_ID3 -n TERMWIN_ID3 -cr Magenta3 &
+ "I" Module FvwmButtons MiniButtons
+ "I" Module FvwmTaskBar
+ "I" Module FvwmAuto 700
+ "I" Module FvwmPager 0 0
#elif PROFILE == 10
...
#else
AddToFunc "InitFunction" \
...
...
+ "I" Exec rxvt -geometry 94x28+0+0 -fn DEF_FONT -ls -sb -vb \
                          -title TERMWIN_ID1 -n home -cr Yellow3 &
+ "I" Exec rxvt -geometry TERMWIN_GEO2 -fn DEF_FONT -ls -sb  -vb \
                          -title TERMWIN_ID2 -n TERMWIN_ID2 -cr Red3 &
+ "I" Exec rxvt -geometry TERMWIN_GEO3 -fn DEF_FONT -ls -sb  -vb \
                          -title TERMWIN_ID3 -n TERMWIN_ID3 -cr Magenta3 &
+ "I" Exec rxvt -geometry TERMWIN_GEO4 -fn DEF_FONT -ls -sb  -vb \
                          -title TERMWIN_ID4 -n TERMWIN_ID4 -cr Green3 &
+ "I" Exec rxvt -geometry TERMWIN_GEO5 -fn DEF_FONT -ls -sb  -vb \
                          -title TERMWIN_ID5 -n TERMWIN_ID5 -cr Blue3 &
...
...
#endif
</pre>
		<p>

The terminal geometry und identifiers are defined as follows:
		<p>

<pre>
#if PROFILE == 10
#define TERMWIN_ID1 bav@nana
#define TERMWIN_ID2 nana
#define TERMWIN_ID3 lulu
#elif PROFILE == 20
...
#elif PROFILE == 30
...#define TERMWIN_ID1 bav@lulu
#elif PROFILE == 31
...
#elif PROFILE == 32
#define TERMWIN_ID1 bav@lulu
#define TERMWIN_ID2 lulu
#define TERMWIN_ID3 abba
#define TERMWIN_ID4 bebe
#define TERMWIN_ID5 abba
#endif
</pre>


<h2>Conclusion</h2>

Screen geometry and network environment differ from one machine to
      another. Everyone, who wants to have <b>one</b>
      configuration file for his fvwm 2.xx or fvwm95 to reflect these
      differences, should consider to use <code>cpp</code> as shown.
      <p>
 Perhaps you know, that <code>xrdb(1)</code> also can
      make use of <code>cpp</code>. So 
      you can preprocess your <code>~/.Xdefaults</code> achieving the discussed advantages.
      <p>
I hope you will find these ideas somehow useful !
      <p>
	Kind regards
      <p>
	Gerd
      <hr>
      <address><a href="mailto:bav@rw.sni.de">Gerd Bavendiek</a></address>


<!--===================================================================-->
<P> <hr> <P> 
<center><H5>Copyright &copy; 1997, Gerd Bavendiek<BR> 
Published in Issue 21 of the Linux Gazette, September 1997</H5></center>

<!--===================================================================-->
<P> <hr> <P> 
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif" 
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./ext2.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./impress.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P> 
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->