Difference between revisions of "Rxvt-unicode"

From ArchWiki
Jump to: navigation, search
(Font Declaration Methods)
(Font Declaration Methods)
Line 58: Line 58:
 
The complete list of short names for X core fonts can be found in {{Filename|/usr/share/fonts/misc/fonts.alias}} (there's also some fonts.alias files in some of the other subdirectories of {{Filename|/usr/share/fonts/}}, but as they are packaged separately from the actual fonts, they may list fonts you don't actually have installed). It is worth noting that these short aliases select for ISO-8859-1 versions of the fonts rather than ISO-10646-1 (Unicode) versions, and 75 DPI rather than 100 DPI versions, so you're probably better off avoiding them and choosing fonts by their full long names instead.
 
The complete list of short names for X core fonts can be found in {{Filename|/usr/share/fonts/misc/fonts.alias}} (there's also some fonts.alias files in some of the other subdirectories of {{Filename|/usr/share/fonts/}}, but as they are packaged separately from the actual fonts, they may list fonts you don't actually have installed). It is worth noting that these short aliases select for ISO-8859-1 versions of the fonts rather than ISO-10646-1 (Unicode) versions, and 75 DPI rather than 100 DPI versions, so you're probably better off avoiding them and choosing fonts by their full long names instead.
  
* ''Edit : Note the above paragraph is only for bitmap fonts. Xft fonts can be specified using the 'Xft:<my ttf/otf font name>:size=<pt size>' format''
+
* Note the above paragraph is only for bitmap fonts. Xft fonts can be specified using this format:
 +
 
 +
Urxvt.font: xft:monaco:size=10
 +
 
 +
Or
 +
 
 +
Urxvt.font: xft:monaco:bold:size=10
  
 
==Perl extensions==
 
==Perl extensions==

Revision as of 15:34, 1 March 2011

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n links end rxvt-unicode is a highly customizable terminal emulator forked from rxvt. Commonly known as urxvt, rxvt-unicode can be daemonized to run clients within a single process in order to minimize the use of system resources. Developed by Marc Lehmann, some of the more outstanding features of rxvt-unicode include international language support through Unicode, the ability to display multiple font types and support for Perl extensions.

Installation

Template:Package Official is available in [extra] and now includes 256 color support:

# pacman -S rxvt-unicode

Template:Package AUR is available in the AUR and includes a fix for the font width bug and adds support for ignoring window hints (to remove layout gaps in tiling window managers).

Configuration

See the rxvt-unicode reference page for the complete list of available setting and values.

Creating ~/.Xresources

The look, feel and function of rxvt-unicode is controlled by command-line arguments and/or X resources. X resources can be set using Template:Filename and xrdb, see the wiki page for details.

Note: Command-line arguments override and take precedence over the resource settings established in this file.

True transparency

To use true transparency you need to be using a window manager that supports compositing or a separate compositor.

From the command-line:

$ urxvt -depth 32 -bg rgba:3f00/3f00/3f00/dddd

Using the configuration file:

Template:File

Scrollbar

The look of the scrollbar can be chosen through this entry in Template:Filename:

# scrollbar style - rxvt (default), plain, next, or xterm
URxvt*scrollstyle:rxvt

Of which "plain" is the most compact one.

Font Declaration Methods

URxvt.font:  9x15

is the same as:

URxvt.font:  -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-1

and:

URxvt.font:  9x15bold

is the same as:

URxvt.font:  -misc-fixed-bold-r-normal--15-140-75-75-c-90-iso8859-1

The complete list of short names for X core fonts can be found in Template:Filename (there's also some fonts.alias files in some of the other subdirectories of Template:Filename, but as they are packaged separately from the actual fonts, they may list fonts you don't actually have installed). It is worth noting that these short aliases select for ISO-8859-1 versions of the fonts rather than ISO-10646-1 (Unicode) versions, and 75 DPI rather than 100 DPI versions, so you're probably better off avoiding them and choosing fonts by their full long names instead.

  • Note the above paragraph is only for bitmap fonts. Xft fonts can be specified using this format:
Urxvt.font: xft:monaco:size=10

Or

Urxvt.font: xft:monaco:bold:size=10

Perl extensions

Clickable URLs

You can make URLs in the terminal clickable using the matcher extension. For example, to open links in Firefox add the following to Template:Filename:

URxvt.perl-ext-common:  default,matcher
URxvt.urlLauncher:      /usr/bin/firefox
URxvt.matcher.button:   1 

Yankable URLs (No Mouse)

In addition, you can select and open URLs in your web browser without using the mouse.

Install the Template:Package Official package from the [community] repo and adjust your Template:Filename as necessary. An example is shown below:

