Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux Timesaving Techniques For Dummies.pdf
Скачиваний:
59
Добавлен:
15.03.2015
Размер:
15.98 Mб
Скачать

48 Technique 8: Logging In, Logging Out

Follow these steps to run ~/.bash_logout every time you log out of your computer:

1. Open a terminal window, give yourself superuser privileges, and move into the PostSession directory:

$ su Password:

# cd /etc/X11/gdm/PostSession

If you’re running SuSE Linux, cd to /etc/opt/ gnome/gdm instead.

2. Rename the original PostSession/Default script:

# mv Default Default.dist

3.Use a text editor to create a new file that includes the following code:

#!/bin/bash

if [ -x $HOME/.bash_logout ] then

su -c “$HOME/.bash_logout” $USER

fi

SCRIPTDIR=$(dirname $0)

exec $SCRIPTDIR/Default.dist

4.Save your work to /etc/X11/gdm/ PostSession/Default and close the editor.

If you’re a SuSE user, save your work to /etc/opt/ gnome/gdm/PostSession/Default instead.

After making this change, your ~/.bash_logout script will run whether you’re using a KDE session, a GNOME session, or a command line ssh session.

Changing prototype scripts

Have you ever wondered how ~/.bash_profile,

~/.bashrc, and ~/.bash_logout got into your home directory to begin with? When you create a new user account, you don’t have to write the login and logout scripts yourself, but they must come from somewhere, right? Right! Each time you create a new user account,

Linux copies the prototype scripts from a directory named /etc/skel (that’s skel as in skeleton).

If you try to look at the /etc/skel directory with a normal ls command, it looks empty, but it’s not. All the files in /etc/skel have names that start with a period ( . ), meaning that they are hidden from the ls command. If you really want to see what’s in /etc/skel, use ls -a instead (that -a option tells ls to display hidden files as well as normal files). You’ll see (at least) three files:

/etc/skel/.bash_profile: Copied to

~/.bash_profile

/etc/skel/.bashrc: Copied to ~/.bashrc

/etc/skel/.bash_logout: Copied to

~/.bash_logout

/etc/skel/.bash_profile may be missing if you’re running SuSE Linux. If you want to change a login (or logout) script inherited by new users, change the script in /etc/skel. That way, when you create

a new user account, Linux copies the modified script into the spankin’ new home directory.

Now you know how the Linux login and logout scripts work. Whenever you feel a need to modify a login (or logout) script, be sure to ask yourself whom you want to affect and when your code needs to run.

Customizing Your Autostart File

If you’re like us, each time you log in to your graphical desktop (KDE or GNOME), you launch a few handy programs: xmms to play some music, Evolution to read e-mail, and Mozilla to surf the Web. Wouldn’t it be nice if Linux started those programs automatically, every time you logged in to your desktop?

Meet Autostart. Autostart is the KDE way to have your desktop ready for you every time you log in — no extra keystrokes or mouse clicks are required. KDE autostarts the programs you need and has them waiting for you on your desktop.

Customizing Your Autostart File

49

Autostart and the login scripts described earlier are somewhat related: They both prepare your environment for you. Login scripts set up your command line environment. Autostart sets up your graphical environment the way you like it.

Autostart is easy to set up and change. Just open a few browser windows and surf and drag, and with a few clicks, Autostart is up and running. To remove something from the Autostart menu, just drag the icon to the Trash.

To arrange your desktop with Autostart, follow these steps:

1. Double-click the Start Here icon on the desktop to open Konqueror.

2. Surf to the Autostart directory:

/home/username/.kde/Autostart

If you can’t see your .kde directory, you can find it by choosing View Show Hidden Files.

3. Double-click the Start Here icon again to open another Konqueror window.

Now the fun starts!

4. In the second Konqueror window, start surfing for the programs you want to see on your desktop.

Start in the Applications directory, where you’ll find your tools (and games) in the appropriate folders.

5. When you find a program that you want on your desktop at login, grab the icon and drag it to the Autostart folder.

When you drop it, a little dialog opens.

6. In the dialog, choose Link Here.

The icon now appears in the Autostart folder.

7. Repeat Steps 5 and 6 to add additional icons if you want.

That’s all there is to it. When you reboot, your tools are there waiting for you!

To remove startup programs, open the Autostart folder again and drag the icons you don’t want to the Trash. You’re just throwing away links, so the originals are still there if you need them.

Соседние файлы в предмете Операционные системы