Difference between revisions of "Cursor themes"

From ArchWiki
Jump to: navigation, search
(Supplying missing cursors: Add common rdesktop mappings)
m (See also: See also sections are made for links only; I didn't know where else I could move this tip in the article)
Line 211: Line 211:
 
== See also ==
 
== See also ==
  
For more information about cursors in X (supported directories, formats, compatibility, etc.) refer to {{ic|man Xcursor}}.
+
* [http://www.x.org/releases/current/doc/man/man3/Xcursor.3.xhtml man Xcursor] — For more information about cursors in X (supported directories, formats, compatibility, etc.).

Revision as of 02:57, 6 July 2014

zh-CN:X11 Cursors There are many cursor themes available besides the default black pointer.

Getting mouse cursor themes

Check which themes are already installed:

ls /usr/share/icons/*

Search for cursors subdirectories:

find /usr/share/icons -type d -iname "*cursors*"
Note: The xcursor-themes package comes with the 'redglass' and 'whiteglass' themes in /usr/share/icons.

The official repositories (search "xcursor-") and AUR (search cursor) have more cursor themes available. Other sources include:

Manually installing mouse cursor themes

This is only required when not using pacman to install themes.

Extract the cursor theme package:

$ tar -zxvf foobar-cursor-theme-package-foo.tar.gz

or

$ tar -jxvf foobar-cursor-theme-package-foo.tar.bz2

Make a directory for the cursor theme:

Example: FooBar-AweSoMe-Cursors-v2.98beta

User-specific installation:

$ mkdir -p ~/.icons/foobar/cursors
$ cp -a FooBar-AweSoMe-Cursors-v2.98beta/cursors/* ~/.icons/foobar/cursors/

System-wide installation:

# mkdir -p /usr/share/icons/foobar/cursors
# cp -a FooBar-AweSoMe-Cursors-v2.98beta/cursors/* /usr/share/icons/foobar/cursors/
Note: To simplify the name of the theme, the name being used is 'foobar' instead of 'FooBar-AweSoMe-Cursors-v2.98beta' when creating the dir(s) above.

If the package includes an index.theme file, check if there is an "Inherits" line inside. If yes, check whether the inherited theme also exists under this name in your system (rename if needed). Then copy the index.theme file:

User-specific installation:

$ cp -a FooBar-AweSoMe-Cursors-v2.98beta/index.theme ~/.icons/foobar/index.theme

System-wide installation:

# cp -a FooBar-AweSoMe-Cursors-v2.98beta/index.theme /usr/share/icons/foobar/index.theme

Create links to missing cursors

Applications may keep using the default cursors when a theme lacks some cursors. This can be corrected by adding links to the missing cursors. For example:

$ cd ~/.icons/foobar/cursors/
$ ln -s right_ptr arrow
$ ln -s cross crosshair
$ ln -s right_ptr draft_large
$ ln -s right_ptr draft_small
$ ln -s cross plus
$ ln -s left_ptr top_left_arrow
$ ln -s cross tcross
$ ln -s hand hand1
$ ln -s hand hand2
$ ln -s left_side left_tee
$ ln -s left_ptr ul_angle
$ ln -s left_ptr ur_angle
$ ln -s left_ptr_watch 08e8e1c95fe2fc01f976f1e063a24ccd

If the above does not solve the problem, look in /usr/share/icons/whiteglass/cursors for additional cursors your theme may be missing, and create links for these as well.

Tip: You can also remove unwanted cursors. To for example remove the "watch" cursor:
$ cd ~/.icons/foobar/cursors/
$ rm watch left_ptr_watch
$ ln -s left_ptr watch
$ ln -s left_ptr left_ptr_watch

Choosing and configuring cursor themes

If you use some desktop environment like Gnome, you can use its GUIs to choose cursor themes. Alternatively you can use lxappearance to manage and apply cursor themes.

If you don't want to install any additional packages, you can use an environment variable to set a theme for a single application to try it out temporarily, for example:

$ XCURSOR_THEME=SomeThemeName xclock

Using the XDG Icon theme specification

Note:
  • This will set both the X11 and Wayland cursor theme.
  • Even if you are using a tool such as lxappearance or dconf-editor to set the cursor theme, it is recommended that you create an index.theme file as well otherwise cursor themes will not be consistent systemwide and across all applications.

Using an index.theme file (recommended)

Create the following file (you may also need to create the directory):

/usr/share/icons/default/index.theme
[icon theme] 
Inherits=my-cursor-theme
Tip: If your cursor theme is installed in ~/.icons you can create the index.theme file in the ~/.icons/default/ directory instead.

Using a symlink

Create a symlink named "default" in ~/.icons, which points to your installed cursor theme:

$ ln -s /usr/share/icons/my-cursor-theme/ ~/.icons/default
Note: This method will not set the cursor theme used in display managers and it may not set the cursor theme consistently across all applications. It will also make it more difficult to customise the theme by adding additional cursors. It is highly recommended that users create an index.theme instead, as described in the subsection above.

GNOME 3.8 and above

To change the cursor theme with GNOME 3.8 and above, run the following command:

gsettings set org.gnome.desktop.interface cursor-theme my-cursor-theme

Use the dconf-editor if you do not wish to issue a command.

Tip: For cursor theme consistency across all applications, you may need to create an index.theme file as described above.

GDM

GDM disregards GNOME cursor theme settings and it also ignores the cursor theme set according to the XDG Icon theme specification - see above. To change the cursor theme used in GDM, you must create the following file:

/etc/dconf/db/gdm.d/10-cursor-settings
[org/gnome/desktop/interface]
cursor-theme='my-cursor-theme'

Then run the following command as root:

# dconf update

Using X resources

To locally name a cursor theme, add to your ~/.Xresources:

Xcursor.theme: my-cursor-theme

To have the cursor theme properly loaded it will need to be called by your window manager. If it does not, you can force it to load prior your window manager by putting the following command in ~/.xinitrc or .xprofile (depending on your setup):

$ xrdb ~/.Xresources &

You can optionally add this line to ~/.Xresources if your cursor theme supports multiple sizes:

Xcursor.size:  16       !  32, 48 or 64 may also be good values

If you do not know about supported cursor sizes, start X without this setting and let it choose the cursor size automatically.

Refer to your window manager documentation for details.

Supplying missing cursors

Some programs set their own custom cursors which you may want to override. A common example of this is rdesktop, which connects to a Microsoft Windows computer and uses the cursors obtained from the remote machine, which can often be difficult to see due to protocol limitations yielding poor conversion quality.

This can be resolved by replacing these cursors with ones from the same (or another) cursor theme. In order to do this, the hash of the image must be obtained. This is done by setting the XCURSOR_DISCOVER environment variable prior to launching the application that sets these cursors:

$ XCURSOR_DISCOVER=1 rdesktop ...

The first time (and only the first time) the cursor is set, some details will be displayed, like this:

Cursor image name: 24020000002800000528000084810000
...
Cursor image name: 7bf1cc07d310bf080118007e08fc30ff
...
Cursor hash 24020000002800000528000084810000 returns 0x0

When Xcursor looks for missing cursors, the search path includes ~/.icons/default/cursors so this is where an image can be placed for Xcursor to find. First, create this directory if it doesn't already exist:

$ mkdir -p ~/.icons/default/cursors

Then link the hash to the target image. Here we are using the left_ptr image from the Vanilla-DMZ cursor theme:

$ ln -s /usr/share/icons/Vanilla-DMZ/cursors/left_ptr ~/.icons/default/cursors/24020000002800000528000084810000

The change will be visible as soon as the application is restarted. No special method of launching the application is required.

rdesktop

Here are some common Microsoft Windows cursors that rdesktop uses when connecting to a remote machine running Windows 7. Unfortunately animated cursors are difficult to override as they are sent frame-by-frame, so one mapping will be needed for every frame!

$ ln -s /usr/share/icons/$THEME/cursors/00000000017e000002fc000000000000 ~/.icons/default/cursors/xterm
$ ln -s /usr/share/icons/$THEME/cursors/00000093000010860000631100006609 ~/.icons/default/cursors/right_ptr
$ ln -s /usr/share/icons/$THEME/cursors/01e00000201c00004038000080300000 ~/.icons/default/cursors/plus
$ ln -s /usr/share/icons/$THEME/cursors/24020000002800000528000084810000 ~/.icons/default/cursors/left_ptr
$ ln -s /usr/share/icons/$THEME/cursors/6ce0180090108e0005814700a0021400 ~/.icons/default/cursors/left_ptr_watch
$ ln -s /usr/share/icons/$THEME/cursors/d2201000a2c622004385440041308800 ~/.icons/default/cursors/hand
$ ln -s /usr/share/icons/$THEME/cursors/fc618c00da110f0034fd0e004e082400 ~/.icons/default/cursors/watch

Troubleshooting

Awesome window manager

Xcursor does not work correctly with awesome window manager. You may notice all of the themed cursors work except the default cursor.

For more information see Awesome wiki.

See also

  • man Xcursor — For more information about cursors in X (supported directories, formats, compatibility, etc.).