URxvt.perl-ext:      default,url-select
URxvt.keysym.M-u:    perl:url-select:select_next
URxvt.urlLauncher:   firefox
URxvt.underlineURLs: true
Note: This extension replaces the Clickable URLs extension mentioned above, so matcher can be removed from the URxvt.perl-ext list.

Key commands:

Template:Keypress + Template:Keypress Enter selection mode. The last URL on your screen will be selected. You can repeat Alt+u to select the next upward URL.

Template:Keypress Select next upward URL

Template:Keypress Select next downward URL

Template:Keypress Open selected URL in browser and quit selection mode

Template:Keypress Open selected URL in browser without quitting selection mode

Template:Keypress Copy (yank) selected URL and quit selection mode

Template:Keypress Cancel URL selection mode

Tabs

To add tabs to urxvt, add the following to your Template:Filename:

URxvt.perl-ext-common:  default,tabbed

To control tabs use:

Template:Keypress + Template:Keypress new tab

Template:Keypress + Template:Keypress go to left tab

Template:Keypress + Template:Keypress go to right tab

Template:Keypress + Template:Keypress move tab to the left

Template:Keypress + Template:Keypress move tab to the right

Template:Keypress + Template:Keypress: close tab

You can change tabs' colors with the following:

URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg:    3
URxvt.tabbed.tab-bg:    0

Colors must be specified using color indexes: 0 to 15 correspond to your Template:Filename colors, -1 is the background color and -2 is the foreground color. Colors are declared like this :

XTerm.color0: #000000
XTerm.color2: #aece92
XTerm.color3: #968a38

For named tabs, see this package in the AUR, (Shift+Up: names a tab).

Improving Performance

  • Avoid the use of Xft fonts. If Xft fonts must be used, append Template:Codeline to the setting value.[1]

Cut and Paste

For users unfamiliar with Xorg data transfer methods, the exchange of information to and from rxvt-unicode can become a burden. Suffice to say that rxvt-unicode uses cut buffers which are typically loaded into the current PRIMARY selection by default.[4] Users are urged to review Wikipedia:X Window selection for additional information.

Clipboard Management

  • Parcellite is a GTK+ clipboard manager which can also run in the background as a daemon.
  • autocutsel provides command line and daemon interfaces to synchronize PRIMARY, CLIPBOARD and cut buffer selections.
  • Glipper is a GNOME panel applet with older versions available for use in environments other than GNOME.
  • Clipman (xfce-clipman-plugin) is a GUI clipboard manager plugin for the Xfce panel (xfpanel).

Automatic Script Management

Skottish[5] created a perl script to automatically copy any selection in urxvt to the X clipboard. Save the following as Template:Filename:

#! /usr/bin/perl

sub on_sel_grab {
    my $query=quotemeta $_[0]->selection;
    $query=~ s/\n/\\n/g;
    $query=~ s/\r/\\r/g;
    system( "echo -en " . $query . " | xsel -i -b -p" );
}

Xyne has also created his own variation of Skottish's script (which is also available in the AUR):

#! /usr/bin/perl

sub on_sel_grab {
    my $query = $_[0]->selection;
    open (my $pipe,'|-','xsel -ibp') or die;
    print $pipe $query;
    close $pipe;
}

It also requires Template:Codeline and needs to be enabled in the Template:Codeline or Template:Codeline field in Template:Filename. For example:

URxvt.perl-ext-common: default,clipboard

Improved Kuake-like Behavior in Openbox

This was originally posted on the forum by Xyne[6] and it relies on Template:Codeline which is available in the community repo.

Scriptlets

Save this scriptlet from the Template:Codeline man page somewhere on your system as Template:Filename (e.g., in Template:Filename):

#!/bin/sh
urxvtc "$@"
if [ $? -eq 2 ]; then
   urxvtd -q -o -f
   urxvtc "$@"
fi

and save this one as Template:Filename:

#!/bin/bash

wid=$(xdotool search --classname urxvtq)
if [ -z "$wid" ]; then
  /path/to/urxvtc -name urxvtq -geometry 80x28
  wid=$(xdotool search --classname urxvtq | head -1)
  xdotool windowfocus $wid
  xdotool key Control_L+l
else
  if [ -z "$(xdotool search --onlyvisible --classname urxvtq 2>/dev/null)" ]; then
    xdotool windowmap $wid
    xdotool windowfocus $wid
  else
    xdotool windowunmap $wid
  fi
fi

A previous version of xdotool introduced a bug which disabled recognition of visible windows and thus led some users to use the following scriptlet in place of the previous one. This is no longer necessary as xdotool>=1.20100416.2809, but it has been left here for future reference.

#!/bin/bash

wid=$(xprop -name urxvtq | grep 'WM_COMMAND' | awk -F ',' '{print $3}' | awk -F '"' '{print $2}')
if [ -z "$wid" ]; then
  /path/to/urxvtc -name urxvtq -geometry 200x28
  wid=$(xprop -name urxvtq | grep 'WM_COMMAND' | awk -F ',' '{print $3}' | awk -F '"' '{print $2}')
  xdotool windowfocus $wid
  xdotool key Control_L+l
else
  if [ -z "$(xprop -id $wid | grep 'window state: Normal' 2>/dev/null)" ]; then
    xdotool windowmap $wid
    xdotool windowfocus $wid
  else
    xdotool windowunmap $wid
  fi
fi

Make sure that you change Template:Filename to the actual path to the Template:Filename scriptlet that you saved above. We'll be using Template:Filename to launch both regular instances of Template:Codeline and the kuake-like instance.

urxvtq with tabbing

If you want to have tabs in your kuake-like Template:Filename (here called Template:Filename) just replace the third line in your Template:Filename:

wid=$(xdotool search --name urxvtq)

with:

wid=$(xdotool search --name urxvtq | grep -m 1 "" )

To activate the tab support, you can either replace the fifth line of your Template:Filename:

/path/to/urxvtc -name urxvtq -geometry 80x28

with:

/path/to/urxvtc -name urxvtq -pe tabbed -geometry 80x28

or replace this line of your Template:Filename:

URxvt.perl-ext-common: default,matcher

with

URxvt.perl-ext-common: default,matcher,tabbed

Tab control

<SHIFT>-Left: Switch to the tab left of current one

<SHIFT>-Right: Switch to the tab right of current one

<SHIFT>-Down: Create a new tab

You can also use your mouse to switch the tabs by clicking the wished one and create a new tab by clicking on [NEW].\\

To close a tab just enter 'exit' like you'll close a terminal.

Openbox configuration

Now add the following lines to the Template:Codeline section of Template:Filename:

<application name="urxvtq">
   <decor>no</decor>
   <position force="yes">
     <x>center</x>
     <y>0</y>
   </position>
   <desktop>all</desktop>
   <layer>above</layer>
   <skip_pager>yes</skip_pager>
   <skip_taskbar>yes</skip_taskbar>
   <maximized>Horizontal</maximized>
</application>

and add these lines to the Template:Codeline section:

<keybind key="W-t">
  <action name="Execute">
    <command>/path/to/urxvtc</command>
  </action>
</keybind>
<keybind key="W-grave">
  <action name="Execute">
    <execute>/path/to/urxvtq</execute>
  </action>
</keybind>

Here too you need to change the Template:Filename lines to point to the scripts that you saved above. Save the file and then reconfigure Openbox. You should now be able to launch regular instances of urxvt with the Windows/Super key + "t", and toggle the kuake-like console with Windows/Super+grave (`).

Further configuration

The advantage of this configuration over the urxvt kuake perl script is that Openbox provides more keybinding options such as modifier keys. The kuake script hijacks an entire physical key regardless of any modifier combination. Review the Openbox bindings documentation for the full range or possibilities.

The Openbox per-app settings can be used to further configure the behavior of the kuake-like console (e.g. screen position, layer, etc). You may need to change the "geometry" parameter in the Template:Filename scriptlet to adjust the height of the console.

Related scripts

Troubleshooting

Transparency not working after upgrade to V9.09

The rxvt-unicode devs removed compatibility code for a lot of non standard wallpaper setters with this update. Using a non compatible wallpaper setter will break transparency support. Recommended wallpaper setters:

  • feh
  • hsetroot
  • esetroot

To make true transparency work, make sure to comment urxvt*tintColor and urxvt*inheritPixmap.

Remote Hosts

If you are logging into a remote host, you may encounter problems when running text-mode programs under rxvt-unicode. This can be fixed by copying Template:Filename from your local machine to your host at Template:Filename.

Using rxvt-unicode as gmrun terminal

Unlike some other terminals, urxvt expects the arguments to -e to be given separately, rather than grouped together with quotes. This causes trouble with gmrun, which assumes the opposite behavior. This can be worked around by putting an "eval" in front of gmrun's "Terminal" variable in .gmrunrc:

Terminal = eval urxvt
TermExec = ${Terminal} -e

(gmrun uses /bin/sh to execute commands, so the "eval is understood here.) The "eval" has the side-effect of "breaking up" the argument to -e in the same way $@ does in bash, making the command intelligible to urxvt.

External resources