https://wiki.archlinux.org/api.php?action=feedcontributions&user=Clickthem&feedformat=atomArchWiki - User contributions [en]2024-03-29T15:32:55ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Emacs&diff=188748Emacs2012-03-11T07:15:38Z<p>Clickthem: /* Customization */ use setq for setting things</p>
<hr />
<div>[[Category:Text editors (English)]]<br />
{{i18n|Emacs}}<br />
{{Article summary start|Summary}}<br />
{{Article summary text|Tutorial on acquiring and using the Emacs text editor.}}<br />
{{Article summary end}}<br />
<br />
[[Wikipedia:Emacs|Emacs]] is the extensible, customizable, self-documenting real-time display editor. At the core of Emacs lies an [[Wikipedia:Emacs Lisp|Emacs Lisp]] interpreter, the language in which the majority of Emacs' built-in functionality and extensions are implemented. GTK is the default X toolkit used as of GNU Emacs 22, though it functions equally well within a CLI environment. The text-editing capabilities of Emacs are often compared to that of [[vim]].<br />
<br />
== Installation ==<br />
Emacs comes in several variants (sometimes referred to as ''emacsen''). The most common of these is GNU Emacs, which can be installed (as root) via:<br />
# pacman -S emacs<br />
Another common variant is xemacs, which is also available for installation via pacman.<br />
<br />
== Quick Start ==<br />
Although Emacs is complex, it will not take long to begin to understand the benefits which the level of customization and extensibility bring. Furthermore, the comprehensive variety of extensions already available allows it to be transformed into a powerful environment for almost any form of text-editing.<br />
<br />
Emacs has an excellent built-in tutorial which can be accessed by clicking the first link on the splash screen; by selecting ''Help->Emacs Tutorial'' from the menu or by pressing 'F1' followed by 't'. This page is designed to be an additional resource for getting started with Emacs.<br />
<br />
Emacs also includes a set of reference cards, useful for beginners and experts alike, see {{ic|/usr/share/emacs/<version>/etc/refcards/}} (substitute <version> for your version of emacs).<br />
<br />
===Running Emacs===<br />
====Normal way====<br />
To start Emacs run:<br />
<br />
$ emacs<br />
<br />
or, to use it from the console:<br />
<br />
$ emacs -nw<br />
<br />
A file name can also be provided to open that file immediately:<br />
<br />
$ emacs filename.txt<br />
<br />
====As a daemon====<br />
Emacs can take some time to start since it has to load the .emacs file each time. Since version 23, Emacs is capable to run as a daemon to which users can connect. To run Emacs as a daemon:<br />
<br />
$ emacs --daemon<br />
<br />
You are likely to start the daemon at startup time and to connect a window to the daemon. Besides, it is possible to connect ''both'' graphical and console clients to the daemon at the same time and make the GUI to start quickly.<br />
<br />
If you want to connect to the daemon simply use the folowing command (note that it will start a graphical client if called in a graphical environment or a console client if called in a console like a tty):<br />
<br />
$ emacsclient -c<br />
<br />
If you still want a console client no matter you are in a graphical environment then use:<br />
<br />
$ emacsclient -t<br />
<br />
<br />
----<br />
<br />
<br />
With xfce, if you want to tell it to use emacsclient -c instead of emacs %f when opening a new file, you can change your /usr/share/applications/emacs.desktop and change the line<br />
<br />
$ Exec=emacs %f<br />
<br />
To<br />
<br />
$ Exec=emacsclient -c<br />
<br />
This way, a client will be called each time you open up a file and so be very fast!<br />
<br />
===Basic terminology and convention===<br />
Emacs uses some terminology and conventions which may seem unusual at first and will be introduced where appropriate. However, there is some terminology which should be introduced before-hand, as it is fundamental to working with Emacs.<br />
<br />
The one piece of terminology which must be introduced early is the concept of ''buffers''. A buffer is a representation of data within Emacs. For example, when a file is opened in Emacs, that file is read from disk and its contents stored in a buffer, which allows it to be edited and saved back to disk later. Buffers are not limited to text, and can also contain images and widgets. Work is in progress to allow buffers to even display applications! Another way to think of it: data available on disk is referred to as a 'file', whereas data available in Emacs is referred to as a 'buffer'.<br />
<br />
The convention for key sequences in Emacs may be unfamiliar. Namely:<br />
<br />
'''C-x''' refers to Control-x<br />
<br />
'''M-x''' refers to Meta-x<br />
<br />
{{Note|'Meta' corresponds to the Alt key in most cases. Alternatively, the Esc key can be used.}}<br />
<br />
For example, to exit Emacs use the following key sequence: '''C-x C-c'''. This can be read as "Hold Control and press 'x'. Release. Hold Control and press 'c'." Although Emacs provides a menu bar, it is recommended practise to focus on learning the key sequences. This guide will refer to keybindings with the convention used in Emacs from now on.<br />
<br />
===Movement===<br />
Cursor movement is very similar to other graphical editors. The mouse and arrow keys can be used to change the position of the cursor (referred to as ''point'' in Emacs). The standard movement commands performed by the arrow keys also have more accessible bindings in Emacs. To move forward one character, use '''C-f''' and to move one character backward, '''C-b'''. '''C-n''' and '''C-p''' can be used to move to the next and previous lines, respectively. Again, it is generally recommended to use these key-sequences in preference to the mouse and/or arrow keys.<br />
<br />
As might be expected, Emacs provides more advanced movement commands, including moving by word and sentence. '''M-f''' moves forward one word and '''M-b''' will move point one word backward. Similarly, '''M-e''' moves point one sentence forward and '''M-a''' one sentence backward.<br />
<br />
Until now, all of the movement commands introduced have been relative to point. '''M-<''' can be used to move point to the beginning of the buffer, with its counterpart, '''M->''', moving to the end of the buffer. To move point to a specific line number, use '''M-g g'''. '''M-g g''' will prompt for the desired line number. Also, to move to the start or end of the current line, use '''C-a''' or '''C-e''', respectively.<br />
<br />
{{Note|Keybindings for these commands, or indeed any command, may differ ''slightly'' depending on which modes are currently active. However, it is unusual for the replacement command not to provide equivalent functionality. See [[Emacs#Modes|Modes]] for more information.}}<br />
<br />
===Files and buffers===<br />
Emacs provides a series of commands to act upon files, the most common of which will be detailed here. '''C-x C-f''' is used to open a file (this command is called 'find-file' in Emacs). Should the file specified not exist, Emacs will open an empty buffer. Saving a buffer will create the file with the buffer's contents. '''C-x C-s''' can be used to save a buffer. To save a buffer with a different filename, use '''C-x C-w''' (this is a mnemonic for the command 'write-file'), which will prompt for the new filename before writing it to disk. It is also possible to ensure all buffers are saved with '''C-x s''', which, should a buffer be modified since its last save, a prompt will be displayed asking which action to take.<br />
<br />
{{Note|'''C-x C-f''' does not read the file from disk again if a buffer corresponding to the file is still opened. To re-read the file from disk, kill the buffer ('''C-x k''') prior to '''C-x C-f''' or use '''M-x revert-buffer'''.}}<br />
<br />
Many interactive commands such as "find-file" or "write-file" prompt for input in the bottom-most line of the Emacs window. This line is referred to as the ''minibuffer''. The minibuffer supports many basic editing commands as well as tab-completion similar to that which is available in many *nix shells. '''<TAB>''' can be pressed twice in succession to display a list of completions, and if desired, the mouse can be also be used to select a completion from that list. Completion in the minibuffer is available for many forms of input including commands and filenames.<br />
<br />
The minibuffer also provides a history feature. The previous items entered for a command can be recalled using the '''Up Arrow''' or '''C-p'''.<br />
<br />
To exit the minibuffer at any time, press '''C-g'''.<br />
<br />
After opening several files, a way to switch between them is needed. Opening a file corresponding to a buffer already available in Emacs, will cause Emacs to switch to that buffer. But this is not the most effective way. Emacs provides '''C-x b''', which prompts for the new buffer to be displayed (tab-completion is available here). By entering the name of a buffer which does not exist, a new buffer with that name will be created.<br />
<br />
{{Note|To switch to the previous buffer use '''C-x b <RET>''', as the previous buffer is the default.}}<br />
<br />
A list of all open buffers can be displayed using '''C-x C-b'''. Should a buffer no longer be required, it can be removed with '''C-x k'''.<br />
<br />
===Editing===<br />
Many editing commands exist within Emacs. Perhaps the most important command which has not yet been introduced is 'undo', which can be performed via '''C-_''' or '''C-/'''. Movement commands generally also have a corresponding delete command. For example, '''M-<backspace>''' can be used to delete a word backwards, and '''M-d''' to delete a word forwards. To delete to the end of the line, or the end of the sentence, use '''C-k''' or '''M-k''', respectively.<br />
<br />
It is a rule-of-thumb that no line be allowed to exceed 80 characters. This aids readability, especially in cases where the line wraps at the edge of a window. Automatically inserting (or removing) line separator(s) is known as ''filling'' in Emacs. A paragraph can be filled using '''M-q'''.<br />
<br />
Characters and words can be transposed using '''C-t''' and '''M-t''', respectively. For example: <code>Hello World!</code> → <code>World! Hello</code><br />
<br />
The case of words is also readily adjustable. '''M-l''' downcases a word from point (<code>HELLO</code> → <code>hello</code>); '''M-u''' upcases a word from point (<code>hello</code> → <code>HELLO</code>) and '''M-c''' capitalizes the first character of a word from point while downcasing the remainder (<code>hElLo</code> → <code>Hello</code>).<br />
<br />
===Killing, yanking and regions===<br />
A region is a section of text between two positions. One of those positions is referred to as ''mark'', and the other is point. '''C-<SPC>''' is used to set the position of mark, after which point can be moved to create a region. Within GNU Emacs 23.1 onwards, this region is visible by default. There are a number of commands which act upon regions, among the most commonly used are ''killing'' commands.<br />
<br />
In Emacs, cut and paste are referred to as ''kill'' and ''yank'', respectively. Many commands which delete more than one character (including many of those in the above section, such as '''C-k''' and '''M-d''') actually cut the text and append it to what is known as the ''kill-ring''. The kill-ring is simply a list of killed text. The kill-ring stores up to the last 60 kills by default. Successive kills are concatenated and stored at the head of the list.<br />
<br />
'''C-w''' and '''M-w''' can be used to kill and copy a region, respectively.<br />
<br />
To insert killed text into a buffer (known as 'yanking'), use '''C-y'''. '''C-y''' can be used multiple times in succession to yank text repeatedly. As mentioned, previous kills are stored in a list, however '''C-y''' only retrieves the first of them. The earlier kills can be accessed via '''M-y'''. This will remove the text inserted by 'yank' initially, replacing it with the text killed earlier. '''M-y''' must be used immediately following '''C-y''' and can be used in many times succession to cycle through the kill-ring.<br />
<br />
===Search and replace===<br />
Searching for a string is common practise in text-editing. This can be performed using '''C-s''' (to search forward) or '''C-r''' (to search backward). These commands prompt for the string for which to search. Searching is performed incrementally, and so it will match the next (or previous) occurrence as you type. To move to the next or previous match, press '''C-s''' or '''C-r''' again, respectively. Once a match has been found, '''<RET>''' can be used to end the search. Alternatively, should you wish to return to the location you initiated the search, use '''C-g'''.<br />
<br />
Once a search is completed (i.e., was not aborted with '''C-g''' or similar), the string which was searched for will be the default for any following search. To make use of this, press '''C-s C-s''' or '''C-r C-r''' to search forward or backward again, respectively.<br />
<br />
Regular Expression searches behave identically to the searching described above except for the command to initiate the search. Use '''C-M-s''' or '''C-M-r''' to initiate a regexp search forward or backward, respectively. Once a Regular Expression search has commenced, '''C-s''' and '''C-r''' can be used to search forward or backward, just as with string searches.<br />
<br />
In addition to searching, it is also possible to perform string and regular expression replacement (via '''M-%''' and '''C-M-%''', respectively). Prompts are provided for both the initial and replacement text, and then another prompt for the action to perform on the highlighted match. Although many options are available (the full list is available by pressing '''?'''), the most commonly used are '''y''', to perform replacement, '''n''', to skip this match, and '''!''' to replace this, and all following matches.<br />
<br />
===Indentation and prefix arguments===<br />
Indentation is usually performed with either '''<TAB>''', to indent a single line, or with '''C-M-\''', to indent a region.<br />
<br />
Exactly how text is indented usually depends on the ''major-mode'' which is active. Major-modes often define indentation styles specialising in indenting a certain type of text. (See [[Emacs#Modes|Modes]] for more information.)<br />
<br />
In some cases, a suitable major-mode may not exist for a file type, in which case, manual indentation may be necessary. Create a region (see [[Emacs#Killing, yanking and regions|Killing, yanking and regions]]) then perform indentation with '''C-u <n> C-x <TAB>''' (where '<n>' is the number of columns which the text within the region should be indented). For example:<br />
<br />
Increase the region's indentation by four columns:<br />
<br />
C-u 4 C-x <TAB><br />
<br />
Decrease the region's indentation by two columns.<br />
<br />
C-u -2 C-x <TAB><br />
<br />
{{Note|The trick behind this is '''C-u''', which corresponds to the 'universal-argument' command. Providing a 'universal-argument' is a way to provide more information to a command (this information is referred to as a 'prefix argument'). In this case, we provided the amount of indentation desired to the command invoked by '''C-x <TAB>'''. Without providing an argument, '''C-x <TAB>''' will only increase indentation by 1 column.}}<br />
<br />
===Windows and frames===<br />
Emacs is designed for convenient editing of many files at a time. This is achieved by dividing the Emacs interface into three levels. Namely, buffers, which have already been introduced, as well as ''windows'' and ''frames''.<br />
<br />
A ''window'' is a viewport used for displaying a buffer. A window can display only one buffer at a time, however one buffer can be displayed in many windows. Beneath each window exists a ''mode-line'', which displays information for that buffer.<br />
<br />
A ''frame'' is an Emacs "window" (in standard terminology. i.e., 'window' in the sense of the modern desktop paradigm) which contains a title bar, menu bar and one or more 'windows' (in Emacs terminology. i.e., the above definition of 'window').<br />
<br />
From now on the definition of these terms as they exist in Emacs will be used.<br />
<br />
To split the window vertically or horizontally, use '''C-x 2''' or '''C-x 3''', respectively. This has the effect of creating another window in the current frame. To cycle between multiple windows, use '''C-x o'''.<br />
<br />
The opposite of splitting a window, is deleting it. To delete the current window, use '''C-x 0''' and '''C-x 1''' to delete all windows except the current.<br />
<br />
As with windows, it is also possible to create and delete frames. '''C-x 5 2''' creates a frame. With '''C-x 5 0''' to delete the current frame and '''C-x 5 1''' to delete all except the current frame.<br />
<br />
{{Note|These commands do not affect buffers. For example, deleting a window does not kill the buffer it displays.}}<br />
<br />
===Getting help===<br />
Emacs is self-documenting by design. As such, a great deal of information is available to determine the name of a specific command or its keybinding, for example. The following is a listing of some of the most helpful of these:<br />
<br />
'''C-h t''' Start the Emacs tutorial<br />
<br />
'''C-h b''' List all active keybindings<br />
<br />
'''C-h k''' Find which command a key is bound to<br />
<br />
'''C-h w''' Find which key(s) a command is bound to<br />
<br />
'''C-h a''' Find a command matching a description<br />
<br />
'''C-h m''' Display information regarding the currently active modes<br />
<br />
'''C-h f''' Describe the given function<br />
<br />
===Modes===<br />
An Emacs mode is an extension written in Emacs Lisp that controls the behaviour of the buffer it is attached to. Usually it provides indentation, syntax highlighting and keybindings for editing that form of text. Sophisticated modes can turn Emacs into a full-fledged IDE (Integrated Development Environment). Emacs will generally use a file's extension to determine which mode should be loaded.<br />
<br />
Useful modes for editing shell scripts are sh-mode, line-number-mode and column-number-mode. They can be used in parallel and are invoked by:<br />
<br />
'''M-x sh-mode <RET>'''<br />
<br />
'''M-x column-number-mode <RET>'''<br />
<br />
line-number-mode is enabled by default, though, it can be toggled on/off by issuing the command again:<br />
<br />
'''M-x line-number-mode <RET>'''<br />
<br />
sh-mode is a ''major-mode''. Major-modes adjust Emacs, and often also provide a specialised set of commands, for editing a particular type of text. Only one major-mode can be active in each buffer. In addition to syntax highlighting, and indentation support, sh-mode defines several commands to help write shell scripts. The following shows a few of those commands:<br />
<br />
'''C-c (''' Insert a function definition<br />
<br />
'''C-c C-f''' Insert a 'for' loop<br />
<br />
'''C-c TAB''' Insert an 'if' statement<br />
<br />
'''C-c C-w''' Insert a 'while' loop<br />
<br />
'''C-c C-l''' Insert an indexed loop from 1 to n<br />
<br />
'line-number-mode' and 'column-number-mode', are ''minor-modes''. Minor-modes can be used to extend a major-mode and any number of minor-modes can be enabled at once.<br />
<br />
==Tips and tricks==<br />
While the previous sections has given an overview of the basic editing commands available, it has not given an indication of the possibilities of Emacs. This section will cover some more advanced techniques and functionality.<br />
<br />
===TRAMP===<br />
TRAMP (Transparent Remote Access, Multiple Protocols) is an extension which, as its name suggests, provides transparent access to remote files across a number of protocols. When prompted for a filename, entering a specific form will invoke TRAMP. Some examples:<br />
<br />
To prompt for the root password before opening /etc/hosts with root permissions:<br />
<br />
C-x C-f /su::/etc/hosts<br />
<br />
To connect to 'myhost' as 'myuser' via SSH and open the file ~/example.txt:<br />
<br />
C-x C-f /ssh:myuser@myhost:~/example.txt<br />
<br />
The path for TRAMP is typically of the form '/[protocol]:[[user@]host]:<file>'. TRAMP supports much more than the examples above might indicate. For more information refer to the TRAMP info manual, which is distributed with Emacs.<br />
<br />
===Keyboard macros and registers===<br />
This section will provide a practical demonstration of the use of a couple of more powerful editing features. Namely, ''keyboard macros'' and ''registers''.<br />
<br />
The aim will be to produce a listing of a series of characters and their corresponding position in this list. While it is possible to format each of them by hand, this would be slow and error-prone. Alternatively, some of Emacs' more powerful editing functionality could be leveraged. Before describing a solution, some details behind the techniques which will be used follow.<br />
<br />
The first feature which will be introduced is ''registers''. Registers are used to store and retrieve a variety of data types ranging from numbers to window configurations. Each register is given a name of a single character: this character is used to access the register.<br />
<br />
The other which will be demonstrated is ''keyboard macros''. A keyboard macro stores a sequence of commands so they can be easily repeated later. These changes will now be performed step-by-step.<br />
<br />
Starting with a buffer containing our set of characters:<br />
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz<br />
<br />
Prepare a register by invoking the `number-to-register' command ('''C-x r n''') then storing the number '0' in register 'k':<br />
<br />
C-x r n k<br />
<br />
With point at the beginning of the buffer, start a keyboard macro ('''C-x (''') and begin to format the characters:<br />
<br />
C-x ( C-f M-4 .<br />
<br />
Insert ('''C-x r i''') and increment ('''C-x r +''') the register 'k'. The prefix argument ('''C-u''') is used to leave point positioned after the inserted text:<br />
<br />
C-u C-x r i k C-x r + k<br />
<br />
Complete the formatting by inserting a newline. Emacs can then repeat that process, beginning from the point where we started defining the keyboard macro, for the rest of the characters. '''C-x e''' completes then invokes the keyboard macro. The prefix argument, '''M-0''', causes the macro to repeat until it comes across an error. In this case it aborts once it reaches the end of the buffer.<br />
<br />
<RET> M-0 C-x e<br />
<br />
The result:<br />
<br />
A....0<br />
B....1<br />
C....2<br />
[...]<br />
x....49<br />
y....50<br />
z....51<br />
<br />
===Regular expressions===<br />
From the Emacs Manual: "A regular expression, or ''regexp'' for short, is a pattern that denotes a (possibly infinite) set of strings." This section will not go into any detail regarding regular expressions themselves (as there is simply too much to cover). It will however provide a quick demonstration of their power. See [http://www.gnu.org/software/emacs/manual/html_node/elisp/Regular-Expressions.html#Regular-Expressions Regular Expressions] section in the Emacs Manual for further reading.<br />
<br />
Given the same scenario presented above: A list of characters which are to be formatted to represent their respective position in the list. (see [[Emacs#Keyboard macros and registers|Keyboard macros and registers]]). Again, starting with a buffer containing.<br />
<br />
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz<br />
<br />
At the beginning of the buffer, use '''C-M-%''' (if the key-sequence is difficult to perform, it may be more comfortable to use '''M-x query-replace-regexp'''). At the prompt:<br />
\(.\)<br />
which simply matches one character. Then, when prompted for the replacement:<br />
\1....\#^J<br />
{{Note|'^J' represents where a newline should be placed, it should not be entered into the prompt. The newline must instead be inserted literally using '''C-q C-j'''.}}<br />
The replacement expression reads: "Insert the matched text between the first set of parentheses (in this case, a single character), followed by 4 periods then insert an automatically incremented number followed by a newline.<br />
<br />
Finally, press '''!''' to apply this across the entire buffer. All of the formatting that was performed in the previous section was performed with a single regexp replacement.<br />
<br />
===Customization===<br />
Emacs can configured by editing '~/.emacs' or using '''M-x customize'''. This section will focus on editing ~/.emacs by hand, and provide some example customizations to demonstrate commonly-configured aspects of Emacs. The customize command provides a simple interface to make adjustments, though it may become restricting as you grow more familiar with Emacs.<br />
<br />
All of the examples here can be performed while Emacs is running. To evaluate the expression within Emacs, use:<br />
<br />
'''C-M-x''' with point anywhere within the expression.<br />
<br />
or<br />
<br />
'''C-x C-e''' with point following the last ')'<br />
<br />
For some users, typing 'yes' and 'no' in prompts can quickly become tiring. To instead use the 'y' and 'n' keys at these prompts:<br />
<br />
(defalias 'yes-or-no-p 'y-or-n-p)<br />
<br />
To stop the cursor blinking, use:<br />
<br />
(blink-cursor-mode -1)<br />
<br />
Similarly, to enable column-number-mode, as discussed in the previous section:<br />
<br />
(column-number-mode 1)<br />
<br />
The similarities between the previous two commands are not a coincidence: blink-cursor-mode and column-number-mode are both minor-modes. As a rule, minor-modes can be enabled given positive argument or disabled with a negative argument. Should the argument be omitted, the minor-mode will be toggled on/off.<br />
<br />
Here are some more examples of minor-modes. The following will disable the scroll bars, menu-bar and tool-bar, respectively.<br />
<br />
(scroll-bar-mode -1)<br />
(menu-bar-mode -1)<br />
(tool-bar-mode -1)<br />
<br />
The variable, 'auto-mode-alist', can be modified to change the major-mode used by default for certain file names. The following example will make the default major-mode for '.tut' and '.req' files 'text-mode'.<br />
<br />
(setq auto-mode-alist<br />
(append<br />
'(("\\.tut$" . text-mode)<br />
("\\.req$" . text-mode))<br />
auto-mode-alist))<br />
<br />
Settings can also be applied on a per-mode basis. A common method for this is to add a function to a ''hook''. For example, to force indentation to use spaces instead of tabs, but only in text-mode:<br />
<br />
(add-hook 'text-mode-hook (lambda () (setq indent-tabs-mode nil)))<br />
<br />
Similarly, to only use spaces for indentation everywhere:<br />
<br />
(setq-default indent-tabs-mode nil)<br />
<br />
Keybindings can be adjusted in two ways. The first of which is 'define-key'. 'define-key' creates a keybinding for a command but only in one mode. The example below will make '''F8''' delete any whitespace from the end of each line of a 'text-mode' buffer:<br />
<br />
(define-key text-mode-map (kbd "<f8>") 'delete-trailing-whitespace)<br />
<br />
The other method is 'global-set-key'. This is used to bind a key to a command everywhere. To bind 'query-replace-regexp' ('''C-M-%''') to '<f7>'.<br />
<br />
(global-set-key (kbd "<f7>") 'query-replace-regexp)<br />
<br />
Binding a command to an alternate key does not replace any existing bindings. Which is to say, 'query-replace-regexp' would be bound to both '''F7''' and '''C-M-%''' after the above example.<br />
<br />
Almost anything within Emacs can be configured. Browsing through the [http://emacswiki.org/ Emacs Wiki] should give a solid place to start.<br />
<br />
=== Extensions ===<br />
<br />
While Emacs includes hundreds of modes, libraries and other extensions, there are many more available to further Emacs' capabilities. The majority of these come with instructions detailing any changes needed to be made to ~/.emacs. These instructions are generally found in the comment block at the beginning of an elisp source file, or in a README (or similar) should the extension consist of multiple source files.<br />
<br />
A number of popular extensions are available as packages in the 'community' repository, and more still are available via the [[AUR]]. The name of such packages have a 'emacs-' prefix (for example, emacs-lua-mode). In many cases, the changes which need to be made to ~/.emacs are shown during the installation of the package.<br />
<br />
Should instructions describing how to activate a specific extension not be available in the aforementioned location(s), check for a corresponding page in the [http://emacswiki.org/ Emacs Wiki], which will almost certainly provide an example configuration. The Emacs Wiki is also an excellent resource for discovering even more extensions.<br />
<br />
You can also use the [http://tromey.com/elpa/ Emacs Lisp Package Archive (ELPA)] to automatically install packages. See the website for instructions. ELPA will be included with Emacs 24 (the next version of Emacs); it is an accepted part of the Emacs ecosystem.<br />
<br />
== Troubleshooting ==<br />
<br />
===Colored output issues===<br />
By default, the Emacs shell will show raw escape sequences used to print colors. In other words, it will display strange symbols in place of the desired colored output.<br />
<br />
Including the following into {{ic|~/.emacs}} amends the problem:<br />
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)<br />
<br />
===Menus appear empty===<br />
A bug exists in GNU Emacs 23.1 (using the GTK toolkit) which may cause some menus to appear empty. This appears to be fixed in Emacs' CVS trunk. The corresponding [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=550541 Debian bug report] contains a workaround.<br />
<br />
=== Problems displaying characters in X Windows ===<br />
If when you start emacs in X windows all the characters in the main window are white boxes with black borders (the ones you see if you try to view characters for which you do not have the correct font installed), you need to install xorg-fonts-75dpi and/or xorg-fonts-100dpi and restart X windows.<br />
<br />
=== Slow startup ===<br />
Slow startup times are often caused by one of two things.<br />
<br />
To determine which it might be, run Emacs with:<br />
<br />
$ emacs -q<br />
<br />
If Emacs still starts slowly, refer to [[Emacs#Incorrect network configuration|Incorrect network configuration]]. If not, it is almost certainly a [[Emacs#Init file loads slowly|problem in your .emacs]].<br />
<br />
====Incorrect network configuration====<br />
<br />
Mistakes, particularly in /etc/hosts, will often result in a 5+ second delay when starting Emacs. Refer to '[[Configuring_network#Set_the_hostname|set the hostname]]' in the network configuration guide for information.<br />
<br />
====Init file loads slowly====<br />
<br />
A simple way to search for the cause is to comment-out (i.e., prefix lines with ';') suspect sections of your ~/.emacs (or ~/.emacs.d/init.el) then start Emacs again to see if there's any change. Keep in mind use of "require" and "load" can slow the startup down, especially when used with larger extensions. They should, as a rule, only be used when their target is either: needed once Emacs starts or provides little more than "autoloads" for an extension. Otherwise, use the 'autoload function directly. For example, instead of:<br />
<br />
(require 'anything)<br />
<br />
you might use:<br />
<br />
(autoload 'anything "anything" "Select anything" t)<br />
<br />
=== Cannot open load file: ... ===<br />
<br />
The most common cause of this error is the 'load-path' variable not including the path to the directory within which the extension is located. To solve this, add the appropriate path to the list to be searched prior to attempting to load the extension:<br />
<br />
(add-to-list 'load-path "/path/to/directory/")<br />
<br />
When attempting to use packages for extensions and Emacs has been configured with a prefix other than '/usr', the load-path will need to be updated. Place the following in ~/.emacs prior to the instructions provided by the package:<br />
<br />
(add-to-list 'load-path "/usr/share/emacs/site-lisp")<br />
<br />
If compiling Emacs by hand, keep in mind that the default prefix is '/usr/local'.<br />
<br />
== Resources ==<br />
* [http://www.gnu.org/software/emacs/ GNU Emacs home page]<br />
* [http://www.gnu.org/software/emacs/manual/emacs.html GNU Emacs Manual]<br />
* [http://www.emacswiki.org/cgi-bin/wiki/ Emacs Wiki]<br />
* [http://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial.html Useful introduction to Emacs and its shortcuts]<br />
* [http://www.dina.kvl.dk/~abraham/religion/ The Church of Emacs]</div>Clickthemhttps://wiki.archlinux.org/index.php?title=Xorg&diff=187657Xorg2012-03-05T00:24:55Z<p>Clickthem: /* Setting Keyboard Layout With Hot-Plugging */ chaged layout example to use variant instead</p>
<hr />
<div>[[Category:X Server (English)]]<br />
{{i18n|Xorg}}<br />
[[de:X]]<br />
[[fr:Xorg]]<br />
[[pl:Xorg]]<br />
[[ro:Xorg]]<br />
<br />
{{Article summary start}}<br />
{{Article summary text|An all-inclusive overview about installing and managing Xorg}}<br />
{{Article summary heading|Overview}}<br />
{{Article summary text|{{Graphical user interface overview}}}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Start X at boot}}<br />
{{Article summary wiki|Execute commands after X start}}<br />
{{Article summary wiki|Login Manager}}<br />
{{Article summary wiki|Window Manager}}<br />
{{Article summary wiki|Font Configuration}}<br />
{{Article summary wiki|X11 Cursors}}<br />
{{Article summary wiki|Get All Mouse Buttons Working}}<br />
{{Article summary wiki|Desktop Environment}}<br />
{{Article summary wiki|Wayland}}<br />
{{Article summary heading|Proprietary Video Drivers}}<br />
{{Article summary wiki|NVIDIA}}<br />
{{Article summary wiki|ATI Catalyst}}<br />
{{Article summary heading|Free Video Drivers}}<br />
{{Article summary wiki|Nouveau}}<br />
{{Article summary wiki|ATI}}<br />
{{Article summary wiki|Intel}}<br />
{{Article summary end}}<br />
<br />
'''Xorg''' is the public, open-source implementation of the X window system version 11. Since Xorg is the most popular choice among Linux users, its ubiquity has led to making it an ever-present requisite for GUI applications, resulting in massive adoption from most distributions. See the [[Wikipedia:X.Org Server|Xorg]] Wikipedia article or visit the [http://www.x.org/wiki/ Xorg website] for more details.<br />
<br />
==Installation==<br />
First, you will need to [[pacman|install]] the X server with the package {{Pkg|xorg-server}}, available in the [[Official Repositories]]. You may also want the useful utilities cointained in the {{Grp|xorg-apps}} group.<br />
<br />
[[udev]] will detect your hardware and [[Wikipedia:evdev|evdev]] will act as the hotplugging input driver for almost all devices. Both of them are already required by {{Pkg|xorg-server}}, so there is no need to explicitly install their packages.<br />
<br />
{{Tip|The default X environment is rather bare, and you will typically seek to install a [[Window Manager|window manager]] or a [[Desktop Environment|desktop environment]] to supplement X.}}<br />
<br />
==Running==<br />
''See also: [[Start X at boot]]''<br />
<br />
{{Tip|The easiest way to start X is by using a [[Display Manager|display manager]] such as [[GDM]], [[KDM]] or [[SLiM]].}}<br />
<br />
If you want to start X without a display manager, install the package {{Pkg|xorg-xinit}}. Optionally, the packages {{Pkg|xorg-twm}}, {{Pkg|xorg-xclock}} and {{Pkg|xterm}} allows for a default environment, as described below.<br />
<br />
The {{ic|startx}} and {{ic|xinit}} commands will start the X server and clients (the {{ic|startx}} script is merely a front end to the more versatile {{ic|xinit}} command). To determine the client to run, {{ic|startx}}/{{ic|xinit}} will first look to parse a {{ic|~/.xinitrc}} file in the user's home directory. In the absence of {{ic|~/.xinitrc}}, it defaults to the global file {{ic|/etc/X11/xinit/xinitrc}}, which defaults to starting a basic environment with the [[Twm]] window manager, [[Wikipedia:Xclock|Xclock]] and [[Xterm]].<br />
<br />
For more information, see [[xinitrc]].<br />
<br />
{{Note|<br />
* If a problem occurs, then view the log at {{ic|/var/log/Xorg.0.log}}. Be on the lookout for any lines beginning with {{ic|(EE)}}, which represent errors, and also {{ic|(WW)}}, which are warnings that could indicate other issues.<br />
* If there is an ''empty'' {{ic|.xinitrc}} file in your {{ic|$HOME}}, either delete or [[xinitrc|edit it]] in order for X to start properly. If you do not do this X will show a blank screen with what appears to be no errors in your {{ic|Xorg.0.log}}. Simply deleting it will get it running with a default X environment.}}<br />
<br />
==Configuring==<br />
Xorg can be configured via {{ic|/etc/X11/xorg.conf}} or {{ic|/etc/xorg.conf}} and configuration files located in {{ic|/etc/X11/xorg.conf.d/}}. Arch supplies default configuration files in {{ic|/etc/X11/xorg.conf.d}}, and no extra configuration is necessary for most setups. You are free to create new configuration files, but they must start with {{ic|XX-}} (where XX is a number) and have a {{ic|.conf}} suffix (10 is read before 20, for example).<br />
<br />
Alternatively, your video card drivers may come with a tool to automatically configure Xorg. In the case of NVIDIA, try nvidia-xconfig. For ATI, try aticonfig.<br />
<br />
==Input devices==<br />
Installing input drivers is not needed for most hardware. Nevertheless, if evdev does not support your device, install the needed driver from the {{Grp|xorg-drivers}} group (try {{ic|pacman -Sg xorg-drivers}} for a listing).<br />
<br />
You should have {{ic|10-evdev.conf}} in the {{ic|/etc/X11/xorg.conf.d}} directory, which manages the keyboard, the mouse, the touchpad and the touchscreen.<br />
<br />
===Touchpad Synaptics===<br />
''Main page: [[Touchpad Synaptics]]''<br />
<br />
If you have a laptop, you need to [[pacman|install]] the touchpad driver provided by the {{Pkg|xf86-input-synaptics}} package in the [[Official Repositories]].<br />
<br />
After installation, you can find {{ic|10-synaptics.conf}} in the {{ic|/etc/X11/xorg.conf.d}} directory. It is safe to comment out/delete the {{ic|InputClass}} line regarding the touchpad in {{ic|10-evdev.conf}}.<br />
<br />
===Disabling Input Hot-plugging===<br />
Since version''' 1.8''' Xorg-server uses udev for device detection. The following will disable the use of udev.<br />
<br />
Section "ServerFlags"<br />
Option "AutoAddDevices" "False"<br />
EndSection<br />
{{Warning|This will disable Xorg hot-plugging for '''all''' input devices and revert to the same behavior as xorg-server 1.4. It is much more convenient to let udev configure your devices. '''Therefore, disabling hot-plugging is not recommended!'''}}<br />
<br />
===Keyboard settings===<br />
<br />
Xorg may fail to detect your keyboard correctly. This might give problems with your keyboard layout or keyboard model not being set correctly.<br />
<br />
To see a full list of keyboard models, layouts, variants and options, open {{ic|/usr/share/X11/xkb/rules/xorg.lst}}.<br />
<br />
To set the keymap for the current Xorg session:<br />
# setxkbmap dvorak<br />
<br />
====Key repeat delay and rate====<br />
<br />
Use {{ic|xset r rate DELAY RATE}} to change them, then use [[xinitrc]] to make it permanent.<br />
<br />
====Viewing Keyboard Settings====<br />
{{hc|$ setxkbmap -print -verbose 10|<nowiki><br />
<br />
Setting verbose level to 10<br />
locale is C<br />
Applied rules from evdev:<br />
model: evdev<br />
layout: us<br />
options: terminate:ctrl_alt_bksp<br />
Trying to build keymap using the following components:<br />
keycodes: evdev+aliases(qwerty)<br />
types: complete<br />
compat: complete<br />
symbols: pc+us+inet(evdev)+terminate(ctrl_alt_bksp)<br />
geometry: pc(pc104)<br />
xkb_keymap {<br />
xkb_keycodes { include "evdev+aliases(qwerty)" };<br />
xkb_types { include "complete" };<br />
xkb_compat { include "complete" };<br />
xkb_symbols { include "pc+us+inet(evdev)+terminate(ctrl_alt_bksp)" };<br />
xkb_geometry { include "pc(pc104)" };<br />
};<br />
</nowiki>}}<br />
====Setting Keyboard Layout With Hot-Plugging====<br />
To permanently change your keyboard layout, add the following to {{ic|xorg.conf}}:<br />
<br />
Section "InputClass"<br />
Identifier "Keyboard Defaults"<br />
MatchIsKeyboard "yes"<br />
Option "XkbLayout" "us"<br />
Option "XkbVariant" "colemak"<br />
EndSection<br />
<br />
{{Note|This is in an InputClass Section and not the InputDevice section for the keyboard.}}<br />
<br />
====Setting Keyboard Layout Without Hot-Plugging (deprecated)====<br />
{{Note|Changing the keyboard layout through this method requires disabling input hot-plugging.}}<br />
<br />
To change the keyboard layout, use the XkbLayout option in the keyboard InputDevice section. For example, if you have a keyboard with the English (Great Britain) layout, your keyboard InputDevice section might look similar to this:<br />
<br />
Section "InputDevice"<br />
Identifier "Keyboard0"<br />
Driver "kbd"<br />
Option "XkbLayout" "gb"<br />
EndSection<br />
<br />
To change the keyboard model, use the XkbModel option in the keyboard InputDevice section. For example, if you have a Microsoft Wireless Multimedia Keyboard:<br />
<br />
Option "XkbModel" "microsoftmult"<br />
<br />
====Switching Between Keyboard Layouts====<br />
{{Note|You need to install {{Pkg|xorg-xkbevd}} and add {{ic|xkbevd}} to DAEMONS section of {{ic|/etc/rc.conf}}.}}<br />
<br />
To be able to easily switch keyboard layouts, modify the Options used in either of the above two methods. For example, to switch between a US and a Swedish layout using the {{Keypress|Caps Lock}} key, create a file {{ic|/etc/X11/xorg.conf.d/01-keyboard-layout.conf}} with the following content:<br />
Section "InputClass"<br />
Identifier "keyboard-layout"<br />
MatchIsKeyboard "on"<br />
Option "XkbLayout" "us, se"<br />
Option "XkbOptions" "grp:caps_toggle"<br />
EndSection<br />
<br />
You can get a list of possible options for {{ic|grp:}} in {{ic|/usr/share/X11/xkb/rules/xorg.lst}} (they start about mid way in the file).<br />
<br />
As an alternative, you can add the following to your {{ic|.xinitrc}}:<br />
<br />
setxkbmap -layout "us, se" -option "grp:caps_toggle"<br />
<br />
This is mainly useful if you run a Desktop Environment which does not take care of keyboard layouts for you.<br />
<br />
====Enable pointerkeys====<br />
[[Wikipedia:Mouse keys|Mouse keys]] is now disabled by default and has to be manually enabled:<br />
{{hc|/etc/X11/xorg.conf.d/20-enable-pointerkeys.conf|<nowiki>Section "InputClass"<br />
Identifier "Keyboard Defaults"<br />
MatchIsKeyboard "yes"<br />
Option "XkbOptions" "keypad:pointerkeys"<br />
EndSection</nowiki>}}<br />
<br />
You can also run:<br />
$ setxkbmap -option keypad:pointerkeys<br />
<br />
Both will make the {{Keypress|Shift+Num Lock}} shortcut toggle mouse keys.<br />
<br />
===InputClasses ===<br />
'''Taken from: https://fedoraproject.org/wiki/Input_device_configuration'''<br />
<br />
InputClasses are a new type of configuration section that does not apply to a single device but rather to a class of devices, including hotplugged devices. An InputClass section's scope is limited by the ''matches'' specified &ndash; to apply to an input device, all matches must apply to a device. An example InputClass section is provided below:<br />
<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "touchpad catchall"<br />
MatchIsTouchpad "on"<br />
Driver "synaptics"<br />
EndSection<br />
}}<br />
<br />
The next snippet might also be helpful:<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "evdev touchpad catchall"<br />
MatchIsTouchpad "on"<br />
MatchDevicePath "/dev/input/event*"<br />
Driver "evdev"<br />
EndSection<br />
}}<br />
<br />
If this snippet is present in the {{ic|xorg.conf}} or xorg.conf.d, any touchpad present in the system is assigned the synaptics driver. Note that due to precedence order (alphanumeric sorting of xorg.conf.d snippets) the Driver setting overwrites previously set driver options &ndash; the more generic the class, the earlier it should be listed. The default snippet shipped with the xorg-x11-drv-Xorg package is {{ic|00-evdev.conf}} and applies the evdev driver to all input devices.<br />
<br />
The match options specify which devices a section may apply to. To match a device, all match lines must apply. The following match lines are supported (with examples):<br />
* {{ic|MatchIsPointer}}, {{ic|MatchIsKeyboard}}, {{ic|MatchIsTouchpad}}, {{ic|MatchIsTouchscreen}}, {{ic|MatchIsJoystick}} &ndash; boolean options to apply to a group of devices.<br />
* {{ic|MatchProduct "foo&#124;bar"}}: match any device with a product name containing either "foo" or "bar"<br />
* {{ic|MatchVendor "foo&#124;bar&#124;baz"}}: match any device with a vendor string containing either "foo", "bar", or "baz"<br />
* {{ic|MatchDevicePath "/dev/input/event*"}}: match any device with a device path matching the given patch (see fnmatch(3) for the allowed pattern)<br />
* {{ic|MatchTag "foo&#124;bar"}}: match any device with a tag of either "foo" or "bar". Tags may be assigned by the config backend &ndash; udev in our case &ndash; to label devices that need quirks or special configuration.<br />
<br />
An example section for user-specific configuration is:<br />
<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "lasermouse slowdown"<br />
MatchIsPointer "on"<br />
MatchProduct "Lasermouse"<br />
MatchVendor "LaserMouse Inc."<br />
Option "ConstantDeceleration" 20<br />
EndSection<br />
}}<br />
<br />
This section would match a pointer device containing "Lasermouse" from "Lasermouse Inc." and apply a constant deceleration of 20 on this device &ndash; slowing it down by factor 20.<br />
<br />
Some devices may get picked up by the X server when they really should not be. These devices can be configured to be ignored:<br />
<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "no need for accelerometers in X"<br />
MatchProduct "accelerometer"<br />
Option "Ignore" "on"<br />
EndSection<br />
}}<br />
<br />
====Example configurations====<br />
<br />
The following subsections describe example configurations for commonly used configuration options. Note that if you use a desktop environment such as GNOME or KDE, options you set in the xorg.conf ''may'' get overwritten with user-specific options upon login.<br />
<br />
=====Example: Wheel Emulation (for a Trackpoint)=====<br />
<br />
If you own a computer with a Trackpoint (a Thinkpad for example) you can add the following to the {{ic|xorg.conf}} to use the middle Button to emulate a mouse wheel:<br />
<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "Wheel Emulation"<br />
MatchIsPointer "on"<br />
MatchProduct "TrackPoint"<br />
Option "EmulateWheelButton" "2"<br />
Option "EmulateWheel" "on"<br />
EndSection<br />
}}<br />
<br />
For full support of TrackPoints (including horizontal scrolling) you can use the following:<br />
{{bc|<nowiki><br />
Section "InputClass"<br />
Identifier "Trackpoint Wheel Emulation"<br />
MatchProduct "TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device"<br />
MatchDevicePath "/dev/input/event*"<br />
Option "EmulateWheel" "true"<br />
Option "EmulateWheelButton" "2"<br />
Option "Emulate3Buttons" "false"<br />
Option "XAxisMapping" "6 7"<br />
Option "YAxisMapping" "4 5"<br />
EndSection<br />
</nowiki>}}<br />
<br />
=====Example: Tap-to-click=====<br />
Tap-to-click can be enabled in the mouse configuration dialog (in the touchpad tab) but if you need tapping enabled at gdm already, the following snippet does it for you:<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "tap-by-default"<br />
MatchIsTouchpad "on"<br />
Option "TapButton1" "1"<br />
EndSection<br />
}}<br />
<br />
=====Example: Keyboard layout and model on Acer 5920G Laptop=====<br />
<br />
Keyboard model and layout may be set in the file {{ic|/etc/X11/xorg.conf.d/keyboard.conf}} or any other .conf file in the same directory.<br />
* {{ic|MatchIsKeyboard "yes"}}: set the input device to a keyboard<br />
* {{ic|Option "XkbModel" "acer_laptop"}}: set the keyboard model to an Acer * {{ic|Option "XkbLayout" "be"}}: set the keyboard layout to belgian. You may replace {{ic|be}} with whatever layout you have.<br />
* {{ic|Option "XkbVariant" "sundeadkeys"}}: set the layout variant to Sun dead keys. You may omit the {{ic|XkbVariant}} option if you stick with the default variant.<br />
laptop keyboard. You may replace {{ic|acer_laptop}} with your actual keyboard layout.<br />
<br />
Note that a list of keyboard layouts and models can be found in {{ic|/usr/share/X11/xkb/rules/base.lst}}<br />
<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "Keyboard Defaults"<br />
MatchIsKeyboard "yes"<br />
Option "XkbModel" "acer_laptop"<br />
Option "XkbLayout" "be"<br />
Option "XkbVariant" "sundeadkeys"<br />
EndSection<br />
}}<br />
<br />
==Graphics==<br />
===Driver installation===<br />
The default graphics driver is vesa ({{Pkg|xf86-video-vesa}}), which handles a large number of chipsets but does not include any 2D or 3D acceleration. To enable graphics acceleration, you will need to install and use the driver specific to your graphics card.<br />
<br />
First, identify your card:<br />
$ lspci | grep VGA<br />
<br />
Then, install an appropriate driver. You can search for these packages with the following command:<br />
$ pacman -Ss xf86-video<br />
<br />
Common open source drivers:<br />
*NVIDIA: {{Pkg|xf86-video-nouveau}} (see [[Nouveau]])<br />
*Intel: {{Pkg|xf86-video-intel}} (see [[Intel]])<br />
*ATI: {{Pkg|xf86-video-ati}} (see [[ATI]])<br />
<br />
Common proprietary drivers:<br />
*NVIDIA: {{Pkg|nvidia}} (see [[NVIDIA]])<br />
*ATI: {{AUR|catalyst}} (see [[ATI Catalyst]])<br />
<br />
Xorg should run smoothly without closed source drivers, which are typically needed only for advanced features such as fast 3D-accelerated rendering for games, dual-screen setups, and TV-out.<br />
<br />
===Monitor settings===<br />
====Getting started====<br />
{{Note|This step is OPTIONAL and should not be done unless you know what you are doing.<br><br />
This step is '''NOT OPTIONAL''' if using dual monitors or the nouveau driver. See [[Nouveau#Configuration]].}}<br />
<br />
First, create a new config file, such as {{ic|/etc/X11/xorg.conf.d/10-monitor.conf}}.<br />
<br />
Insert the following code into the config file mentioned above:<br />
<br />
{{bc|<nowiki><br />
Section "Monitor"<br />
Identifier "Monitor0"<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "Device0"<br />
Driver "vesa" #Choose the driver used for this monitor<br />
EndSection<br />
<br />
Section "Screen"<br />
Identifier "Screen0" #Collapse Monitor and Device section to Screen section<br />
Device "Device0"<br />
Monitor "Monitor0"<br />
DefaultDepth 16 #Choose the depth (16||24)<br />
SubSection "Display"<br />
Depth 16<br />
Modes "1024x768_75.00" #Choose the resolution<br />
EndSubSection<br />
EndSection<br />
</nowiki>}}<br />
<br />
====Multiple monitors/Dual screen====<br />
=====NVIDIA=====<br />
Please see: [[NVIDIA#Multiple monitors]].<br />
<br />
=====More than one graphics card=====<br />
You must define the correct driver to use and put the bus ID of your graphic cards.<br />
{{bc|<br />
Section "Device"<br />
Identifier "Screen0"<br />
Driver "nouveau"<br />
BusID "PCI:0:12:0"<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "Screen1"<br />
Driver "radeon"<br />
BusID "PCI:1:0:0"<br />
EndSection<br />
}}<br />
<br />
To get your bus ID:<br />
$ lspci | grep VGA<br />
01:00.0 VGA compatible controller: nVidia Corporation G96 [GeForce 9600M GT] (rev a1)<br />
<br />
The bus ID here is 1:0:0.<br />
<br />
=====Script to toggle internal/external display for laptops=====<br />
Script can be used to the keyboard shortcut.<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
IN="LVDS1"<br />
EXT="VGA1"<br />
<br />
if (xrandr | grep "$EXT" | grep "+")<br />
then<br />
xrandr --output $EXT --off --output $IN --auto<br />
else<br />
if (xrandr | grep "$EXT" | grep " connected")<br />
then<br />
xrandr --output $IN --off --output $EXT --auto<br />
fi<br />
fi<br />
</nowiki>}}<br />
<br />
Internal/external display names you can check:<br />
# xrandr -q<br />
<br />
If you do not have {{ic|xrandr}}, [[pacman|install]] {{Pkg|xorg-xrandr}} to use it.<br />
<br />
==== Display Size and DPI ====<br />
The DPI of the X server is determined in the following manner:<br />
# The -dpi command line option has highest priority.<br />
# If this is not used, the DisplaySize setting in the X config file is used to derive the DPI, given the screen resolution.<br />
# If no DisplaySize is given, the monitor size values from DDC are used to derive the DPI, given the screen resolution.<br />
# If DDC does not specify a size, 75 DPI is used by default.<br />
<br />
In order to get correct dots per inch (DPI) set, the display size must be recognized or set. Having the correct DPI is especially necessary where fine detail is required (like font rendering). Previously, manufacturers tried to create a standard for 96 DPI (a 10.3" diagonal monitor would be 800x600, a 13.2" monitor 1024x768). These days, screen DPIs vary and may not be equal horizontally and vertically. For example, a 19" widescreen LCD at 1440x900 may have a DPI of 89x87. To be able to set the DPI, the Xorg server attempts to auto-detect your monitor's physical screen size through the graphic card with [http://en.wikipedia.org/wiki/Display_Data_Channel DDC]. When the Xorg server knows the physical screen size, it will be able to set the correct DPI depending on resolution size.<br />
<br />
To see if your display size and DPI are detected/calculated correctly:<br />
<br />
$ xdpyinfo | grep -B2 resolution<br />
<br />
Check that the dimensions match your display size. If the Xorg server is not able to correctly calculate the screen size, it will default to 75x75 DPI and you will have to calculate it yourself.<br />
<br />
If you have specifications on the physical size of the screen, they can be entered in the Xorg configuration file so that the proper DPI is calculated:<br />
<br />
{{bc|<br />
Section "Monitor"<br />
Identifier "Monitor0"<br />
DisplaySize 286 179 # In millimeters<br />
EndSection<br />
}}<br />
<br />
If you only want to enter the specification of your monitor '''without''' creating a full xorg.conf create a new config file. For example ({{ic|/etc/X11/xorg.conf.d/90-monitor.conf}}):<br />
<br />
{{bc|<br />
Section "Monitor"<br />
Identifier "<default monitor>"<br />
DisplaySize 286 179 # In millimeters<br />
EndSection<br />
}}<br />
<br />
If you do not have specifications for physical screen width and height (most specifications these days only list by diagonal size), you can use the monitor's native resolution (or aspect ratio) and diagonal length to calculate the horizontal and vertical physical dimensions. Using the Pythagorean theorem on a 13.3" diagonal length screen with a 1280x800 native resolution (or 16:10 aspect ratio):<br />
<br />
echo 'scale=2;sqrt(1280^2+800^2)' | bc # 1509.43698<br />
<br />
This will give the pixel diagonal length and with this value you can discover the physical horizontal and vertical lengths (and convert them to millimeters):<br />
<br />
{{bc|<nowiki><br />
echo 'scale=2;(13.3/1509)*1280*25.4' | bc # 286.43072<br />
echo 'scale=2;(13.3/1509)*800*25.4' | bc # 179.01920<br />
</nowiki>}}<br />
<br />
{{Note|This calculation works for monitors with square pixels; however, there is the seldom monitor that may compress aspect ratio (e.g 16:10 aspect resolution to a 16:9 monitor). If this is the case, you should measure your screen size manually.}}<br />
<br />
===== Setting DPI manually =====<br />
DPI can be set manually if you only plan to use one resolution ([http://pxcalc.com/ DPI calculator]):<br />
<br />
{{bc|<br />
Section "Monitor"<br />
Identifier "Monitor0"<br />
Option "DPI" "96 x 96"<br />
EndSection<br />
}}<br />
<br />
If you use an NVIDIA card, you can manually set the DPI adding the options bellow on {{ic|/etc/X11/xorg.conf.d/20-nvidia.conf}} (inside '''Device''' section):<br />
<br />
Option "UseEdidDpi" "False"<br />
Option "DPI" "96 x 96"<br />
<br />
For RandR compliant drivers, you can set it by:<br />
<br />
xrandr --dpi 96<br />
<br />
See [[Execute commands after X start]] to make it permanent.<br />
<br />
====DPMS====<br />
DPMS (Display Power Management Signaling) is a technology that allows power saving behaviour of monitors when the computer is not in use. This will allow you to have your monitors automatically go into standby after a predefined period of time. See: [[DPMS]]<br />
<br />
== Composite ==<br />
The Composite extension for X causes an entire sub-tree of the window hierarchy to be rendered to an off-screen buffer. Applications can then take the contents of that buffer and do whatever they like. The off-screen buffer can be automatically merged into the parent window or merged by external programs, called compositing managers.<br />
<br />
{{Accuracy}}<br />
{{Box YELLOW||Is this actually still true in recent Xorg releases?}}<br />
The Composite extension can't be used simultaneously with Xinerama. However, it can be used simultaneously with Nvidia Twinview.<br />
<br />
=== Disabling the extension ===<br />
The composite extension is enabled by default. To disable it, add this to xorg.conf or a file in /etc/xorg.conf.d:<br />
<br />
Section "Extensions"<br />
Option "Composite" "Disable"<br />
EndSection<br />
<br />
This may slightly improve your performance with some drivers.<br />
<br />
=== See also ===<br />
*[[AIGLX]]<br />
*[[Compiz]] -- The original composite/window manager from Novell<br />
*[[Xcompmgr]] -- A simple composite manager capable of drop shadows and primitive transparency<br />
*[[Cairo Compmgr|Cairo Composite Manager]] -- A versatile and extensible composite manager which uses cairo for rendering.<br />
*[[Wikipedia:Compositing window manager]]<br />
<br />
==Sample configurations==<br />
Anyone who has an {{ic|xorg.conf}} file written up that works, go ahead and post a link to it here for others to look at. Please do not in-line the entire configuration file; upload it somewhere else and link to it.<br />
<br />
'''Please post input hotplugging configurations only, otherwise note that your config is not using input hotplugging.''' (Xorg 1.8 = udev)<br />
<br />
=== Sample 1: {{ic|xorg.conf}} & {{ic|/etc/X11/xorg.conf.d/10-evdev.conf}} ===<br />
This is a sample configuration file using {{ic|/etc/X11/xorg.conf.d/10-evdev.conf}} for the keyboard layouts:<br />
<br />
{{Note|The "InputDevice" sections are commented out, because {{ic|/etc/X11/xorg.conf.d/10-evdev.conf}} is taking care of them.}}<br />
{{ic|xorg.conf}}: http://pastebin.com/raw.php?i=EuSKahkn<br />
{{ic|/etc/X11/xorg.conf.d/10-evdev.conf}}: http://pastebin.com/raw.php?i=4mPY35Mw<br />
{{ic|/etc/X11/xorg.conf.d/10-monitor.conf}} (VMware): http://pastebin.com/raw.php?i=fJv8EXGb<br />
{{ic|/etc/X11/xorg.conf.d/10-monitor.conf}} (KVM): http://pastebin.com/raw.php?i=NRz7v0Kn<br />
<br />
==Tips and tricks==<br />
===X startup ({{ic|/usr/bin/startx}}) tweaking===<br />
For X's option reference see:<br />
$ man Xserver<br />
<br />
The following options have to be appended to the variable {{ic|"defaultserverargs"}} in the {{ic|/usr/bin/startx}} file:<br />
<br />
* Enable deferred glyph loading for 16 bit fonts:<br />
-deferglyphs 16<br />
<br />
{{Note|1=If you start X with kdm, the startx script does not seem to be executed. X options must be appended to the variable {{ic|"ServerArgsLocal"}} or {{ic|"ServerCmd"}} in the {{ic|/usr/share/config/kdm/kdmrc}} file. By default kdm options are:<br />
{{bc|1=ServerArgsLocal=-nolisten tcp<br />
ServerCmd=/usr/bin/X}}<br />
}}<br />
<br />
===Virtual X session===<br />
To start another X session in, for example, {{Keypress|Ctrl+Alt+F8}}, you need to type this on a console:<br />
xinit /path/to/wm -- :1<br />
<br />
Change "/path/to/wm" to your window manager start file or to your login manager like gdm, kdm, or slim.<br />
<br />
===Nested X session===<br />
To run a nested session of another desktop environment:<br />
$ /usr/bin/Xnest :1 -geometry 1024x768+0+0 -ac -name Windowmaker & wmaker -display :1<br />
<br />
This will launch a Window Maker session in a 1024 by 768 window within your current X session.<br />
<br />
This needs the package {{Pkg|xorg-server-xnest}} to be installed.<br />
<br />
==Troubleshooting==<br />
===Common problems===<br />
If Xorg will not start, the screen is completely black, the keyboard and mouse are not working, etc., first take these simple steps:<br />
*Check the log file: {{ic|cat /var/log/Xorg.0.log}}<br />
*Install input driver (keyboard, mouse, joystick, tablet, etc...):<br />
*Finally, search for common problems in [[ATI]], [[Intel]] and [[NVIDIA]] articles.<br />
<br />
===Ctrl+Alt+Backspace does not work===<br />
There are two ways of restoring {{Keypress|Ctrl+Alt+Backspace}}; with and without input-hotplugging. Using hot-plugging is recommended.<br />
<br />
====With input hot-plugging====<br />
=====System-wide=====<br />
Within {{ic|/etc/X11/xorg.conf.d/10-evdev.conf}}, simply add the following:<br />
{{bc|<br />
Section "InputClass"<br />
Identifier "Keyboard Defaults"<br />
MatchIsKeyboard "yes"<br />
Option "XkbOptions" "terminate:ctrl_alt_bksp"<br />
EndSection<br />
}}<br />
<br />
{{Note|On KDE, this system-wide setting has no effect. To restore, go to Kickoff > Computer > System Settings which will open up the System Settings window. Click on 'Input Devices'. In this new window click the Keyboard tab and then click on the advanced tab. In this new window, click the box for 'Configure keyboard options.' Expand the entry for 'Key sequence to kill the X server' and ensure {{keypress|Ctrl+Alt+Backspace}} is checked. Click Apply and close the System Settings window. You now have your {{keypress|Ctrl+Alt+Backspace}} back in KDE.}}<br />
<br />
=====User-specific=====<br />
Another way is to put this line in [[xinitrc]]:<br />
setxkbmap -option terminate:ctrl_alt_bksp<br />
<br />
{{Note|This setting has no effect on Gnome 3.}}<br />
<br />
====Without input hot-plugging====<br />
New Xorg disables zapping with {{keypress|Ctrl+Alt+Backspace}} by default. You can enable it by adding the following line to {{ic|/etc/X11/xorg.conf}},<br />
Option "XkbOptions" "terminate:ctrl_alt_bksp"<br />
to {{ic|InputDevice}} section for keyboard.<br />
<br />
===Apple keyboard issues===<br />
:''See: [[Apple Keyboard]]''<br />
<br />
===Touchpad tap-click issues===<br />
:''See: [[Synaptics]]''<br />
<br />
===Extra mouse buttons not recognized===<br />
:''See: [[Get All Mouse Buttons Working]]''<br />
<br />
===X clients started with "su" fail===<br />
If you are getting "Client is not authorized to connect to server", try adding the line:<br />
session optional pam_xauth.so<br />
to {{ic|/etc/pam.d/su}}. {{ic|pam_xauth}} will then properly set environment variables and handle {{ic|xauth}} keys.<br />
<br />
===Program requests "font '(null)'"===<br />
*Error message: "''unable to load font `(null)'.''"<br />
Some programs only work with bitmap fonts. Two major packages with bitmap fonts are available, {{Pkg|xorg-fonts-75dpi}} and {{Pkg|xorg-fonts-100dpi}}. You do not need both; one should be enough. To find out which one would be better in your case, try this:<br />
$ xdpyinfo | grep resolution<br />
and use what is closer to you (75 or 100 instead of XX)<br />
# pacman -S xorg-fonts-XXdpi<br />
<br />
===Frame-buffer mode problems===<br />
If X fails to start with the following log messages,<br />
{{bc|<nowiki><br />
(WW) Falling back to old probe method for fbdev<br />
(II) Loading sub module "fbdevhw"<br />
(II) LoadModule: "fbdevhw"<br />
(II) Loading /usr/lib/xorg/modules/linux//libfbdevhw.so<br />
(II) Module fbdevhw: vendor="X.Org Foundation"<br />
compiled for 1.6.1, module version=0.0.2<br />
ABI class: X.Org Video Driver, version 5.0<br />
(II) FBDEV(1): using default device<br />
<br />
Fatal server error:<br />
Cannot run in framebuffer mode. Please specify busIDs for all framebuffer devices<br />
</nowiki>}}<br />
uninstall fbdev:<br />
# pacman -R xf86-video-fbdev<br />
<br />
===DRI with Matrox cards stops working===<br />
If you use a Matrox card and DRI stops working after upgrading to Xorg, try adding the line:<br />
Option "OldDmaInit" "On"<br />
to the Device section that references the video card in {{ic|xorg.conf}}.<br />
<br />
===Recovery: disabling Xorg before GUI login===<br />
If Xorg is set to boot up automatically and for some reason you need to prevent it from starting up before the login/display manager appears (if {{ic|/etc/rc.conf}} is wrongly configured and Xorg does not recognize your mouse or keyboard input, for instance), you can accomplish this task with two methods.<br />
<br />
*From the GRUB menu, you can specify the runlevel in the kernel line by adding a number to the end of the kernel line specifying the run level you want. The following example sets the run level to 3:<br />
kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/..ro 3<br />
<br />
*If you have not only a faulty {{ic|/etc/rc.conf}} to make Xorg unusable, but you have also set the GRUB menu wait time to zero, or cannot otherwise use GRUB to prevent Xorg from booting, you can use the Arch Linux live CD. Boot up the live CD and login as root. You need a mount point, such as {{ic|/mnt}}, and you need to know the name of the partition you want to mount.<br />
<br />
:You can use the command,<br />
# fdisk -l<br />
:to see your partitions. Usually, the one you want will be resembling {{ic|/dev/sda1}}. Then, to mount this to {{ic|/mnt}}, use<br />
# mount /dev/sda1 /mnt<br />
<br />
:Then your filesystem will show up under {{ic|/mnt}}. So your {{ic|/etc/rc.conf}} file, for example, would be in {{ic|/mnt/etc/rc.conf}}. From here you can delete the {{ic|gdm}} daemon to prevent Xorg from booting up normally or make any other necessary changes to the configuration.<br />
<br />
===X failed to start : Keyboard initialization failed===<br />
If your hard disk is full, startx will fail. {{ic|/var/log/Xorg.0.log}} will end with:<br />
(EE) Error compiling keymap (server-0)<br />
(EE) XKB: Couldn't compile keymap<br />
(EE) XKB: Failed to load keymap. Loading default keymap instead.<br />
(EE) Error compiling keymap (server-0)<br />
(EE) XKB: Couldn't compile keymap<br />
XKB: Failed to compile keymap<br />
Keyboard initialization failed. This could be a missing or incorrect setup of xkeyboard-config.<br />
Fatal server error:<br />
Failed to activate core devices.<br />
Please consult the The X.Org Foundation support at http://wiki.x.org<br />
for help.<br />
Please also check the log file at "/var/log/Xorg.0.log" for additional information.<br />
(II) AIGLX: Suspending AIGLX clients for VT switch<br />
<br />
Make some free space on your root partition and X will start.</div>Clickthemhttps://wiki.archlinux.org/index.php?title=Talk:NVIDIA&diff=187650Talk:NVIDIA2012-03-05T00:16:01Z<p>Clickthem: /dev/nvidia0 issues</p>
<hr />
<div>== Comments ==<br />
<br />
Nice documentation. Thanks to contributors. --[[User:Gen2ly|Gen2ly]] 07:53, 17 October 2009 (EDT)<br />
<br />
----<br />
<br />
== Suggestions ==<br />
<br />
NVoption Online Version - great tool to make tv-out easy and fast <br />
<br />
[I'm using gmplayer with gl and twinview]<br />
[http://www.sorgonet.com/linux/nv-online/]http://www.sorgonet.com/linux/nv-online/<br />
<br />
----<br />
<br />
Since most of the wiki is aimed at new users anyway: why differentiate between the Xorg client and server? [[User:Manolo|manolo]] 19:23, 9 November 2009 (EST)<br />
<br />
: Just got to say thanks for you edits Manolo, you're doing a great job on the wiki. As for Xorg naming, their is no client only a server ([http://en.wikipedia.org/wiki/Xorg Wikepedia]). However, the nomenclature of it is a bit awkward. Xorg server got its' name from when the popular design philosophy was that computer hubs would essential be dum-terminals (i.e. not have an graphic card) and one machine would handle the graphic load. It's sort of an outdated (and awkward) term now but is still used and the proper and common wording.<br />
:: --[[User:Gen2ly|Gen2ly]] 01:34, 10 November 2009 (EST)<br />
<br />
:: Thanks for the clarification/compliments. So if I understand correctly, "Xorg" is referring to "Xorg server"? [[User:Manolo|manolo]] 02:05, 10 November 2009 (EST)<br />
<br />
----<br />
Maybe someone can put this in better words:<br />
Logging out, or switching to a different terminal using ctrl+alt+F<2-9> consistently resulted in a black screen, and killing Xorg with ctrl-alt-backspace resulted in a terminal screen with only the top line visible. It turned out that a 'vga=773' added to kernel line was the cause of this. After removing that the problem was solved. Probably something to do with KMS? B.t.w. I have only used x with 'startx', so possibly specific for that way of starting X.<br />
[[User:rwd|rwd]]<br />
<br />
:Was it with this driver or nouveau? The proprietary drivers don't have KMS. [[User:Thestinger|thestinger]] 17:42, 13 December 2010 (EST)<br />
<br />
This was with the proprietary driver. I originally had put vga=.. because it made gave the bootup screen a higher resolution, and because the beginners guide mentions it (https://wiki.archlinux.org/index.php/Beginners%27_Guide#GRUB). Apart from leaving out the vga option, I discovered that setting it to the native resolution as explained on https://wiki.archlinux.org/index.php/GRUB#Framebuffer_resolution fixes the black screens as well. Maybe a warning for using vga= option with with proprietary drivers would be useful.[[User:rwd|rwd]]<br />
<br />
Well the thing is that vga= is meant for the proprietary drivers only - open source drivers already set the native resolution without a vga command. It can be removed from the beginners' guide though, since it breaks open source drivers, and if the card doesn't support the vga command, it breaks the closed source ones too. [[User:Thestinger|thestinger]] 20:13, 13 December 2010 (EST)<br />
<br />
== Reboot after installing the driver ==<br />
It's mentioned [https://wiki.archlinux.org/index.php?title=NVIDIA&diff=122995&oldid=prev#Errors_after_updating_the_kernel here]: ''Rebooting is generally recommended after updating kernel and graphic drivers.'' <br />
<br />
I created a Tip at the end of the Install section saying just that, because many people install the drivers, 'startx' and <sadface>.<br />
<br />
== /var/abs/extra/nvidia/ no such file or directory ==<br />
<br />
When trying to follow this page's instructions regarding a custom kernel, after successfully installing abs I am unable to cp -r /var/abs/extra/nvidia/ because I get a no such file or directory error. In fact, there is nothing in /var/abs/ except "README" and a "local" directory, which also has no "extra" or "nvidia" dir. Are these instructions outdated? [[User:Brianwc|Brianwc]] 12:43, 7 January 2011 (EST)<br />
:That's because the abs package just contains the tools, you still need to run the abs command to sync the abs tree. Try 'sudo abs extra/nvidia' --[[User:Solarshado|Solarshado]] 09:32, 22 July 2011 (EDT)<br />
<br />
== Nvidia 173xx ==<br />
The nvidia-173xx package no longer exists (29 Oct 2011). <br />
<br />
Has it been replaced by nvidia-173xx-all? If so, this package hasn't been updated since Feb 2011.<br />
<br />
Will it need to be updated to be able to use the latest xorg 1.11? <br />
<br />
In the meantime, please include instructions for which xorg related packages pacman should ignore.<br />
:[http://mailman.archlinux.org/pipermail/arch-dev-public/2011-October/021764.html] -- [[User:Karol|Karol]] 21:14, 28 October 2011 (EDT)<br />
::I commented out the info about older drivers, since they're not compatible with Xorg 1.11. Maybe if someone create the appropriate packages for Xorg 1.10 in AUR, then we could add back some info, but until it's misleading I think. --[[User:City-busz|City-busz]] 23:32, 3 November 2011 (EDT)<br />
:::nvidia-96xx and nvidia-71xx are in the AUR, you can't use pacman to install them. -- [[User:Karol|Karol]] 00:03, 4 November 2011 (EDT)<br />
::::You can't install these packages from AUR, because they requires Xorg 1.10/1.7, which is not available in official repos, nor in AUR. Once NVidia make them compatible with Xorg 1.11, then someone should add them back to the official repos. Another option is to someone create xorg-server-1.10, xf86-input-evdev-1.10 etc. packages to support these drivers. --[[User:City-busz|City-busz]] 01:31, 4 November 2011 (EDT)<br />
:::::You can use [[Downgrading_Packages#ARM|ARM]] or some other mirror that holds old packages and still use nvidia-173xx and older drivers. My question is, why did you put {{ic|# pacman -S nvidia-96xx nvidia-96xx-utils}} instead of "install {{AUR|nvidia-96xx-all}} and {{AUR|nvidia-96xx-utils}} from the [[AUR]]."??<br />
:::::The latter still works with out of date packages while the former does not, because I'm not aware of any repo that has nvidia-96xx. -- [[User:Karol|Karol]] 09:06, 4 November 2011 (EDT)<br />
::::::It's possible, but it requires further explanation (maybe in a new section). Simply install nvidia-* packages from AUR is not work currently. --[[User:City-busz|City-busz]] 10:20, 4 November 2011 (EDT)<br />
:::::::And installing them with pacman does work? I still don't get this change. -- [[User:Karol|Karol]] 11:16, 4 November 2011 (EDT)<br />
<br />
== custom kernel ==<br />
<br />
The package changed for kernel 3.0 and the instructions no longer work. Please fix this. [[User:Z.T.|Z.T.]] 09:14, 23 November 2011 (EST)<br />
<br />
<br />
== '/dev/nvidia0' Input/Output error... suggested fixes ==<br />
<br />
Can anyone verify that the BIOS related suggestions work and are not coincidentally set (either automatically when changing the IRQ or turning off ACPI) while troubleshooting? I have found little information that confirms any of the suggestions would work. The file permissions thing seems to be completely unfounded and never works (as noted in the article) that I could find. It would probably be a good idea if we cleaned out items that have not been verified to work. For my setup I was having this error and none of the items in the wiki nor the many file permission search results worked. -- [[User:Clickthem|click, them so hard]] 19:16, 4 March 2012 (EST)</div>Clickthemhttps://wiki.archlinux.org/index.php?title=NVIDIA&diff=187646NVIDIA2012-03-05T00:01:09Z<p>Clickthem: /* '/dev/nvidia0' Input/Output error */ added IOMMU defect information</p>
<hr />
<div>[[Category: Graphics (English)]]<br />
[[Category: X Server (English)]]<br />
{{i18n|NVIDIA}}<br />
[[de:Nvidia]]<br />
[[fr:Nvidia]]<br />
{{Article summary start}}<br />
{{Article summary text|Information on installing, configuring and troubleshooting the proprietary NVIDIA Drivers.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|ATI}}<br />
{{Article summary wiki|Intel}}<br />
{{Article summary wiki|Nouveau}}<br />
{{Article summary wiki|Xorg}}<br />
{{Article summary end}}<br />
<br />
This article covers installing and configuring [http://www.nvidia.com NVIDIA]'s ''proprietary'' graphic card driver. For information about the open-source drivers, see [[Nouveau]].<br />
<br />
==Installing==<br />
These instructions are for those using the stock {{Pkg|linux}} package. For custom kernel setup, skip to the [[#Alternate install: custom kernel|next]] subsection.<br />
<br />
{{Tip|It is usually beneficial to install the NVIDIA driver through [[pacman]] rather than through the package provided by the NVIDIA site, this allows the driver to be updated when upgrading the system.}}<br />
<br />
1. Visit NVIDIA's [http://www.nvidia.com/Download/index.aspx?lang=en-us driver download site] to find out the appropriate driver for a given card.<br />
:{{Note|Currently nvidia-173xx, nvidia-96xx and nvidia-71xx drivers do not support Xorg release 1.11, and therefore are not available in the [[Official Repositories]]. You can use the [[nouveau]] open source driver instead.}}<br />
<br />
2. Install the driver for newer cards (newest GPUs, GeForce 6 and newer [NV40 and newer]):<br />
:{{bc|# pacman -S nvidia nvidia-utils}}<br />
<br />
<!-- These drivers are not compatible with the latest Xorg release in the official repo.<br />
<br />
:Whereas users with older cards should install (GeForce 5 FX series cards [NV30-NV38]):<br />
:{{bc|# pacman -S nvidia-173xx nvidia-173xx-utils}}<br />
<br />
:or (GeForce2 MX, GeForce3 and GeForce4 series cards [NV11 and NV17-NV28]):<br />
:{{bc|# pacman -S nvidia-96xx nvidia-96xx-utils}}<br />
<br />
:or (Riva TNT, TNT2, GeForce and GeForce2 series cards [NV03-NV10 and NV15-NV16]):<br />
:{{bc|# pacman -S nvidia-71xx nvidia-71xx-utils}}<br />
<br />
--><br />
:The nvidia<!--{,-173xx,-96xx,-71xx}-->-utils package conflict with the libgl package. This is normal. If pacman asks to remove libgl and fails due to unsatisfied dependencies remove libgl with {{ic|# pacman -Rdd libgl}}.<br />
<br />
{{Note|For the latest card models, it may be required to install {{AUR|nvidia-beta}} and {{AUR|nvidia-utils-beta}} from the [[AUR]] since the stable drivers may not support the newly introduced features.}}<br />
{{Note|On 64 bit systems, for 32 bit programs to take advantage of nvidia-utils you must also install the equivalent lib32 package (eg. {{Pkg|lib32-nvidia-utils}} or {{AUR|lib32-nvidia-utils-beta}}).}}<br />
<br />
3. '''Reboot'''. The nvidia<!--{,-173xx,-96xx,-71xx}--> package contains a file which blacklists the nouveau module. A reboot is necessary for this blacklist to take effect.<br />
<br />
Once the driver has been installed, continue to: [[#Configuring]].<br />
<br />
===Alternate install: custom kernel===<br />
{{Out of date}}<br />
First of all, it is of advantage to know how the ABS system works by reading some of the other articles about it:<br />
* Main article for [[ABS]]<br />
* Article on [[makepkg]]<br />
* Article on [[Creating Packages]]<br />
<br />
{{Note|There is the {{AUR|nvidia-all}} package on [[AUR]] which turns out to make it easier to install the NVIDIA driver for custom kernels and multiple kernels}}<br />
<br />
The following is a short tutorial for making a custom NVIDIA driver package using [[ABS]]:<br />
<br />
Install ABS and generate the tree:<br />
# pacman -S abs<br />
# abs<br />
As a standard user, make a temporary directory for creating the new package:<br />
$ mkdir -p ~/abs<br />
Make a copy of the {{ic|nvidia}} package directory:<br />
$ cp -r /var/abs/extra/nvidia/ ~/abs/<br />
Go into the temporary {{ic|nvidia}} build directory:<br />
$ cd ~/abs/nvidia<br />
It is required to edit the files {{ic|nvidia.install}} and {{ic|PKGBUILD}} file so that they contain the right kernel version variables.<br />
<br />
While running the custom kernel, get the appropriate kernel and local version names:<br />
$ uname -r<br />
# In nvidia.install, replace the {{ic|KERNEL_VERSION<nowiki>=</nowiki>"2.6.xx-ARCH"}} variable with the custom kernel version, such as {{ic|KERNEL_VERSION<nowiki>=</nowiki>"2.6.22.6"}} or {{ic|KERNEL_VERSION<nowiki>=</nowiki>"2.6.22.6-custom"}} depending on what the kernel's version is and the local version's text/numbers. Do this for all instances of the version number within this file.<br />
# In PKGBUILD, change the {{ic|_kernver<nowiki>=</nowiki>'2.6.xx-ARCH'}} variable to match the appropriate version, as above.<br />
# If there are more than one kernels in the system installed in parallel, (such as a custom kernel alongside the default -ARCH kernel) change the {{ic|"pkgname<nowiki>=</nowiki>nvidia"}} variable in the PKGBUILD to a unique identifier, such as nvidia-2622 or nvidia-custom. This will allow both kernels to use the nvidia module, since the custom nvidia module has a different package name and will not overwrite the original. You will also need to comment the line in {{ic|package()}} that creates {{ic|/etc/modprobe.d/nouveau_blacklist.conf}} (else pacman will complain that it already exists).<br />
<br />
Then do:<br />
$ makepkg -ci<br />
The {{ic|-c}} operand tells makepkg to clean left over files after building the package, whereas {{ic|-i}} specifies that makepkg should automatically run pacman to install the resulting package.<br />
<br />
==Configuring==<br />
It is possible that after installing the driver it may not be needed to create an Xorg server configuration file. You can run [[Xorg#Running Xorg| a test]] to see if the Xorg server will function correctly without a configuration file. However, it may be required to create a {{ic|/etc/X11/xorg.conf}} configuration file in order to adjust various settings. This configuration can be generated by the NVIDIA Xorg configuration tool, or it can be created manually. If created manually, it can be a minimal configuration (in the sense that it will only pass the basic options to the [[Xorg]] server), or it can include a [[Xorg#Manual configuration|number of settings]] that can bypass Xorg's auto-discovered or pre-configured options.<br />
:{{Note|Since 1.8.x Xorg uses separate configuration files in {{ic|/etc/X11/xorg.conf.d}} - check out [[NVIDIA#Advanced:_20-nvidia.conf|advanced configuration]] section.}}<br />
<br />
===Automatic configuration===<br />
The NVIDIA package includes an automatic configuration tool to create an Xorg server configuration file ({{ic|xorg.conf}}) and can be run by:<br />
# nvidia-xconfig<br />
<br />
This command will auto-detect and create (or edit, if already present) the {{ic|/etc/X11/xorg.conf}} configuration according to present hardware.<br />
<br />
If there are instances of DRI, ensure they are commented out:<br />
# Load "dri"<br />
Double check your {{ic| /etc/X11/xorg.conf}} to make sure your default depth, horizontal sync, vertical refresh, and resolutions are acceptable.<br />
<br />
{{Warning| That may still not work properly with Xorg-server 1.8 }}<br />
<br />
===Minimal configuration===<br />
A basic {{ic|xorg.conf}} would look like this:<br />
<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "Device"<br />
Identifier "Device0"<br />
Driver "nvidia"<br />
VendorName "NVIDIA Corporation"<br />
EndSection<br />
}}<br />
<br />
{{Tip|If upgrading from nouveau make sure to remove "{{ic|nouveau}}" from {{ic|/etc/mkinitcpio.conf}}. See [[NVIDIA#Switching_between_nvidia_and_nouveau_drivers]], if switching between the open and proprietary drivers often.}}<br />
<br />
=== Multiple monitors ===<br />
<br />
To activate dual screen support, you just need to edit the {{ic|/etc/X11/xorg.conf.d/10-monitor.conf}} file which you made before.<br />
<br />
Per each physical monitor, add one Monitor, Device, and Screen Section entry, and then a ServerLayout section to manage it. Be advised that when Xinerama is enabled, the NVIDIA proprietary driver automatically disables compositing. If you desire compositing, you should comment out the {{ic|Xinerama}} line in "{{ic|ServerLayout}}" and use TwinView (see below) instead.<br />
<br />
{{hc|/etc/X11/xorg.conf.d/10-monitor.conf|<br />
Section "ServerLayout"<br />
Identifier "DualSreen"<br />
Screen 0 "Screen0"<br />
Screen 1 "Screen1" RightOf "Screen0" #Screen1 at the right of Screen0<br />
Option "Xinerama" "1" #To move windows between screens<br />
EndSection<br />
<br />
Section "Monitor"<br />
Identifier "Monitor0"<br />
Option "Enable" "true"<br />
EndSection<br />
<br />
Section "Monitor"<br />
Identifier "Monitor1"<br />
Option "Enable" "true"<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "Device0"<br />
Driver "nvidia"<br />
Screen 0<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "Device1"<br />
Driver "nvidia"<br />
Screen 1<br />
EndSection<br />
<br />
Section "Screen"<br />
Identifier "Screen0"<br />
Device "Device0"<br />
Monitor "Monitor0"<br />
DefaultDepth 24<br />
Option "TwinView" "0"<br />
SubSection "Display"<br />
Depth 24<br />
Modes "1280x800_75.00"<br />
EndSubSection<br />
EndSection<br />
<br />
Section "Screen"<br />
Identifier "Screen1"<br />
Device "Device1"<br />
Monitor "Monitor1"<br />
DefaultDepth 24<br />
Option "TwinView" "0"<br />
SubSection "Display"<br />
Depth 24<br />
EndSubSection<br />
EndSection<br />
}}<br />
<br />
====TwinView====<br />
You want only one big screen instead of two. Set the {{ic|TwinView}} argument to {{ic|1}}. This option should be used instead of Xinerama (see above), if you desire compositing.<br />
Option "TwinView" "1"<br />
<br />
=====Automatic configuration =====<br />
The NVIDIA package provides Twinview. This tool will help by automatically configuring all the monitors connected to your video card. This only works for multiple monitors on a single card.<br />
To configure Xorg Server with Twinview run:<br />
# nvidia-xconfig --twinview<br />
<br />
====Using NVIDIA Settings====<br />
You can also use the {{ic|nvidia-settings}} tool provided by {{Pkg|nvidia-utils}}. With this method, you will use the proprietary software NVIDIA provides with their drivers. Simply run {{ic|nvidia-settings}} as root, then configure as you wish, and then save the configuration to {{ic|/etc/X11/xorg.conf.d/10-monitor.conf}}.<br />
<br />
==Tweaking==<br />
<br />
===GUI: nvidia-settings===<br />
The NVIDIA package includes the {{ic|nvidia-settings}} program that allows adjustment of several additional settings.<br />
<br />
For the settings to be loaded on login, run this command from the terminal:<br />
$ nvidia-settings --load-config-only<br />
<br />
Or add it to the the desktop environment's auto-startup method.<br />
<br />
For a dramatic 2D graphics performance increase in pixmap-intensive applications, e.g. Firefox, set the {{ic|InitialPixmapPlacement}} parameter to 2:<br />
<br />
$ nvidia-settings -a InitialPixmapPlacement=2<br />
<br />
This is documented in [http://cgit.freedesktop.org/~aplattner/nvidia-settings/tree/src/libXNVCtrl/NVCtrl.h?id=b27db3d10d58b821e87fbe3f46166e02dc589855#n2797 nvidia-settings source code]. For this setting to persist, this command needs to be run on every startup or added to your {{ic|~/.nvidia-settings-rc}}.<br />
<br />
{{Tip | On rare occasions the {{ic|~/.nvidia-settings-rc}} may become corrupt. If this happens, the Xorg server may crash and the file will have to be deleted to fix the issue.}}<br />
<br />
===Advanced: 20-nvidia.conf===<br />
Edit {{ic|/etc/X11/xorg.conf.d/20-nvidia.conf}}, and add the option to the correct section. The Xorg server will need to be restarted before any changes are applied.<br />
<br />
* See [http://us.download.nvidia.com/XFree86/Linux-x86_64/256.53/README/index.html NVIDIA Accelerated Linux Graphics Driver README and Installation Guide] for additional details and options.<br />
====Enabling desktop composition====<br />
As of NVIDIA driver version 180.44, support for GLX with the Damage and Composite X extensions is enabled by default. Refer to [[Composite]] for detailed instructions.<br />
<br />
====Disabling the logo on startup====<br />
Add the {{ic|"NoLogo"}} option under section {{ic|Device}}:<br />
Option "NoLogo" "1"<br />
<br />
====Enabling hardware acceleration====<br />
{{Note|RenderAccel is enabled by default since drivers version 97.46.xx}}<br />
Add the {{ic|"RenderAccel"}} option under section {{ic|Device}}:<br />
Option "RenderAccel" "1"<br />
<br />
====Overriding monitor detection====<br />
The {{ic|"ConnectedMonitor"}} option under section {{ic|Device}} allows to override monitor detection when X server starts, which may save a significant amount of time at start up. The available options are: {{ic|"CRT"}} for analog connections, {{ic|"DFP"}} for digital monitors and {{ic|"TV"}} for televisions.<br />
<br />
The following statement forces the NVIDIA driver to bypass startup checks and recognize the monitor as DFP:<br />
Option "ConnectedMonitor" "DFP"<br />
{{Note| Use "CRT" for all analog 15 pin VGA connections, even if the display is a flat panel. "DFP" is intended for DVI digital connections only.}}<br />
<br />
====Enabling triple buffering====<br />
Enable the use of triple buffering by adding the {{ic|"TripleBuffer"}} Option under section {{ic|Device}}:<br />
Option "TripleBuffer" "1"<br />
<br />
Use this option if the graphics card has plenty of ram (equal or greater than 128MB). The setting only takes effect when syncing to vblank is enabled, one of the options featured in nvidia-settings.<br />
<br />
{{Note|This option may introduce full-screen tearing and reduce performance.}}<br />
<br />
====Using OS-level events====<br />
Taken from the NVIDIA driver's [http://http.download.nvidia.com/XFree86/Linux-x86/1.0-7182/README/readme.txt README] file: ''"[...] Use OS-level events to efficiently notify X when a client has performed direct rendering to a window that needs to be composited."'' It may help improving performance, but it is currently incompatible with SLI and Multi-GPU modes.<br />
<br />
Add under section {{ic|Device}}:<br />
Option "DamageEvents" "1"<br />
{{Note|This option is enabled by default in newer driver versions.}}<br />
<br />
====Enabling power saving====<br />
Add under section {{ic|Monitor}}:<br />
Option "DPMS" "1"<br />
<br />
====Enabling Brightness Control====<br />
Add under section {{ic|Device}}:<br />
Option "RegistryDwords" "EnableBrightnessControl=1"<br />
<br />
====Enabling SLI====<br />
{{Warning|As of May 7, 2011, you may experience sluggish video performance in GNOME 3 after enabling SLI.}}<br />
<br />
Taken from the NVIDIA driver's [http://http.download.nvidia.com/XFree86/Linux-x86/1.0-8774/README/appendix-d.html README] appendix: ''This option controls the configuration of SLI rendering in supported configurations.'' A ''supported configuration'' is a computer equipped with an SLI-Certified Motherboard and 2 or 3 SLI-Certified GeForce GPUs. See NVIDIA's [http://www.slizone.com/page/home.html SLI Zone] for more information.<br />
<br />
Find the first GPU's PCI Bus ID using {{ic|lspci}}:<br />
$ lspci | grep VGA<br />
<br />
This will return something similar to:<br />
03:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce 8800 GTS 512] (rev a2)<br />
05:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce 8800 GTS 512] (rev a2)<br />
<br />
Add the BusID (3 in the previous example) under section {{ic|Device}}:<br />
BusID "PCI:3:0:0"<br />
<br />
{{Note|The format is important. The BusID value must be specified as {{ic|"PCI:<BusID>:0:0"}}}}<br />
<br />
Add the desired SLI rendering mode value under section {{ic|Screen}}:<br />
Option "SLI" "SLIAA"<br />
<br />
The following table presents the available rendering modes.<br />
<br />
{| border="1"<br />
! Value !! Behavior<br />
|-<br />
| 0, no, off, false, Single || Use only a single GPU when rendering.<br />
|-<br />
| 1, yes, on, true, Auto || Enable SLI and allow the driver to automatically select the appropriate rendering mode.<br />
|-<br />
| AFR || Enable SLI and use the alternate frame rendering mode.<br />
|-<br />
| SFR || Enable SLI and use the split frame rendering mode.<br />
|-<br />
| SLIAA || Enable SLI and use SLI antialiasing. Use this in conjunction with full scene antialiasing to improve visual quality.<br />
|}<br />
<br />
Alternatively, you can use the {{ic|nvidia-xconfig}} utility to insert these changes into {{ic|xorg.conf}} with a single command:<br />
# nvidia-xconfig --busid=PCI:3:0:0 --sli=SLIAA<br />
<br />
To verify that SLI mode is enabled from a shell:<br />
$ nvidia-settings -q all | grep SLIMode<br />
Attribute 'SLIMode' (arch:0.0): AA <br />
'SLIMode' is a string attribute.<br />
'SLIMode' is a read-only attribute.<br />
'SLIMode' can use the following target types: X Screen.<br />
<br />
====Forcing Powermizer performance level (for laptops)====<br />
Add under section {{ic|Device}}:<br />
# Force Powermizer to a certain level at all times<br />
# level 0x1=highest<br />
# level 0x2=med<br />
# level 0x3=lowest<br />
<br />
# AC settings:<br />
Option "RegistryDwords" "PowerMizerLevelAC=0x3"<br />
# Battery settings:<br />
Option "RegistryDwords" "PowerMizerLevel=0x3"<br />
Settings are better explained in [http://tutanhamon.com.ua/technovodstvo/NVIDIA-UNIX-driver/ NVIDIA Driver for X.org:Performance and Power Saving Hints].<br />
<br />
=====Letting the GPU set its own performance level based on temperature=====<br />
Add under section {{ic|Device}}:<br />
Option "RegistryDwords" "PerfLevelSrc=0x3333"<br />
<br />
====Disable vblank interrupts (for laptops)====<br />
When running the interrupt detection utility [[powertop]], it can be observed that the Nvidia driver will generate an interrupt for every vblank. To disable, place in the {{ic|Device}} section:<br />
Option "OnDemandVBlankInterrupts" "1"<br />
This will reduce interrupts to about one or two per second.<br />
<br />
====Enabling overclocking====<br />
{{Warning|Please note that overclocking may damage hardware and that no responsibility may be placed on the authors of this page due to any damage to any information technology equipment from operating products out of specifications set by the manufacturer.}}<br />
To enable GPU and memory overclocking, place the following line in the {{ic|Device}} section:<br />
Option "Coolbits" "1"<br />
<br />
This will enable on-the-fly overclocking within an X session by running:<br />
$ nvidia-settings<br />
{{Note|GTX 4xx/5xx series Fermi cores cannot currently be overclocked using <br />
the Coolbits method. The alternative is to edit and reflash the GPU BIOS either under DOS (preferred), or within a Win32 environment by way of [http://www.mvktech.net/component/option,com_remository/Itemid,26/func,select/id,127/orderby,2/page,1/ nvflash] and [http://www.mvktech.net/component/option,com_remository/Itemid,26/func,select/id,135/orderby,2/page,1/ NiBiTor 6.0]. The advantage of BIOS flashing is that not only can voltage limits be raised, but stability is generally improved over software overclocking methods such as Coolbits.}}<br />
<br />
===== Setting static 2D/3D clocks =====<br />
Set the following string in the {{ic|Device}} section to enable PowerMizer at its maximum performance level:<br />
Option "RegistryDwords" "PerfLevelSrc=0x2222"<br />
Set one of the following two strings in the {{ic|Device}} section to enable manual GPU fan control within {{ic|nvidia-settings}}:<br />
Option "Coolbits" "4"<br />
<br />
Option "Coolbits" "5"<br />
<br />
====Enable screen rotation through XRandR====<br />
Place the following line in the {{ic|Device}} section:<br />
Option "RandRRotation" "True"<br />
After restarting Xorg:<br />
$ xrandr -o left<br />
The Screen should be rotated. To restore:<br />
$ xrandr -o normal<br />
{{Note| Editing xorg.conf may be unnecessary since screen rotation should be enabled by default, ideally by using the respective DE tools, such as SystemSettings in KDE.}}<br />
<br />
==Tips and tricks==<br />
===Enabling Pure Video HD (VDPAU/VAAPI)===<br />
'''Hardware Required:''' <br />
<br />
At least a video card with second generation PureVideo HD [http://en.wikipedia.org/wiki/PureVideo_HD#Table_of_PureVideo_.28HD.29_GPUs]<br />
<br />
'''Software Required:'''<br />
<br />
Nvidia video cards with the proprietary driver installed will provide video decoding capabilities with the VDPAU interface at different levels according to PureVideo generation.<br />
<br />
You can also add support for the VA-API interface with:<br />
# pacman -S vdpau-video<br />
<br />
Check VA-API support with:<br />
$ vainfo<br />
<br />
To take full advantage of the hardware decoding capability of your video card you will need a media player that supports VDPAU or VA-API.<br />
<br />
To enable hardware acceleration in [[MPlayer]] edit {{ic|~/.mplayer/config}}<br />
<br />
vo=vdpau<br />
vc=ffmpeg12vdpau,ffwmv3vdpau,ffvc1vdpau,ffh264vdpau,ffodivxvdpau,<br />
<br />
To enable hardware acceleration in [[VLC]] go:<br />
<br />
{{ic|'''Tools'''}} -> {{ic|'''Preferences'''}} -> {{ic|'''Input & Codecs'''}} -> check {{ic|'''Use GPU acceleration (experimental)'''}}<br />
<br />
To enable hardware acceleration in '''smplayer''' go:<br />
<br />
{{ic|'''Options'''}} -> {{ic|'''Preferences'''}} -> {{ic|'''General'''}} -> {{ic|'''Video Tab'''}} -> select {{ic|vdpau}} as {{ic|'''output driver'''}}<br />
<br />
To enable hardware acceleration in '''gnome-mplayer''' go:<br />
<br />
{{ic|'''Edit'''}} -> {{ic|'''Preferences'''}} -> set {{ic|'''video output'''}} to {{ic|vdpau}}<br />
<br />
'''Playing HD movies on cards with low memory:'''<br />
<br />
If your graphic card does not have a lot of memory (>512MB?), you can experience glitches when watching 1080p or even 720p movies.<br />
To avoid that start simple window manager like TWM or MWM.<br />
<br />
Additionally increasing the MPlayer's cache size in {{ic|~/.mplayer/config}} can help, when your hard drive is spinning down when watching HD movies.<br />
<br />
===Using TV-out===<br />
A good article on the subject can be found [http://en.wikibooks.org/wiki/NVidia/TV-OUT here]<br />
<br />
===X with a TV (DFP) as the only display===<br />
The X server falls back to CRT-0 if no monitor is automatically detected. This can be a problem when using a DVI connected TV as the main display, and X is started while the TV is turned off or otherwise disconnected.<br />
<br />
To force nvidia to use DFP, store a copy of the EDID somewhere in the filesystem so that X can parse the file instead of reading EDID from the TV/DFP.<br />
<br />
To acquire the EDID, start nvidia-settings. It will show some information in tree format, ignore the rest of the settings for now and select the GPU (the corresponding entry should be titled "GPU-0" or similar), click the {{ic|DFP}} section (again, {{ic|DFP-0}} or similar), click on the {{ic|Acquire Edid}} Button and store it somewhere, for example, {{ic|/etc/X11/dfp0.edid}}.<br />
<br />
Edit {{ic|xorg.conf}} by adding to the {{ic|Device}} section:<br />
Option "ConnectedMonitor" "DFP"<br />
Option "CustomEDID" "DFP-0:/etc/X11/dfp0.edid"<br />
The {{ic|ConnectedMonitor}} option forces the driver to recognize the DFP as if it were connected. The {{ic|CustomEDID}} provides EDID data for the device, meaning that it will start up just as if the TV/DFP was connected during X the process.<br />
<br />
This way, one can automatically start a display manager at boot time and still have a working and properly configured X screen by the time the TV gets powered on.<br />
<br />
===Check the power state===<br />
NVIDIA X.org driver can detect power source. To see the current state check 'GPUPowerSource' read-only parameter (0 - AC, 1 - battery):<br />
<br />
$ nvidia-settings -q GPUPowerSource -t<br />
1<br />
<br />
For it to be able to detect this you need to have [[acpid]] installed. Make sure to include acpid on DAEMONS array in rc.conf or this warning will appear on system log:<br />
ACPI: failed to connect to the ACPI event daemon; the daemon<br />
may not be running or the "AcpidSocketPath" X<br />
configuration option may not be set correctly. When the<br />
ACPI event daemon is available, the NVIDIA X driver will<br />
try to use it to receive ACPI event notifications. For<br />
details, please see the "ConnectToAcpid" and<br />
"AcpidSocketPath" X configuration options in Appendix B: X<br />
Config Options in the README.<br />
<br />
===Displaying GPU temperature in the shell===<br />
====Method 1 - nvidia-settings====<br />
{{Note|This method requires that you are using X. Use Method 2 or Method 3 if you are not. Also note that Method 3 currently does not not work with newer nvidia cards such as the G210/220 as well as embedded GPUs such as the Zotac IONITX's 8800GS.}}<br />
<br />
To display the GPU temp in the shell, use nvidia-settings as follows:<br />
$ nvidia-settings -q gpucoretemp<br />
<br />
This will output something similar to the following:<br />
Attribute 'GPUCoreTemp' (hostname:0.0): 41.<br />
'GPUCoreTemp' is an integer attribute.<br />
'GPUCoreTemp' is a read-only attribute.<br />
'GPUCoreTemp' can use the following target types: X Screen, GPU.<br />
<br />
The GPU temps of this board is 41 C.<br />
<br />
In order to get just the temperature for use in utils such as rrdtool or conky, among others:<br />
$ nvidia-settings -q gpucoretemp -t<br />
41<br />
<br />
====Method 2 - nvidia-smi====<br />
<br />
Use nvidia-smi which can read temps directly from the GPU without the need to use X at all. This is important for a small group of users who do not have X running on their boxes, perhaps because the box is headless running server apps. <br />
To display the GPU temp in the shell, use nvidia-smi as follows:<br />
<br />
$ nvidia-smi<br />
<br />
This should output something similar to the following:<br />
{{bc|<nowiki>$ nvidia-smi<br />
Fri Jan 6 18:53:54 2012 <br />
+------------------------------------------------------+ <br />
| NVIDIA-SMI 2.290.10 Driver Version: 290.10 | <br />
|-------------------------------+----------------------+----------------------+<br />
| Nb. Name | Bus Id Disp. | Volatile ECC SB / DB |<br />
| Fan Temp Power Usage /Cap | Memory Usage | GPU Util. Compute M. |<br />
|===============================+======================+======================|<br />
| 0. GeForce 8500 GT | 0000:01:00.0 N/A | N/A N/A |<br />
| 30% 62 C N/A N/A / N/A | 17% 42MB / 255MB | N/A Default |<br />
|-------------------------------+----------------------+----------------------|<br />
| Compute processes: GPU Memory |<br />
| GPU PID Process name Usage |<br />
|=============================================================================|<br />
| 0. ERROR: Not Supported |<br />
+-----------------------------------------------------------------------------+<br />
</nowiki>}}<br />
<br />
Only for Temp<br />
{{bc|<nowiki><br />
$ nvidia-smi -q -d TEMPERATURE<br />
<br />
==============NVSMI LOG==============<br />
<br />
Timestamp : Fri Jan 6 18:50:57 2012<br />
<br />
Driver Version : 290.10<br />
<br />
Attached GPUs : 1<br />
<br />
GPU 0000:01:00.0<br />
Temperature<br />
Gpu : 62 C<br />
<br />
</nowiki>}}<br />
<br />
In order to get just the temperature for use in utils such as rrdtool or conky, among others:<br />
<br />
$ nvidia-smi -q -d TEMPERATURE | grep Gpu | cut -c35-36<br />
<br />
62<br />
<br />
Reference: http://www.question-defense.com/2010/03/22/gpu-linux-shell-temp-get-nvidia-gpu-temperatures-via-linux-cli<br />
<br />
====Method 3 - nvclock====<br />
Use nvclock which is available from the [extra] repo. Note that nvclock cannot access thermal sensors on newer NVIDIA cards such as the G210/220.<br />
<br />
There can be significant differences between the temperatures reported by nvclock and nvidia-settings/nv-control. According to [http://sourceforge.net/projects/nvclock/forums/forum/67426/topic/1906899 this post] by the author (thunderbird) of nvclock, the nvclock values should be more accurate.<br />
<br />
===Set Fan Speed at Login===<br />
You can adjust the fan speed on your graphics card with {{ic|nvidia-settings}}'s console interface. First ensure that your Xorg configuration sets the Coolbits option to 4 or 5 in your {{ic|Device}} section to enable fan control.<br />
<br />
Option "Coolbits" "4"<br />
<br />
{{Note|GTX 4xx/5xx series cards cannot currently set fan speeds at login using this method. This method only allows for the setting of fan speeds within the current X session by way of nvidia-settings.}}<br />
<br />
Place the following line in your [[xinitrc|{{ic|~/.xinitrc}}]] file to adjust the fan when you launch Xorg. Replace <n> with the fan speed percentage you want to set.<br />
<br />
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUCurrentFanSpeed=<n>"<br />
<br />
You can also configure a second GPU by incrementing the GPU and fan number.<br />
<br />
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" \ <br />
-a "[gpu:1]/GPUFanControlState=1" \<br />
-a "[fan:0]/GPUCurrentFanSpeed=<n>" \<br />
-a [fan:1]/GPUCurrentFanSpeed=<n>" &<br />
<br />
If you use a login manager such as GDM or KDM, you can create a desktop entry file to process this setting. Create {{ic|~/.config/autostart/nvidia-fan-speed.desktop}} and place this text inside it. Again, change <n> to the speed percentage you want.<br />
<br />
[Desktop Entry]<br />
Type=Application<br />
Exec=nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUCurrentFanSpeed=<n>"<br />
X-GNOME-Autostart-enabled=true<br />
Name=nvidia-fan-speed<br />
<br />
===Order of install/deinstall for changing drivers===<br />
Where the old driver is nvidiaO and the new driver is nvidiaN.<br />
remove nvidiaO<br />
install nvidia-utilsN<br />
install nvidiaN<br />
install lib32-nvidia-utils-N (if required)<br />
<br />
===Switching between nvidia and nouveau drivers===<br />
If you are switching between the nvidia and nouveau driver often, you can use those two scripts to make it easier:<br />
<br />
#!/bin/bash<br />
# nvidia -> nouveau<br />
<br />
/usr/bin/sudo /bin/sed -i 's/#*options nouveau modeset=1/options nouveau modeset=1/' /etc/modprobe.d/modprobe.conf<br />
/usr/bin/sudo /bin/sed -i 's/#*MODULES="nouveau"/MODULES="nouveau"/' /etc/mkinitcpio.conf<br />
<br />
/usr/bin/sudo /usr/bin/pacman -Rdds --noconfirm nvidia-173xx{,-utils}<br />
/usr/bin/sudo /usr/bin/pacman -S --noconfirm nouveau-dri xf86-video-nouveau<br />
<br />
#/usr/bin/sudo /bin/cp {10-monitor,20-nouveau}.conf /etc/X11/xorg.conf.d/<br />
<br />
/usr/bin/sudo /sbin/mkinitcpio -p linux<br />
<br />
#!/bin/bash<br />
# nouveau -> nvidia<br />
<br />
/usr/bin/sudo /bin/sed -i 's/options nouveau modeset=1/#options nouveau modeset=1/' /etc/modprobe.d/modprobe.conf<br />
/usr/bin/sudo /bin/sed -i 's/MODULES="nouveau"/#MODULES="nouveau"/' /etc/mkinitcpio.conf<br />
<br />
/usr/bin/sudo /usr/bin/pacman -Rdds --noconfirm nouveau-dri xf86-video-nouveau libgl<br />
/usr/bin/sudo /usr/bin/pacman -S --noconfirm nvidia-173xx{,-utils}<br />
<br />
#/usr/bin/sudo /bin/rm /etc/X11/xorg.conf.d/{10-monitor,20-nouveau}.conf<br />
<br />
/usr/bin/sudo /sbin/mkinitcpio -p linux<br />
<br />
A reboot is needed to complete the switch.<br />
<br />
Adjust the scripts accordingly if you are using other version of NVIDIA drivers (I use nvidia-173xx).<br />
<br />
If you are using xorg-server older than 1.10.2-1, uncomment the lines that copy and remove {10-monitor,20-nouveau}.conf. Since version 1.10.2-1, xorg-server is patched to load nouveau driver automatically. I keep 10-monitor.conf and [[Nouveau#Tips_and_tricks|20-nouveau.conf]] in the same directory as this script, adjust the path if needed.<br />
<br />
==Troubleshooting==<br />
<br />
===Gaming using Twinview===<br />
In case you want to play fullscreen games when using Twinview, you will notice that games recognize the two screens as being one big screen. While this is technically correct (the virtual X screen really is the size of your screens combined), you probably do not want to play on both screens at the same time. <br />
<br />
To correct this behavior for SDL, try:<br />
export SDL_VIDEO_FULLSCREEN_HEAD=1<br />
<br />
For OpenGL, add the appropiate Metamodes to your xorg.conf in section {{ic|Device}} and restart X:<br />
Option "Metamodes" "1680x1050,1680x1050; 1280x1024,1280x1024; 1680x1050,NULL; 1280x1024,NULL;"<br />
<br />
Another method that may either work alone or in conjunction with those mentioned above is [[Gaming#Starting_games_in_a_separate_X_server|starting games in a separate X server]].<br />
<br />
===Vertical sync using TwinView===<br />
If you're using TwinView and vertical sync (the "Sync to VBlank" option in {{ic|nvidia-settings}}), you will notice that only one screen is being properly synced, unless you have two identical monitors. Although {{ic|nvidia-settings}} does offer an option to change which screen is being synced (the "Sync to this display device" option), this does not always work. A solution is to add the following environment variables at startup:<br />
nano /etc/profile<br />
Add to the end of the file:<br />
export __GL_SYNC_TO_VBLANK=1<br />
export __GL_SYNC_DISPLAY_DEVICE=DFP-0<br />
export __VDPAU_NVIDIA_SYNC_DISPLAY_DEVICE=DFP-0<br />
You can change {{ic|DFP-0}} with your preferred screen ({{ic|DFP-0}} is the DVI port and {{ic|CRT-0}} is the VGA port).<br />
<br />
===Old Xorg Settings===<br />
If upgrading from an old installation, please remove old {{ic|/usr/X11R6}} paths as it can cause trouble during installation.<br />
<br />
===Corrupted screen: "Six screens" issue===<br />
For some users using Geforce GT 100M's, the screen turns out corrupted after X starts; divided into 6 sections with a resolution limited to 640x480.<br />
<br />
To solve this problem, enable the Validation Mode {{ic|NoTotalSizeCheck}} in section {{ic|Device}}:<br />
Section "Device"<br />
...<br />
Option "ModeValidation" "NoTotalSizeCheck"<br />
...<br />
EndSection<br />
==='/dev/nvidia0' Input/Output error===<br />
This error can occur for several different reasons, and the most common solution given for this error is to check for group/file permissions, which in almost every case is ''not'' the issue. The NVIDIA documentation does not talk in detail on what you should<br />
do to correct this problem but there are a few things that have worked for some people. The problem can be a IRQ conflict with another device or bad routing by either the kernel or your BIOS.<br />
<br />
First thing to try is to remove other video devices such as video capture cards and see if the problem goes away. If there are too many video processors on the same system it can lead into the kernel being unable to start them because of memory allocation problems with the video controller. In particular on systems with low video memory this can occur even if there is only one video processor. In such case you should find out the amount of your system's video memory (e.g. with {{ic|lspci -v}}) and pass allocation parameters to the kernel, e.g.:<br />
vmalloc=64M<br />
or<br />
vmalloc=256M<br />
<br />
If running a 64bit kernel, a driver defect can cause the nvidia module to fail initializing when IOMMU is on. Turning it off in the BIOS has been confirmed to work for some users. [http://www.nvnews.net/vbulletin/showthread.php?s=68bb2fabadcb53b10b286aa42d13c5bc&t=159335][https://wiki.archlinux.org/index.php/User:Clickthem#nvidia_module]<br />
<br />
Another thing to try is to change your BIOS IRQ routing from {{ic|Operating system controlled}} to {{ic|BIOS controlled}} or the other way around. The first one can be passed as a kernel parameter:<br />
PCI=biosirq<br />
<br />
The {{ic|noacpi}} kernel parameter has also been suggested as a solution but since it disables ACPI completely it should be used with caution. Some hardware are easily damaged by overheating.<br />
<br />
{{Note|The kernel parameters can be passed either through the kernel command line or the bootloader configuration file. See your bootloader Wiki page for more information.}}<br />
<br />
==='/dev/nvidiactl' errors===<br />
Trying to start an opengl application might result in errors such as:<br />
Error: Could not open /dev/nvidiactl because the permissions are too<br />
restrictive. Please see the {{ic|FREQUENTLY ASKED QUESTIONS}} <br />
section of {{ic|/usr/share/doc/NVIDIA_GLX-1.0/README}} <br />
for steps to correct.<br />
<br />
Solve by adding the appropiate user to the {{ic|video}} group and relogin:<br />
# gpasswd -a username video<br />
<br />
===32 bit applications do not start===<br />
Under 64 bit systems, installing {{ic|lib32-nvidia-utils}} that corresponds to the same version installed for the 64 bit driver fixes the issue.<br />
<br />
===Errors after updating the kernel===<br />
If a custom build of NVIDIA's module is used instead of the package from [extra], a recompile is required every time the kernel is updated. Rebooting is generally recommended after updating kernel and graphic drivers.<br />
<br />
===Crashing in general===<br />
* Try disabling {{ic|RenderAccel}} in xorg.conf.<br />
* If Xorg outputs an error about "conflicting memory type" or "failed to allocate primary buffer: out of memory", add {{ic|nopat}} at the end of the {{ic|kernel}} line in {{ic|/boot/grub/menu.lst}}.<br />
* If the NVIDIA compiler complains about different versions of GCC between the current one and the one used for compiling the kernel, add in {{ic|/etc/profile}}:<br />
export IGNORE_CC_MISMATCH=1<br />
* If Xorg is crashing with a "Signal 11" while using nvidia-96xx drivers, try disabling PAT. Pass the argument {{ic|nopat}} to the {{ic|kernel}} line in {{ic|menu.lst}}.<br />
More information about troubleshooting the driver can be found in the [http://www.nvnews.net/vbulletin/forumdisplay.php?s=&forumid=14 NVIDIA forums.]<br />
<br />
===Bad performance after installing a new driver version===<br />
If FPS have dropped in comparison with older drivers, first check if direct rendering is turned on:<br />
$ glxinfo | grep direct<br />
If the command prints:<br />
direct rendering: No<br />
then that could be an indication for the sudden FPS drop.<br />
<br />
A possible solution could be to regress to the previously installed driver version and rebooting afterwards.<br />
<br />
===CPU spikes with 400 series cards===<br />
If you are experiencing intermittent CPU spikes with a 400 series card, it may be caused by PowerMizer constantly changing the GPU's clock frequency. Switching PowerMizer's setting from Adaptive to Performance, add the following to the {{ic|Device}} section of your Xorg configuration:<br />
<br />
Option "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x3322; PowerMizerDefaultAC=0x1"<br />
<br />
===Laptops: X hangs on login/out, worked around with Ctrl+Alt+Backspace===<br />
If while using the legacy NVIDIA drivers Xorg hangs on login and logout (particularly with an odd screen split into two black and white/gray pieces), but logging in is still possible via Ctrl-Alt-Backspace (or whatever the new "kill X" keybind is), try adding this in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options nvidia NVreg_Mobile=1<br />
<br />
One user had luck with this instead, but it makes performance drop significantly for others:<br />
options nvidia NVreg_DeviceFileUID=0 NVreg_DeviceFileGID=33 NVreg_DeviceFileMode=0660 NVreg_SoftEDIDs=0 NVreg_Mobile=1<br />
<br />
Note that {{ic|NVreg_Mobile}} needs to be changed according to the laptop:<br />
* 1 for Dell laptops.<br />
* 2 for non-Compal Toshiba laptops.<br />
* 3 for other laptops.<br />
* 4 for Compal Toshiba laptops.<br />
* 5 for Gateway laptops.<br />
<br />
See [http://http.download.nvidia.com/XFree86/Linux-x86/1.0-7182/README/readme.txt NVIDIA Driver's Readme:Appendix K] for more information.<br />
<br />
===Refresh rate not detected properly by XRandR dependant utilities===<br />
The XRandR X extension is not presently aware of multiple display devices on a single X screen; it only sees the {{ic|MetaMode}} bounding box, which may contain one or more actual modes. This means that if multiple MetaModes have the same bounding box, XRandR will not be able to distinguish between them.<br />
<br />
In order to support {{ic|DynamicTwinView}}, the NVIDIA driver must make each MetaMode appear to be unique to XRandR. Presently, the NVIDIA driver accomplishes this by using the refresh rate as a unique identifier.<br />
<br />
Use {{ic|nvidia-settings -q RefreshRate}} to query the actual refresh rate on each display device.<br />
<br />
The XRandR extension is currently being redesigned by the X.Org community, so the refresh rate workaround may be removed at some point in the future.<br />
<br />
This workaround can also be disabled by setting the {{ic|DynamicTwinView}} X configuration option to {{ic|false}}, which will disable NV-CONTROL support for manipulating MetaModes, but will cause the XRandR and XF86VidMode visible refresh rate to be accurate.<br />
<br />
===No screens found on a laptop / NVIDIA Optimus===<br />
On a laptop, if the NVIDIA driver cannot find any screens, you may have an NVIDIA Optimus setup : an Intel chipset connected to the screen and the video outputs, and a NVIDIA card that does all the hard work and writes to the chipset's video memory.<br />
<br />
Check if<br />
lspci | grep VGA<br />
outputs something similar to<br />
00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 02)<br />
01:00.0 VGA compatible controller: nVidia Corporation Device 0df4 (rev a1)<br />
<br />
Unfortunately NVIDIA has no plans to support this in their Linux drivers.<br />
<br />
You need to install the [[Intel]] driver to handle the screens, then if you want 3D software you should run them through [[Bumblebee]] to tell them to use the NVIDIA card.<br />
<br />
'''Possible Workaround'''<br />
<br />
On my Lenovo W520 with a Quadro 1000M and Nvidia Optimus, I entered the BIOS and changed my default graphics setting from 'Optimus' to 'Discrete' and the pacman Nvidia drivers(295.20-1 at time of writing) recognized the screens.<br />
<br />
Steps:<br />
-Enter BIOS<br />
-Find Graphics Settings(For me it's in the Config Tab, then Display submenu)<br />
-Change 'Graphics Device' to 'Discrete Graphics'(Disables Intel integrated graphics)<br />
-Change OS Detection for Nvidia Optimus to 'Disabled'<br />
-Save and Exit<br />
<br />
===Screen(s) found, but none have a usable configuration===<br />
On a laptop, sometimes NVIDIA driver cannot find the active screen.<br />
It may be caused because you own a graphic card with vga/tv outs.<br />
You should examine Xorg.0.log to see what is wrong.<br />
<br />
Another thing to try it's adding invalid {{ic|"ConnectedMonitor" Option}} to {{ic|Section "Device"}}<br />
to force Xorg throws error and shows you how correct it.<br />
[http://http.download.nvidia.com/XFree86/Linux-x86/1.0-8178/README/appendix-d.html Here]<br />
more about ConnectedMonitor setting.<br />
<br />
After re-run X see Xorg.0.log to get valid CRT-x,DFP-x,TV-x values.<br />
<br />
{{ic|nvidia-xconfig --query-gpu-info}} could be helpful.<br />
<br />
===No brightness control on laptops===<br />
Try to add the following line on 20-nvidia.conf<br />
Option "RegistryDwords" "EnableBrightnessControl=1"<br />
If it still not working, you can try install [https://aur.archlinux.org/packages.php?ID=25467 nvidia-bl] or [https://aur.archlinux.org/packages.php?ID=50749 nvidiabl].<br />
<br />
===Black Bars while watching full screen flash videos with twinview===<br />
Follow the instructions presented here:<br />
[http://al.robotfuzz.com/content/workaround-fullscreen-flash-linux-multiheaded-desktops link]<br />
<br />
==See also==<br />
* [http://www.nvnews.net/vbulletin/forumdisplay.php?s=&forumid=14 NVIDIA forums]<br />
* [http://http.download.nvidia.com/XFree86/Linux-x86/1.0-7182/README/readme.txt Official readme for NVIDIA drivers]</div>Clickthemhttps://wiki.archlinux.org/index.php?title=User:Clickthem&diff=187644User:Clickthem2012-03-04T23:55:48Z<p>Clickthem: fixed nvnews link</p>
<hr />
<div>click, them so hard...<br />
<br />
= Hardware =<br />
<br />
= Confirmed Fixes =<br />
<br />
== nvidia module ==<br />
With my two cards in a 64bit kernel, I could not get the nvidia module to load. /var/log/Xorg.0.log contained the (hopelessly ambiguous) "Could not open /dev/nvidia0 (Input/output error) that seems to be so common online. dmesg showed "NVRM: rm_init_adapter(0) failed" during the module load. With a little searching I found <br />
[http://www.nvnews.net/vbulletin/showthread.php?s=68bb2fabadcb53b10b286aa42d13c5bc&t=159335 this nvnews forum thread from over a year ago] <br />
and turned off IOMMU which made the driver load and I was able to use both devices with four monitors. This was on an AMD (Asus) board.<br />
<br />
<!-- TODO: Fill in video card and mobo details --></div>Clickthemhttps://wiki.archlinux.org/index.php?title=User:Clickthem&diff=187643User:Clickthem2012-03-04T23:51:53Z<p>Clickthem: Created page with "click, them so hard... = Hardware = = Confirmed Fixes = == nvidia module == With my two cards in a 64bit kernel, I could not get the nvidia module to load. /var/log/Xorg.0..."</p>
<hr />
<div>click, them so hard...<br />
<br />
= Hardware =<br />
<br />
= Confirmed Fixes =<br />
<br />
== nvidia module ==<br />
With my two cards in a 64bit kernel, I could not get the nvidia module to load. /var/log/Xorg.0.log contained the (hopelessly ambiguous) "Could not open /dev/nvidia0 (Input/output error) that seems to be so common online. dmesg showed "NVRM: rm_init_adapter(0) failed" during the module load. With a little searching I found [this nvnews forum thread from over a year ago [http://www.nvnews.net/vbulletin/showthread.php?s=68bb2fabadcb53b10b286aa42d13c5bc&t=159335]] and turned off IOMMU which made the driver load and I was able to use both devices with four monitors. This was on an AMD (Asus) board.<br />
<br />
<!-- TODO: Fill in video card and mobo details --></div>Clickthem