|
SummaryThe initial Ubuntu configuration will determine the ease and flexibility available when modifying the operating system. A right decision at the beginning can make everything else easier. The questions addressed in this chapter include:
Chapter 2 covers the post-installation environment and discusses things that you might want to change after you first log in. In Chapter 3, you'll learn how to configure the different types of devices and peripherals that you may want to use with your system.
|
|
Chapter 2: Making Ubuntu UsableThe basic install of Ubuntu provides a usable system. But usable is not the same as optimal . When you first log into the system, there are some things that you will definitely want to change, like the colors (nobody likes brown-seriously, what can brown do for you?). This chapter discusses options for making the desktop and workspace environment more usable.
Logging in for the First Time
When you first log into Ubuntu, a few things will get your attention, like the login music. It's this increasing tone with twinkles that sound like an orchestra tuning up. And the desktop
Changing the Startup Music
The startup music is one of the
Converting Audio Files
You may select any WAV audio file for any of the audio events. If you want to use a different audio format, such as MP3 or OGG, you will need to convert it to a WAV file. The easiest way to convert audio files is with
sox
-the universal sound
The sox application is a great tool for converting and modifying sound files, but it does not support all formats for all functions. In particular, even though it can read MP3 files, it cannot be used to create MP3 files without additional libraries. To resolve this constraint, you can use lame package to encode MP3 files from WAV files.
Just as GNU is a recursive acronym "
G
NU is
N
ot
U
nix", LAME uses a recursive
The MP3 file from LAME cannot be used for system sounds (because system sounds do not support MP3 files) but can be used by other audio applications and portable music devices.
Modifying Audio FilesMost WAV files are larger than a few seconds, and you probably do not want a three-minute song playing every time you click a button. The sox program can be used to trim audio files, but you will need to know the starting time for the sound you want and the length. For example, to start 3 seconds into the file and keep a 2.31 second duration, use: sox fileIN.mp3 fileOUT.wav trim 3 2.31
Trim times can be written in a variety of formats. You can specify seconds (and fractions of a second) or actual time values. The value 125.6 can be written as 2:05.6 or 0:2:5.6. The notations
The
sox
command can also add effects such as echos, high-pass and
Changing the Background
The default background for Ubuntu Dapper Drake is a brown screen with a bright highlight. As my fashionable coworker
Although Ubuntu does include some very
Changing the Background As-NeededThe picture and color on the desktop does not need to be static. You can write a simple program to change the picture (or color) as needed. The basic commands are:
gconftool-2 -t str --set /desktop/gnome/background/picture_filename \ /
The Gnome Desktop Manager (GDM) keeps a set of configuration parameters, similar to the Microsoft
Similar to picture_filename , the primary_color and secondary_color fields are used to control the background color. If you only have a solid background, then the color is defined by primary_color . The secondary_color is only used with a color gradient. Colors are represented by three hex bytes that denote red, green, and blue. Black is # 000000 , white is # FFFFFF , and a nice light blue is # 2255FF . As with the background image, as soon as you change the color in the registry, the color on the background changes.
Using Informative ColorsThe background color does not need to be a static color. You can create a script to change the color based on system events. For example, you can monitor a log file and change the background to red when something serious happens. To give you an example, Listing 2-1 is a simple Perl script that changes the background color to represent the system load.
Listing 2-1: Script to Change Background Color with Load
#!/usr/bin/perl # Color the background based on system load my $Key = "/desktop/gnome/background/primary_color"; my $Load; # system load my $R, $G, $B; # Red, Green, Blue colors while ( 1 ) { $Load='uptime'; # get the current load # format is "time duration, users, load average: 0.00, 0.00, 0.00" # remove everything except the first load value $Load =~ s/.*: //; # load values: 1 minute, 5 minute, 15 minute averages # these are colored: 1=Red, 5=Green, 15=Blue ($R,$G,$B) = split(', ',$Load); # scale up to the range 0-255, but cap it at 255 $R = $R * 255; if ($R > 255) { $R = 255; } $G = $G * 255; if ($G > 255) { $G = 255; } $B = $B * 255; if ($B > 255) { $B = 255; } # convert to hex $Load = sprintf "%02X%02X%02X",$R,$G,$B; # set the color system("gconftool-2 -t str --set $Key '#$Load'"); sleep 15; # Update 4 times per minute } done
This script will change the background color every 15 seconds based on the system load. A reddish color indicates that the system is very active. Yellow indicates an active process that has been running at least 5 minutes; white means at least 15 minutes. If no processes are raising the system load, then the colors will cycle from green to blue to black. If you want to know when the system is busy, a sudden change in the background color should get your attention.
Changing the Fonts
The default font for the Ubuntu desktop is Sans at 10pt. You can change the font used by the desktop through the System
Changing the DPI
Different output devices render the fonts at different
The default desktop fonts are rendered at 96 dots per inch (dpi). You can change the dpi value by opening the System
Although the Font applet is good for one-time changes, it cannot be easily automated. The dpi value can also be set through the gconf-edit registry under /desktop/gnome/font_ rendering/dpi . This value can be adjusted to match your screen. For example, a monitor that is 14 inches across at 1024×768 has approximately 73 horizontal pixels per inch, while a 20-inch wide screen at the same resolution has 51 pixels per inch. The default desktop assumes 1024×768, with 10 inches across. If you change the screen resolution or use a different size monitor, then fonts may appear larger or smaller. To change the dpi value, use:
gconftool-2 -t float --set /desktop/gnome/font_rendering/dpi 96 Values larger than 96 will make the fonts appear larger (but not change the actual font size), whereas a smaller number decreases the rendered size. In general, changing the dpi setting only changes how fonts are rendered on the screen. It does not change the size of the application windows nor impact how documents will print.
Helping with Big Fonts
I have a couple of
gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_7 \ 'gconftool-2 -t float --set /desktop/gnome/font_rendering/dpi 200' gconftool-2 -t str --set /apps/metacity/keybinding_commands/command_8 \ 'gconftool-2 -t float --set /desktop/gnome/font_rendering/dpi 96' gconftool-2 -t str --set /apps/metacity/global_keybindings/run_command_7 \ '<Control>F7' gconftool-2 -t str --set /apps/metacity/global_keybindings/run_command_8 \ '<Control>F8' Now pressing Ctrl+F7 changes the resolution to 200 dpi and make the fonts appear large (and coworkers can read it without glasses). Ctrl+F8 returns the screen to the system default of 96 dpi (see Figure 2-3).
If you want to remove Grandpa Mode, you can use the gconftool-2 –unset option:
# reset default dpi gconftool-2 -t float --set /desktop/gnome/font_rendering/dpi 96 # unset key mappings gconftool-2 --unset /apps/metacity/keybinding_commands/command_7 gconftool-2 --unset /apps/metacity/keybinding_commands/command_8 gconftool-2 --unset /apps/metacity/global_keybindings/run_command_7 gconftool-2 --unset /apps/metacity/global_keybindings/run_command_8
Tuning the Shell
Most of these Ubuntu hacks require you to use the command line and that means using the GNU Bourne-Again Shell (
bash
). Bash has
Bash also enables you to edit command lines in either vi or emacs mode. set -o vi # enable vi-mode set -o emacs # enable emacs-mode The default edit mode under Ubuntu is emacs . If you want to specify the mode (rather than inherit default settings), then add the appropriate set command to the end of your .bashrc file. This way, it will be set whenever you log in or open a new terminal window.
You may also want to change the default editor for applications by adding one of these lines to your $HOME/.bashrc file: export EDITOR=vi # enable vi-mode export EDITOR=emacs # enable emacs-mode After modifying your $HOME/.bashrc file, you can reload it using: . $HOME/.bashrc . This is called dotting in because the command you are running is a single dot.
Completing Completion
Bash includes file completion so you don't need to type in very long file
There are a few topics in the computer field that can start
When you need to help someone else at his terminal, it is a common
Under Dapper Drake, the default .bashrc loads the file /etc/bash_completion . This file contains many other completion settings. For example, there is a special completion sequence for the command apt-get . Typing apt-get up<TAB><TAB> displays update and upgrade since those are the available options. This default file ( /etc/bash_completion ) contains options for many widely used commands.
Awesome AliasesAliases are simple shortcuts for commonly typed commands. Usually people add aliases for the ls command to their .bashrc file. For example:
alias l.='ls -d .[a-zA-Z]*' # list all system files alias ll='ls -l --color=tty' # list using "ls -l" alias llf='ls -l --
There are a couple of other aliases that I find useful. The first is
telco
. The
telco
alias enables me to quickly look up phone numbers. Simply give it the area code and prefix for a phone number in North America and it will provide you with the city, state, and rate center. This is a useful command when you begin to
$ alias telco='whois -h whois.telcodata.us' $ telco 781-202 Telcodata.US Whois Server -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Your command was: 781-202 Data for 781 - 202
Another alias that I use often is
pinger
. This alias simply displays a number every five seconds. Many firewalls assume that no traffic after a while indicates a closed connection. If I know I will be walking away from a live connection, I run the
pinger
alias just to generate traffic and keep the connection
alias pinger='(i=0; while [ 1 ] ; do sleep 5 ; echo $i; ((i=$i+1)); done)'
Fun FunctionsBesides storing aliases, the .bashrc file can store shell functions that can be used in place of commands. For example, pinger can also be written in the .bashrc file as:
function pinger() { i=0; while [ 1 ] ; do sleep 5 ; echo $i; ((i=$i+1)); done }
Another function that I use is ccd :
function ccd() { if [ "$1" == "" ] ; then echo "Usage: ccd location" elif [ -d "$1" ] ; then # if it is a directory, go there cd "$1" else # must not be a directory # Cut off filename and cd to containing directory cd "${1%/*}" fi }
The ccd function works similar to the cd command, except that it does not mind when you paste a line containing a file name. For example, cd ˜/public_html/logo.gif will fail because the target must be a directory. But ccd ˜/public_html/logo.gif will see that logo.gif is a file and place you in the same directory as the file.
Cool Commands
There are two other lesser-known features of Bash. Ctrl+T transposes the last two
The other is the CDPATH environment variable. The PATH environment variable specifies where to look for commands. This usually looks something like:
export set PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games When you run a command, the shell first checks if the program exists in /usr/local/bin , then in /usr/sbin , and then /usr/bin , and so on until it is found. The CDPATH variable tells cd where to look when the directory is not in your current directory. For example: export set CDPATH=.:~:/usr:/etc If you type cd bin , then the shell will first check for ./bin . If that does not exist, then it will try ˜/bin followed by /usr/bin and /etc/bin . This can come in really handy if you find yourself frequently trying to type cd public_html (or some other directory) when you're in the wrong location.
|