ArchLinux環境作り 〜タイル型ウィンドウマネージャ〜
2017年、明けました。おめでとうございます。
ArchLinuxを普段使いしているときにはXfceを用いているが、ウィンドウをちまちま動かしたり揃えたりするのが少し面倒になってきてしまったので、ここで心機一転しようというのがきっかけ
というわけでタイトルの通り、タイル型ウィンドウマネージャを取り入れることにした
今回採用したのはQtileというもの。最終的にこのような感じの見た目になった
ブラウザと2つのシェルが隙間なく配置されていて非常に使いやすくなった
初期画面で
$ startxfce4
と記述すればXfce4のデスクトップが立ち上がり、
$ startx
と記述すればQtileが立ち上がるように設定した
これは.xinitrcにQtileを指定していることにより区別することができた
このような環境を、以下のWikiに従って導入していく
環境はpython3なのでAURからQtileを入れる
$ yaourt -S qtile
背景の壁紙設定もしたかったのでnitrogenも導入する
$ yaourt -S nitrogen
このときにvte3-ngがvte3と衝突するけどvte3を削除してもいいかと聞かれるが、
Arch Linux - vte3-ng 0.46.1.a-1 (x86_64)
Arch Linux - vte3 0.46.1-1 (x86_64)
上の2つを見比べて削除しても問題なさそうと判断したので削除してvte3-ngを選択した
これでインストール作業はこれで終了となる
nitrogenを利用して背景を設定してみる
$ nitrogen ~/picture
引数には背景にしたい画像が含まれているディレクトリを指定する
するとウィンドウが開かれるので背景を選んでApplyをすると設定される
一度Applyすると~/.config/nitrogen/bg-saved.cfgに設定したものが反映されているので次回からログインしたときに同じ設定を反映させるためにレストアする
実際にレストアするためには
$ nitrogen --restore
をすると以前の設定が反映されるので以降のrcファイルに記述しておくことにする
次に~/.xinitrcを以下のように編集する
setxkbmap -model jp106 -layout jp
nitrogen --restoreexec qtile
デフォルトではキー配列はUSのままなのでsetxkbmapでJIS配列にした
あとは細かい設定をしていくために設定ファイルを作成する
$ mkdir ~/.config/qtile
$ nano ~/.config/qtile/config.py
config.pyファイルには以下を記述した
設定したことをざっくりすると、
- 操作はXfce4でやったことを少し流用できるように
- Ctrl+Alt+矢印でワークスペースの左右移動
- 同じレイヤに2つ以上のアプリケーションがあるときにSuper+vで横に分割
ターミナルはxtermは個人的にあまり好きではないのと、xfce4-terminalが意外と気に入っているのでそれを使うことにした
スタートアップもどきとして同ディレクトリにシェルスクリプトを配置
途中で使用するmod1, mod4はキーのコードを表している
$ Xmodmap
をするとキーがどのmodであるかを確認することができる
本環境ではSuperキーはmod1, Altはmod4であることを確認した
最後に設定内容を載せる
from libqtile.config import Key, Screen, Group, Drag, Click
from libqtile.command import lazy
from libqtile import layout, bar, widget
import subprocess, os
def autostart():
home = os.path.expanduser('~')
subprocess.call([home + '/.config/qtile/start.sh'])
mod = "mod4"
alt = "mod1"
keys = [
# Switch between windows in current stack pane
Key(
[mod], "Down",
lazy.layout.down()
),
Key(
[mod], "Up",
lazy.layout.up()
),
Key(
[mod, "control"], "Down",
lazy.layout.shuffle_down()
),
Key(
[mod, "control"], "Up",
lazy.layout.shuffle_up()
),
# Switch window focus to other pane(s) of stack
Key(
[mod], "space",
lazy.layout.next()
),
# Swap panes of split stack
Key(
[mod, "shift"], "space",
lazy.layout.rotate()
),
Key(
[mod, "shift"], "Return",
lazy.layout.toggle_split()
),
Key(
[mod], "v",
lazy.layout.toggle_split()
),
# Toggle between different layouts as defined below
Key([mod], "Tab", lazy.next_layout()),
Key([mod], "w", lazy.window.kill()),
Key([mod, "control"], "r", lazy.restart()),
Key([mod, "control"], "q", lazy.shutdown()),
Key([mod], "r", lazy.spawncmd()),
# Move to side workspace
Key([alt, "control"], 'Right',lazy.screen.next_group()),
Key([alt, "control"], 'Left',lazy.screen.prev_group()),
Key([alt, "control"], 'j',lazy.spawn("xfce4-terminal")),
Key([alt, "control"], 'l',lazy.spawn("firefox")),
Key(, 'Print',lazy.spawn("xfce4-screenshooter")),
Key([mod], 's',lazy.spawn("xfce4-appfinder")),Key([mod], 'e',lazy.spawn("exo-open --launch FileManager")),
Key(, "XF86AudioMute", lazy.spawn("amixer -q set Master toggle")),
Key(, "XF86AudioLowerVolume", lazy.spawn("amixer set Master 5%-")),
Key(, "XF86AudioRaiseVolume", lazy.spawn("amixer set Master 5%+")),
]
groups = [Group(i) for i in "123456"]
for i in groups:
keys.append(
Key([mod], i.name, lazy.group[i.name].toscreen())
)
window to group
keys.append(
Key([mod, "shift"], i.name, lazy.window.togroup(i.name))
)
layouts = [
layout.Max(),
layout.Stack(num_stacks=2)
]
widget_defaults = dict(
font='Arial',
fontsize=16,
padding=3,
)
screens = [
Screen(
bottom=bar.Bar(
[
widget.GroupBox(),
widget.Prompt(),
widget.WindowName(),
widget.CPUGraph(),
widget.NetGraph(),
widget.Battery(),
widget.Volume(),
widget.Systray(),
widget.Clock(format='%Y-%m-%d %a %I:%M %p'),
],
30,
),
),
]
# Drag floating layouts.
mouse = [
Drag([mod], "Button1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
Drag([mod], "Button3", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
Click([mod], "Button2", lazy.window.bring_to_front())
]
dgroups_key_binder = None
dgroups_app_rules = []
main = None
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
floating_layout = layout.Floating()
auto_fullscreen = True
focus_on_window_activation = "smart"
wmname = "LG3D"