rxvt-unicode/ヒントとテクニック

提供: ArchWiki
2019年7月4日 (木) 21:41時点におけるKusakata.bot (トーク | 投稿記録)による版 (Pkg/AUR テンプレートの更新)
ナビゲーションに移動 検索に移動

メインの記事は rxvt-unicode を見てください。

Openbox で Kuake ライクな挙動を改善する

以下は元は Xyne によってフォーラムに投稿されたもの [1] で、公式リポジトリにある xdotool に依存しています。

スクリプトレット

urxvtc の man ページにある以下のスクリプトレットをシステム上 (例: ~/.config/openbox) に urxvtc と保存してください:

#!/bin/sh

urxvtc "$@"
if [ $? -eq 2 ]; then
   urxvtd -q -o -f
   urxvtc "$@"
fi

そして以下を urxvtq と保存してください:

#!/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

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

urxvtq とタブ

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

wid=$(xdotool search --classname urxvtq)

with:

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

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

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

with:

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

or replace this line of your ~/.Xresources file:

URxvt.perl-ext-common: default,matcher

with

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

タブの操作

キー 説明
Shift+Left 左側のタブに切り替える。
Shift+Right 右側のタブに切り替える。
Shift+Down 新しいタブを作成。

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 would to normally close a terminal.

Openbox の設定

~/.config/openbox/rc.xml<applications> セクションに以下の行を追加:

<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>

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 Super+T, and toggle the kuake-like console with Super+` (the grave key also known as the backtick).

他の設定

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.

関連スクリプト

パフォーマンスの改善

  • Xft フォントは使わないでください。どうしても Xft フォントを使う必要がある場合、設定値に :antialias=false を追加してください [2]
  • Build rxvt-unicode with disabled support for unnecessary features, --disable-xft and --disable-unicode3 in particular.[3]
  • Limit the number of saveLines (option -sl) in the scrollback buffer to reduce memory usage. [4]
    • Use tmux for scrollback buffer and set saveLines to 0
  • perl の無効化
  • Consider running urxvtd as a daemon accepting connections from urxvtc clients.

デーモンクライアント

警告: サーバーがクラッシュすると、クライアントで動作している全てのプロセスが終了します。例えば xkill でサーバーをリセット・再起動すると開いているウィンドウを含む urxvtd インスタンスが終了されます。詳しくは urxvtd(1) を参照。

Xinitrc

urxvtd(1)Examples セクションを見てください。

systemd

ノート: systemd で起動した urxvt クライアント/デーモンにログインしているとき、通常ユーザーは systemctl の電源コマンド (reboot, poweroff など) を実行することはできません。クライアントがセッションに含まれなくなるからです。そのため systemd で urxvt を起動するのは推奨されません。

システムサービス:

/etc/systemd/system/urxvtd@.service
[Unit]
Description=RXVT-Unicode Daemon

[Service]
User=%i
ExecStart=/usr/bin/urxvtd -q -o

[Install]
WantedBy=multi-user.target

サービスを起動するときにユーザー名を指定します:

urxvtd@username.service

systemd/ユーザーサービスの場合、以下のユニットファイルを ~/.config/systemd/user に配置してください:

urxvtd.service
[Unit]
Description=Urxvt Terminal Daemon
Requires=urxvtd.socket

[Service]
ExecStart=/usr/bin/urxvtd -o -q
Environment=RXVT_SOCKET=%t/urxvtd-%H

[Install]
WantedBy=MyTarget.target
urxvtd.socket
[Unit]
Description=urxvt daemon (socket activation)
Documentation=man:urxvtd(1) man:urxvt(1)

[Socket]
ListenStream=%t/urxvtd-%H

[Install]
WantedBy=sockets.target

高度なタブの管理

AUR から urxvt-tabbedexAUR パッケージをインストールして、~/.XresourcesURxvt.perl-ext-common X リソースに tabbedex を追加してください:

URxvt.perl-ext-common: ...,tabbedex,...
ノート: If you have previously used the tabbed Perl extension and have defined the tabbed value for the URxvt.perl-ext-common X resource, please remove the tabbed value first to avoid conflict with tabbedex.

By default, the "[NEW]" button (which is rarely used and usable only with the mouse) is disabled with tabbedex. You can reenable this feature by setting the new-button to yes.

URxvt.tabbed.new-button: true

Tabs can be named with Shift+ ↑ (Enter to confirm, Escape to cancel).

To automatically hide the tabs bar when only one tab is present, enable the following resource:

URxvt.tabbed.autohide: true

To prevent the last tab from closing Urxvt, enable the following resource:

URxvt.tabbed.reopen-on-close: yes

To start a new tab or cycle through tabs, use the following user commands: tabbedex:(new|next|prev)_tab. Example of mappings:

URxvt.keysym.Control-t: perl:tabbedex:new_tab
URxvt.keysym.Control-Tab: perl:tabbedex:next_tab
URxvt.keysym.Control-Shift-Tab: perl:tabbedex:prev_tab

To define your own key bindings to rename a tab or move a tab to the right or to the left, use the following commands: tabbedex:move_tab_(left|right) and tabbedex:rename_tab. Example of mappings:

URxvt.keysym.Control-Shift-Left: perl:tabbedex:move_tab_left
URxvt.keysym.Control-Shift-Right: perl:tabbedex:move_tab_right
URxvt.keysym.Control-Shift-R: perl:tabbedex:rename_tab
ノート: Redefining the keys used for the user commands will not disable the default mappings, you have to set the X resource no-tabbedex-keys for that. However, currently it is not included in urxvt-tabbedexAUR package. Consider using urxvt-tabbedex-gitAUR package instead:
URxvt.tabbed.no-tabbedex-keys: true

透過

完全透過

完全透過を使用するには、コンポジタによるコンポジットをサポートしているウィンドウマネージャを使っている必要があります。

コマンドラインから:

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

設定ファイルを使用:

~/.Xresources
URxvt.depth: 32
URxvt.background: rgba:1111/1111/1111/dddd

または:

~/.Xresources
URxvt.depth: 32
URxvt.background: [95]#000000

'95' は透過レベル (パーセンテージ)、'#000000' は背景色に置き換えて下さい。

To use a color i.e. #302351 with the rgba:rrrr/gggg/bbbb/aaaa syntax it would be rgba:3000/2300/5100/ee00. "ee00" (the alpha value) to make it nicely transparent.

ノート: To make these settings universal for all forms of URxvt, you may add a wildcard. For example, URxvt.depth would become URxvt*depth.

疑似透過

完全透過の必要がない場合、もしくはコンポジットによるシステムリソースの消費が多すぎるという場合、以下のようにして透過を使うことができます:

~/.Xresources
! Xresources file

URxvt*inheritPixmap: true
URxvt*.transparent: true
! URxvt*.shading: 0 to 99 darkens, 101 to 200 lightens
URxvt*.shading: 110

上記の URxvt*.shading の代わりに URxvt*background を使うこともできます。

ノート: Avoid using shading if you have a URxvt.tintColor set. Use a different tintColor instead.

アイコンの設定

ノート: Because of a bug report (FS#34862) complaining that the rxvt-unicode package had too many dependencies, you must now install the AUR package rxvt-unicode-pixbufAUR in order to use the icon option.

デフォルトでは URxvt にはタスクバーアイコンがありません。~/.Xresources に以下の行を追加してアイコンを指定することで簡単に変更することができます:

URxvt.iconFile:    /usr/share/icons/Clarity/scalable/apps/terminal.svg

urxvt をアプリケーションランチャーとして使う

urxvt は gmrun などのアプリケーションの代わりとして使うことができます。以下の設定で urxvt を実行するとアプリケーションランチャーのように使用できます。もしくはコマンドをカスタムエイリアスに割り当ててください:

$ urxvt -geometry 80x3 -name 'bashrun' -e sh -c "/bin/bash -i -t"

Xterm のエスケープシーケンス

rxvt-unicode で Xterm のエスケープシーケンスを使うことができます。xterm の中で cat -v を実行してキーの組み合わせを確認したらキーシムを使って urxvt の設定を行います。

単語移動のバインドは以下のようになります:

~/.Xresources
!Xterm escapes, word by word movement
URxvt.keysym.Control-Left:    \033[1;5D
URxvt.keysym.Control-Right:    \033[1;5C

詳しくは ascii(7) や urxvt(1) の man ページのキーシムセクションを見てください。

双方向言語のサポート

ヘブライ語やアラビア語などの双方向言語のサポートは拡張で追加できます: urxvt-bidiAUR[リンク切れ: パッケージが存在しません]

インストールしたら Xresources ファイルに以下を追加してください:

URxvt.perl-ext: [other extensions],bidi
URxvt.bidi.enabled: 1

もしくは urxvt を以下のように起動してください:

urxvt -pe bidi
ノート: The font you're using should support your language. For example, for viewing Hebrew you should a font like terminus.

ベルコマンド

ターミナルでベルが鳴ったときにシェルコマンドを実行することができます。最初に ~/.Xresources ファイルで bell-command 拡張を有効にしてください:

URxvt.perl-ext-common: ...,bell-command,...

以下の例は ALSAaplay コマンドを使って .wav ファイルを再生します:

URxvt.bell-command: aplay /path/to/a/file.wav

The following example will use libcanberra's canberra-gtk-play command to play the bell sound of your current sound theme:

URxvt.bell-command: canberra-gtk-play -i bell

And the next setting will pop a visual notification:

URxvt.bell-command: notify-send "rxvt-unicode: bell!"
ノート: bell-command オプションだけ設定してもコンピュータのブザー音は無効になりません。PC スピーカーの記事を見てください。