Thursday, August 2, 2007
Tips and Tricks for X-Window
.xinitrc
This is a file you'll find in your user directory. You can use it to start programs automatically when you start X-window. Open the file with vi or the text editor of your choosing. Then, for example, add:
xclock -bg wheat -geometry 100x100+1+1 &
-bg sets the background color and the -geometry setting I have used here gives you a fairly small, but not too small clock in the upper left hand corner of your desktop. You can type: man xclock to see more options. Experiment with options first before you put your definitive xclock settings in your .xinitrc file. Just type your settings into an xterm and try different ones. Type: killall xclock to shut off the clock each time.
.Xdefaults file
There's another file in your user directory called .Xdefaults. You can use this file to change the way some of your X-window applications look. It's fun to try out different styles and get some settings that please your eye. Before you try to do this however, make a backup. Type:
cp .Xdefaults .Xdefaults_good
because there is always some danger of making some applications non-operable because you have left spaces where you shouldn't. It is important when you change settings that you leave no trailing spaces. Most major distributions provide a working .Xdefaults file. It's best to leave what you find there, but you're free to add stuff to it.
As an example, let's change the look of emacs, for example.
First, open up the file with Vi or any text editor your prefer. Add this to it:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! emacs changes [date]
emacs*Background: DarkCyan
emacs*Foreground: Khaki
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Let's explain what we've done here. First, the exclamation point (!) in this file is used to make comments. The two rows of exclamation points I've used to show where my emacs section begins and ends. Then I use two to comment that I am changing emacs and I have included [date] where I would put the actual date to show when I made the changes. You don't have to do this. It's just something extra to remind me when I made the changes. Then we make the actual changes.
With: emacs*background: DarkCyan we can change the background of the application's menu bar and frame. You can use any color you like that the system supports.
With: emacs*Foreground: Khaki we've changed the color of the words in the menu.
To make the changes take effect, you have to issue this command in an xterm:
xrdb -merge $HOME/.Xdefaults
This will restart the x-server database and log in your changes. If you don't do this, X-window keeps your old .Xdefaults in memory and you won't see anything new. Restart emacs and you should see your new colors. If emacs doesn't come up, you may have left some trailing white space. If that is the case, just type emacs in an xterm and an error message should appear saying something like: Warning: Color name "khaki " is not defined or similar. If you see a space before the second quotation mark, then you've got whitespace in your .Xdefaults file that needs to be eliminated.
As you get more adept at changing things, you'll make your desktop more to your liking.
xwininfo
If you're interested in seeing a bit of information about certain programs running, you can type xwininfo into a terminal and then click on any window. For example, I had another xterm open and I clicked on it and got this info:
xwininfo: Window id: 0x2c0000e "xterm"
Absolute upper-left X: 211
Absolute upper-left Y: 132
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 581
Height: 340
Depth: 16
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +211+132 -8+132 -8-128 +211-128
-geometry 80x24-3+109
This comes in handy especially to find suitable '-geometry' settings for use in starting up applications and including them in the .xinitrc file.
xset
This is a command line utility to control things like your mouse, keyboard, monitor and pc speaker. Both GNOME and KDE have other graphic apps to do this stuff a lot easier, so I find myself using this less and less. But you can try it out. For example, type: xset b off to stop your computer from beeping at it. And to turn it back on? You guessed it: xset b on. You can also change the tone by typing something like: xset b 30 550 300 The first number is for volume, the second pitch and the third duration of the beep.
xsetroot
In a previous section, we told you how to use xv to put your favorite picture on your desktop. If you get tired of pictures and you want something plain, you can use xsetroot to just put a color scheme on the desktop. For example, typing: xsetroot -solid seagreen will get you a solid dark green color as a background. This one is soothing to the eyes. It's the same color used on pool and card tables. Of course, you're free to use the color you like! Type: man xsetroot to see other options.
This is a file you'll find in your user directory. You can use it to start programs automatically when you start X-window. Open the file with vi or the text editor of your choosing. Then, for example, add:
xclock -bg wheat -geometry 100x100+1+1 &
-bg sets the background color and the -geometry setting I have used here gives you a fairly small, but not too small clock in the upper left hand corner of your desktop. You can type: man xclock to see more options. Experiment with options first before you put your definitive xclock settings in your .xinitrc file. Just type your settings into an xterm and try different ones. Type: killall xclock to shut off the clock each time.
.Xdefaults file
There's another file in your user directory called .Xdefaults. You can use this file to change the way some of your X-window applications look. It's fun to try out different styles and get some settings that please your eye. Before you try to do this however, make a backup. Type:
cp .Xdefaults .Xdefaults_good
because there is always some danger of making some applications non-operable because you have left spaces where you shouldn't. It is important when you change settings that you leave no trailing spaces. Most major distributions provide a working .Xdefaults file. It's best to leave what you find there, but you're free to add stuff to it.
As an example, let's change the look of emacs, for example.
First, open up the file with Vi or any text editor your prefer. Add this to it:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! emacs changes [date]
emacs*Background: DarkCyan
emacs*Foreground: Khaki
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Let's explain what we've done here. First, the exclamation point (!) in this file is used to make comments. The two rows of exclamation points I've used to show where my emacs section begins and ends. Then I use two to comment that I am changing emacs and I have included [date] where I would put the actual date to show when I made the changes. You don't have to do this. It's just something extra to remind me when I made the changes. Then we make the actual changes.
With: emacs*background: DarkCyan we can change the background of the application's menu bar and frame. You can use any color you like that the system supports.
With: emacs*Foreground: Khaki we've changed the color of the words in the menu.
To make the changes take effect, you have to issue this command in an xterm:
xrdb -merge $HOME/.Xdefaults
This will restart the x-server database and log in your changes. If you don't do this, X-window keeps your old .Xdefaults in memory and you won't see anything new. Restart emacs and you should see your new colors. If emacs doesn't come up, you may have left some trailing white space. If that is the case, just type emacs in an xterm and an error message should appear saying something like: Warning: Color name "khaki " is not defined or similar. If you see a space before the second quotation mark, then you've got whitespace in your .Xdefaults file that needs to be eliminated.
As you get more adept at changing things, you'll make your desktop more to your liking.
xwininfo
If you're interested in seeing a bit of information about certain programs running, you can type xwininfo into a terminal and then click on any window. For example, I had another xterm open and I clicked on it and got this info:
xwininfo: Window id: 0x2c0000e "xterm"
Absolute upper-left X: 211
Absolute upper-left Y: 132
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 581
Height: 340
Depth: 16
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +211+132 -8+132 -8-128 +211-128
-geometry 80x24-3+109
This comes in handy especially to find suitable '-geometry' settings for use in starting up applications and including them in the .xinitrc file.
xset
This is a command line utility to control things like your mouse, keyboard, monitor and pc speaker. Both GNOME and KDE have other graphic apps to do this stuff a lot easier, so I find myself using this less and less. But you can try it out. For example, type: xset b off to stop your computer from beeping at it. And to turn it back on? You guessed it: xset b on. You can also change the tone by typing something like: xset b 30 550 300 The first number is for volume, the second pitch and the third duration of the beep.
xsetroot
In a previous section, we told you how to use xv to put your favorite picture on your desktop. If you get tired of pictures and you want something plain, you can use xsetroot to just put a color scheme on the desktop. For example, typing: xsetroot -solid seagreen will get you a solid dark green color as a background. This one is soothing to the eyes. It's the same color used on pool and card tables. Of course, you're free to use the color you like! Type: man xsetroot to see other options.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment