Difference between revisions of "Rxvt-unicode"

From ArchWiki
Jump to: navigation, search
(Related Scripts)
Line 69: Line 69:
 
* <tt>~/.rxvt-unicode-<i>hostname</i></tt>
 
* <tt>~/.rxvt-unicode-<i>hostname</i></tt>
 
:: [http://en.wikipedia.org/wiki/Unix_domain_socket Socket] connection file created by urxvtd.
 
:: [http://en.wikipedia.org/wiki/Unix_domain_socket Socket] connection file created by urxvtd.
 +
 +
== Clickable URLs ==
 +
You can make URLs in the terminal clickable if you have Perl installed. For example to open links in Firefox add the following to your .Xdefaults:
 +
 +
    URxvt.perl-ext-common : default,matcher
 +
    URxvt.urlLauncher    : /usr/bin/firefox
 +
    URxvt.matcher.button  : 1
 +
  
 
== Cut (Selection) & Paste ==
 
== Cut (Selection) & Paste ==

Revision as of 04:34, 26 June 2009

Introduction

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.

Package Installation

rxvt-unicode is part of the official Arch Linux (extra) repositories.

$ pacman -Si rxvt-unicode
Repository     : extra
Name           : rxvt-unicode
Version        : 9.06-1
URL            : http://software.schmorp.de/pkg/rxvt-unicode.html
Licenses       : GPL2  
Groups         : None
Provides       : None
Depends On     : gcc-libs  libxft  libxpm  
Optional Deps  : perl: lots of utilities
                 gtk-perl: to use the urxvt-tabbed
Conflicts With : None
Replaces       : None
Download Size  : 2312.19 K
Installed Size : 5208.00 K
Packager       : Tobias Kieslich [ tobias <funnychar> archlinux <dot> org ]
Architecture   : i686
Build Date     : Sat 08 Nov 2008 07:17:29 PM PST
MD5 Sum        : d731dc0fe3958eac340fc8ad54a95e51
Description    : an unicode enabled rxvt-clone terminal emulator (urxvt)

Install the latest version of rxvt-unicode:

# pacman -Sy rxvt-unicode

Configuration

Creating ~/.Xdefaults

The look, feel and function of rxvt-unicode is typically controlled by way of either command-line arguments, or resource settings within the file ~/.Xdefaults. If ~/.Xdefaults is not present in the desired home directory, create one:

$ cd ~
$ touch .Xdefaults

All that is left at this point is to enter desired settings by editing the text-based .Xdefaults file.

Template:Box Note

Example .Xdefaults

URxvt.buffered: true
URxvt.background: black
URxvt.foreground: white
URxvt.cursorColor: green
URxvt.underlineColor: yellow
URxvt.font: xft:Terminus:pixelsize=14:antialias=false
URxvt.boldFont: xft:Terminus:bold:pixelsize=14:antialias=false
URxvt.perl-ext-common: default,tabbed
URxvt.title: ArchWiki Example

Improving Performance

  • Avoid the use of Xft fonts. If Xft fonts must be used, append :antialias=false to the setting value.[1]
  • Build rxvt-unicode with disabled support for unnecessary features, --disable-xft and --disable-unicode3 in particular.[2]
  • Limit the number of saveLines (option -sl) in the scrollback buffer to reduce memory usage.[3]
  • Consider running urxvtd as a daemon accepting connections from urxvtc clients.[4]

Troubleshooting DRAFT

Addtional Files Created

  • ~/.terminfo/r/rxvt-unicode
Terminfo library and database file.
  • ~/.rxvt-unicode-hostname
Socket connection file created by urxvtd.

Clickable URLs

You can make URLs in the terminal clickable if you have Perl installed. For example to open links in Firefox add the following to your .Xdefaults:

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


Cut (Selection) & Paste

For users unfamiliar with X11 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.[1] Users are urged to review the Wikipedia article X Window Selection for additional information.

Clipboard Management

  • Parcellite is an actively developed 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).

No clipboard management solution

Skottish[1] created a perl script to automatically copy any selection in urxvt to the X clipboard. You should create a file with the following content in /usr/lib/urxvt/perl named clipboard

#! /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 -ibp" );
}
It also requires xsel and needs to be enabled in the *perl-ext-common field in .Xdefaults. There should be a line in .Xdefaults that looks like this:
urxvt*perl-ext-common:      default,matcher,clipboard

Font Declaration Methods

URxvt.font: 9x15

is the same as

-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


Improved Kuake-like Behavior in Openbox

This was originally posted on the forum by Xyne[2] and it relies on "xdotool" which is available in the community repo.

The Scriptlets

Save this scriptlet from the urxvtc man page somewhere on your system as "urxvtc" (e.g. in ~/.config/openbox):

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

and save this one as "urxvtq":

#!/bin/bash

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

Make sure that you change "/path/to/urxvtc" to the actual path to the urxvtc scriptlet that you saved above. We'll be using urxvtc to launch both regular instances of urxvt and the kuake-like instance.

Openbox Configuration

Now add the following lines to the "<applications>" section of ~/.config/openbox/rc.xml:

    <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 "<keyboard>" 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>
  </keyboard>

Here too you need to change the "/path/to/*" 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 and "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 urxvtq scriptlet to adjust the height of the console.

Related Scripts

hbekel has posted a generalized version of the urxvtq here which can be used to toggle any application using xdotool

A script / program for opening url's with your keyboard instead of mouse with urxvt [3]

Additional Resources

[4] See man 1 urxvtd and man 1 urxvtc for additional information.