| 1 | X tools, -*-text-*- |
| 2 | |
| 3 | |
| 4 | This is just a small collection of small X-based toys. There's |
| 5 | nothing especially clever here, just some stuff I've found to be |
| 6 | useful. It's a bit of a mixed bag, really; just saves me some |
| 7 | effort if I package them all up together. The collection may |
| 8 | grow in future, if I can be bothered to write any more X toys. |
| 9 | |
| 10 | A couple of the toys require GTK. Sorry: I like GTK and I don't |
| 11 | want to play with Athena or Xt or anything like that again, |
| 12 | because they're nasty. |
| 13 | |
| 14 | The tools are described more fully in the accompanying manual |
| 15 | pages. There's not much to know about any of them, though. |
| 16 | |
| 17 | |
| 18 | xgetline |
| 19 | |
| 20 | Pops up a little window (with configurable text in it) asking |
| 21 | the user to type in a piece of text, and then writes it to |
| 22 | stdout. It's useful when a shell script wants to solicit a |
| 23 | string from the user, and particularly handy in window manager |
| 24 | config files. You can also turn off echo of the string being |
| 25 | typed in, which may be useful for input of passwords, but that's |
| 26 | not ever-so recommended. |
| 27 | |
| 28 | The basic idea is that you say something like |
| 29 | |
| 30 | if name=`xgetline -p Name`; then |
| 31 | echo "Hello, $name, pleased to meet you!" |
| 32 | else |
| 33 | echo "You're no fun, are you?" |
| 34 | fi |
| 35 | |
| 36 | and everything is lovely. |
| 37 | |
| 38 | |
| 39 | xscsize |
| 40 | |
| 41 | Returns the size of an X display. The idea is that you can do |
| 42 | something like |
| 43 | |
| 44 | eval `xscsize` |
| 45 | |
| 46 | in a `.xinitrc' file and then play with XWIDTH and XHEIGHT to |
| 47 | decide exactly where to put various windows depending on how big |
| 48 | the screen is. This sort of thing is quite handy if you use the |
| 49 | same setup on lots of different systems or screens. |
| 50 | |
| 51 | |
| 52 | xwait, xtell, xshutdown |
| 53 | |
| 54 | The traditional thing to do at the end of a `.xinitrc' file is |
| 55 | to wait for the window manager to exit. This is unhelpful when |
| 56 | the window manager doesn't like its configuration file, for |
| 57 | example, because your entire session goes away. The idea |
| 58 | (filched shamelessly from SGI, actually) is to end the script |
| 59 | with a program which hangs around until told to go away by |
| 60 | another X client. (I could have used any old IPC mechanism |
| 61 | here, but it seemed silly to use something other than X.) |
| 62 | |
| 63 | The manual pages provide the low-level detail. Basically, |
| 64 | though, you run `xwait', and it sleeps. When you run `xtell', |
| 65 | it tells the `xwait' program to kill itself. `xshutdown' does |
| 66 | essentially the same thing, only it pops up a pretty window |
| 67 | asking you if you're sure before it does it. |
| 68 | |
| 69 | |
| 70 | Notes and things |
| 71 | |
| 72 | All the code here is released under the GNU General Public |
| 73 | License (included in the file COPYING in the distribution). |
| 74 | |
| 75 | I tested the code under Linux and not much else, but I'm usually |
| 76 | fairly conservative about portability and there shouldn't be |
| 77 | much hassle involved. |
| 78 | |
| 79 | If anyone wants to do an Xaw version of the GTK bits then I'll |
| 80 | include that in the distribution; people using Motif or Qt need |
| 81 | not apply. |
| 82 | |