LoginSignup
0
0

More than 3 years have passed since last update.

Arch Linux(7) Manjaro Awesome 18.1.3 の設定ファイル

Last updated at Posted at 2020-03-16

はじめに

前回、Manjaro Awesome 18.1.3 をインストール しました。GUI でいろいろ設定してみると、カスタマイズには、Awesome では設定ファイルをさわらないとできないことが多いようでした。

今回は、Awesome のメインとなる設定ファイルを、自分なりに調べた備忘録です。ただし、勘違いしているかもしれません。


やったこと:

書いている行番号は目安です。いじっているうちにズレている可能性が高いので、近辺を探してください。

ちなみに、設定ファイルで使われているのは「lua 言語 」です。


デスクトップ画面:
BG-01.jpg
壁紙は変更 しています。


インストールされている内容:

>>> yay -Ss awesome | grep Installed

aur/cesious-theme 1.3-1 (+0 0.00%) (Installed: 1.5-1)
community/manjaro-awesome-settings-18.0 20190508-1 (16.3 KiB 115.0 KiB) (Installed)
community/cesious-theme 1.5-1 (122.5 KiB 254.0 KiB) (Installed)
community/awesome-wallpapers 20180305-1 (94.5 KiB 136.0 KiB) (Installed)
community/awesome-freedesktop r104.3f2d23c-1 (13.2 KiB 56.0 KiB) (Installed)
community/awesome 4.3-1 (1.2 MiB 9.3 MiB) (Installed)

→Manjaro Linux にこれらのパッケージが追加されています。Awesome 4.3-1 です。バージョンで設定ファイルの構成が違うようです。


ローカルのドキュメント:

一部のドキュメントが内蔵されています。ブラウザのURL欄に貼り付けてください。日本語訳も可能です。オンラインのリンクと同じものです。

  • 05-awesomerc.md
    (file:////usr/share/doc/awesome/doc/documentation/05-awesomerc.md.html)

  • awesome ドキュメント
    (file:///usr/share/doc/awesome/doc/index.html)


オンラインのドキュメント:

05-awesomerc.md

API documentation for awesome (version v4.3)

awesome ドキュメント


Awesome のメインとなる設定ファイル

~/.config/awesome/rc.lua

設定ファイルにある「-- 」はコメント行になります。

Manjaro Awesome に移植する前の、素のAwesome の設定ファイル(原本)が「/etc/xdg/awesome/rc.lua」に置かれてます。参考になりますが、内容が違います。

まずは、さわる前に保存:
>>> cp ~/.config/awesome/rc.lua ~/.config/awesome/rc.lua-ORG

>>> ls -la ~/.config/awesome/                                                
:
-rwxr-xr-x  1 ooo ooo  1155  5月  8  2019 autorun.sh
-rw-r--r--  1 ooo ooo 27478  3月 11 06:15 rc.lua
-rw-r--r--  1 ooo ooo 27478  3月 15 02:51 rc.lua-ORG

→.lua は一種のスクリプト言語ですが、実行権限は要らないみたい。また、ここにある、autorun.sh にて、キーの割当が少し操作されています。


14行目: メインメニュー生成のための「freedesktop」ライブラリを読み込み
local freedesktop = require("freedesktop")

44行目: テーマとアイコン、フォントの定義
beautiful.init("/usr/share/awesome/themes/cesious/theme.lua")
beautiful.icon_theme        = "Papirus-Dark"
:
beautiful.font              = "Noto Sans Regular 10"
beautiful.notification_font = "Noto Sans Bold 14"

→デフォルトの壁紙は、ここのテーマの壁紙が使われています。


51行目: 通知メッセージのフォントが大きすぎるので少し調整:
beautiful.notification_font = "Noto Sans Bold 14"

↓ フォントのサイズを変更:

beautiful.notification_font = "Noto Sans Bold 10" -- <サイズ変更 14→10>

→スクリーンショットを撮ったときのメッセージで確認。


54行目: 使用するアプリの定義
browser = "exo-open --launch WebBrowser" or "firefox"
filemanager = "exo-open --launch FileManager" or "thunar"
gui_editor = "mousepad"
terminal = os.getenv("TERMINAL") or "lxterminal"

→本体部分以外のアプリは定義名で指定するので、アプリを増やす場合は、定義名を作ってやる必要がありました。


64行目: modkey の定義
modkey = "Mod4"

→「Mod4」は「Windows」キーになります。
ちなみに、「Mod1」にすると「Alt」キーです。


66行目: 使えるタイルの操作モードを定義(パネルの右端のアイコン)
awful.layout.layouts = {
    awful.layout.suit.tile,
    awful.layout.suit.floating,
:
    awful.layout.suit.tile.bottom,
:
    awful.layout.suit.fair,
    awful.layout.suit.fair.horizontal,
:
:
    awful.layout.suit.max,
:
    awful.layout.suit.magnifier,
:

→「-- 」はコメント行なのでここでは省略。デフォルトは、7つのレイアウト が有効。


メインメニュー

メインメニューの中の「本体部分」、および「頭の部分」と「お尻の部分」が定義されています。

「本体部分」は、「awesome-freedesktop」に含まれるfreedesktop ライブラリによって起動のたびに、「/usr/share/applications/」の「.desktop」を元にして、自動生成されていると思われます。

カテゴリは日本語化されていないので「/usr/share/desktop-directories/」は加味されていないのかな。カテゴリの日本語化は難しそう。

本体となるメニューファイルが見つからないのは、起動のたびに自動生成されているからだろうと勝手に納得。

参考:

Awesome で freedesktop を利用したメニューをつくる - Memorandum

116行目: メインメニュー「本体部分」の自動生成(freedesktop)
mymainmenu = freedesktop.menu.build({
    icon_size = 32,
118行目: メインメニュー 「頭の部分」(お気に入りアプリ)
    before = {
        { "Terminal", terminal, menubar.utils.lookup_icon("utilities-terminal") },
        { "Browser", browser, menubar.utils.lookup_icon("internet-web-browser") },
        { "Files", filemanager, menubar.utils.lookup_icon("system-file-manager") },
        -- other triads can be put here
    },

→「-- other triads can be put here」部分に「お気に入りのアプリ」を追加できそう。個人的には、テキストエディタ。

124行目: メインメニュー 「お尻の部分」
    after = {
        { "Awesome", myawesomemenu, "/usr/share/awesome/icons/awesome32.png" },
        { "Exit", myexitmenu, menubar.utils.lookup_icon("system-shutdown") },
        -- other triads can be put here
    }
})

→「-- other triads can be put here」部分に「お気に入りのカテゴリメニュー」を追加できそう。

103行目: メインメニュー 「お尻の部分」の "Awesome" メニューの中の定義
myawesomemenu = {
    { "hotkeys", function() return false, hotkeys_popup.show_help end, menubar.utils.lookup_icon("preferences-desktop-keyboard-shortcuts") },
    { "manual", terminal .. " -e man awesome", menubar.utils.lookup_icon("system-help") },
    { "edit config", gui_editor .. " " .. awesome.conffile,  menubar.utils.lookup_icon("accessories-text-editor") },
    { "restart", awesome.restart, menubar.utils.lookup_icon("system-restart") }
}
109行目: メインメニュー 「お尻の部分」の "Exit" メニューの中の定義
myexitmenu = {
    { "log out", function() awesome.quit() end, menubar.utils.lookup_icon("system-log-out") },
    { "suspend", "systemctl suspend", menubar.utils.lookup_icon("system-suspend") },
    { "hibernate", "systemctl hibernate", menubar.utils.lookup_icon("system-suspend-hibernate") },
    { "reboot", "systemctl reboot", menubar.utils.lookup_icon("system-reboot") },
    { "shutdown", "poweroff", menubar.utils.lookup_icon("system-shutdown") }
}

138行目: パネルの時計の書式
mytextclock = wibox.widget.textclock("%m/%d %H:%M ")

→時計に時刻だけでなく、日付を追加しました。


230行目: パネルの構成

s.mywibox = awful.wibar({ position = "top", screen = s })

-- Add widgets to the wibox
s.mywibox:setup {
    layout = wibox.layout.align.horizontal,
    { -- Left widgets
        layout = wibox.layout.fixed.horizontal,
        mylauncher,  ←メインメニュー
        s.mytaglist,  ←仮想デスクトップの並び(切替)
        s.mypromptbox,  ←Run プロンプトの領域
        separator,  ←縦棒
    },
    s.mytasklist, -- Middle widget
    { -- Right widgets
        layout = wibox.layout.fixed.horizontal,
        wibox.widget.systray(),  ←システムトレイ
        mykeyboardlayout,  ←キーボードレイアウト: jp
        separator,  ←縦棒
        mytextclock,  ←時計
        s.mylayoutbox,  ←タイル操作モードのアイコン
    },
}

キーの割当て

266行目: Windows + S (Run プロンプトの表示)
    awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
              {description="show help", group="awesome"}),

268行目: Windows + 「←」、「→」(仮想ディスクトップの選択)
    awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
              {description = "view previous", group = "tag"}),
    awful.key({ modkey,           }, "Right",  awful.tag.viewnext,
              {description = "view next", group = "tag"}),

275行目: Windows + J、K (ウィンドウの活性化、選択)
    awful.key({ modkey,           }, "j",
        function ()
            awful.client.focus.byidx( 1)
        end,
        {description = "focus next by index", group = "client"}
    ),
    awful.key({ modkey,           }, "k",
        function ()
            awful.client.focus.byidx(-1)
        end,
        {description = "focus previous by index", group = "client"}
    ),

287行目: Windows + W (メインメニューの表示)
    awful.key({ modkey,           }, "w", function () mymainmenu:show() end,
              {description = "show main menu", group = "awesome"}),

311行目: Windows + Enter (端末の起動)
    awful.key({ modkey,           }, "Return", function () awful.spawn(terminal) end,
              {description = "open a terminal", group = "launcher"}),

334行目: Windows + Ctrl + Esc (アプリランチャーの表示)

「Windows」キーでも有効。(←その後、無効)

    awful.key({ modkey, "Control"}, "Escape", function () awful.spawn("/usr/bin/rofi -show drun -modi drun") end,
              {description = "launch rofi", group = "launcher"}),

「Windows」キーでも有効なのは、
「~/.config/awesome/autorun.sh」で設定されているから:

run xcape -e 'Super_L=Super_L|Control_L|Escape'

→その後、こちらは変更したので、「Windows」キーでは別の機能が立ち上がります。


Windows キーは、Windows + P に変更しました。

アプリランチャーの表示は、今のところ、アルファベットが豆腐文字に化けて使えない ので、左のWindows キーは、「Windows + P」に変更しました。

>>> mousepad ~/.config/awesome/autorun.sh

27行目:

run xcape -e 'Super_L=Super_L|Control_L|Escape'

↓ 修正

run xcape -e 'Super_L=Super_L|p'

ログアウト→ログイン


参考:

右のWindows キーに、「Windows + Ctrl + Esc」を割当てたいとき:

run xcape -e 'Super_R=Super_L|Control_L|Escape'

→欲ばって、右のWindows キーでは、「Windows + Ctrl + Esc」が使えるように複数行を記述してみると、有効になったのは一番上の行だけでした。中止。


336行目: Windows + E (ファイルマネージャの起動)
    awful.key({ modkey,           }, "e", function () awful.spawn(filemanager)            end,
              {description = "launch filemanager", group = "launcher"}),

341行目: Print Screen (スクリーンショット)
    awful.key({                   }, "Print", function () awful.spawn.with_shell("sleep 0.1 && /usr/bin/i3-scrot -d")   end,
              {description = "capture a screenshot", group = "screenshot"}),

    awful.key({"Control"          }, "Print", function () awful.spawn.with_shell("sleep 0.1 && /usr/bin/i3-scrot -w")   end,
              {description = "capture a screenshot of active window", group = "screenshot"}),

    awful.key({"Shift"            }, "Print", function () awful.spawn.with_shell("sleep 0.1 && /usr/bin/i3-scrot -s")   end,
              {description = "capture a screenshot of selection", group = "screenshot"}),

359行目: Windows + R (Run プロンプトの表示)

    awful.key({ modkey },            "r",     function () awful.screen.focused().mypromptbox:run() end,
              {description = "run prompt", group = "launcher"}),

373行目: Windows + P (メニューバーの表示)

Run プロンプトのGUI 版

    awful.key({ modkey }, "p", function() menubar.show() end,
              {description = "show the menubar", group = "launcher"})

378行目: Windows + F (フルスクリーンの切替)

    awful.key({ modkey,           }, "f",
        function (c)
            c.fullscreen = not c.fullscreen
            c:raise()
        end,
        {description = "toggle fullscreen", group = "client"}),

384行目: Windows + X (ウィンドウを閉じる)

    awful.key({ modkey,           }, "x",      function (c) c:kill()                         end,
              {description = "close", group = "client"}),

メインメニューの日本語化に挑戦

前もって、設定ファイルの保存をしておくこと。

メインメニューの定義は、98行目 以降。


100行目: 「Awesome」カテゴリ

myawesomemenu = {
    { "hotkeys", function() return false, hotkeys_popup.show_help end, menubar.utils.lookup_icon("preferences-desktop-keyboard-shortcuts") },
    { "manual", terminal .. " -e man awesome", menubar.utils.lookup_icon("system-help") },
    { "edit config", gui_editor .. " " .. awesome.conffile,  menubar.utils.lookup_icon("accessories-text-editor") },
    { "restart", awesome.restart, menubar.utils.lookup_icon("system-restart") }
}

↓ 修正

myawesomemenu = {
    { "ホットキー", function() return false, hotkeys_popup.show_help end, menubar.utils.lookup_icon("preferences-desktop-keyboard-shortcuts") },
    { "マニュアル", terminal .. " -e man awesome", menubar.utils.lookup_icon("system-help") },
    { "設定ファイルの編集", gui_editor .. " " .. awesome.conffile,  menubar.utils.lookup_icon("accessories-text-editor") },
    { "リスタート", awesome.restart, menubar.utils.lookup_icon("system-restart") }
}

106行目: 「終了(exit)」カテゴリ

myexitmenu = {
    { "log out", function() awesome.quit() end, menubar.utils.lookup_icon("system-log-out") },
    { "suspend", "systemctl suspend", menubar.utils.lookup_icon("system-suspend") },
    { "hibernate", "systemctl hibernate", menubar.utils.lookup_icon("system-suspend-hibernate") },
    { "reboot", "systemctl reboot", menubar.utils.lookup_icon("system-reboot") },
    { "shutdown", "poweroff", menubar.utils.lookup_icon("system-shutdown") }
}

↓ 修正

myexitmenu = {
    { "ログアウト", function() awesome.quit() end, menubar.utils.lookup_icon("system-log-out") },
    { "サスペンド", "systemctl suspend", menubar.utils.lookup_icon("system-suspend") },
    { "ハイバネート", "systemctl hibernate", menubar.utils.lookup_icon("system-suspend-hibernate") },
    { "再起動", "systemctl reboot", menubar.utils.lookup_icon("system-reboot") },
    { "シャットダウン", "poweroff", menubar.utils.lookup_icon("system-shutdown") }
}

125行目: メニューのお尻部分

    after = {
        { "Awesome", myawesomemenu, "/usr/share/awesome/icons/awesome32.png" },
        { "Exit", myexitmenu, menubar.utils.lookup_icon("system-shutdown") },

↓ 修正

    after = {
        { "Awesome", myawesomemenu, "/usr/share/awesome/icons/awesome32.png" },
        { "終了", myexitmenu, menubar.utils.lookup_icon("system-shutdown") },

メインメニューに「お気に入り」のアプリを追加

前もって、設定ファイルの保存をしておくこと。
お気に入りは、メインメニューの頭の部分に置かれてます。

113行目: メインメニューの頭の部分

mymainmenu = freedesktop.menu.build({
    icon_size = 32,
    before = {
        { "Terminal", terminal, menubar.utils.lookup_icon("utilities-terminal") },
        { "Browser", browser, menubar.utils.lookup_icon("internet-web-browser") },:

↓ Terminal の前に3行追加

mymainmenu = freedesktop.menu.build({
    icon_size = 32,
    before = {
        { "Gedit", gedit, menubar.utils.lookup_icon("accessories-text-editor") }, -- <追加>
        { "Geany", geany, menubar.utils.lookup_icon("accessories-text-editor") }, -- <追加>
        { "Mousepad", mousepad, menubar.utils.lookup_icon("accessories-text-editor") }, -- <追加>
        { "Terminal", terminal, menubar.utils.lookup_icon("utilities-terminal") },
:

メインメニューの「Browser」を「Firefox」に変更

Terminal の後ろの行をコメントにして、1行追加

        { "Browser", browser, menubar.utils.lookup_icon("internet-web-browser") },

↓ 修正

        -- { "Browser", browser, menubar.utils.lookup_icon("internet-web-browser") }, -- <コメント化>
       { "Firefox", firefox, menubar.utils.lookup_icon("firefox") }, -- <追加>

→Browser だと、google 翻訳が使えないので、直接Firefox を起動します。

保存して、ログアウト→ログイン

→動作確認にて、メニューの表示は変わりましたが、アプリの起動ができません。その他の修正が必要みたいです。


53行目: 追加したアプリを定義して、有効にします

-- This is used later as the default terminal and editor to run.
browser = "exo-open --launch WebBrowser" or "firefox"
filemanager = "exo-open --launch FileManager" or "thunar"
gui_editor = "mousepad"
terminal = os.getenv("TERMINAL") or "lxterminal"

↓ コメント化と追加

-- This is used later as the default terminal and editor to run.
-- browser = "exo-open --launch WebBrowser" or "firefox" -- <コメント化>
filemanager = "exo-open --launch FileManager" or "thunar"
gui_editor = "mousepad"
terminal = os.getenv("TERMINAL") or "lxterminal"
browser = "firefox" -- <追加>
gui_editor2 = "gedit" -- <追加>
gui_editor3 = "geany" -- <追加>
gui_editor4 = "notepadqq" -- <追加>

124行目: メインメニューの頭の部分を再修正

直接アプリ名を指定しても有効にならないので、アプリ名を定義名に変更。およびアイコンも変更。

        { "Gedit", gui_editor2, menubar.utils.lookup_icon("/usr/share/icons/hicolor/scalable/apps/org.gnome.gedit.svg") }, -- <追加>
        { "Geany", gui_editor3, menubar.utils.lookup_icon("/usr/share/icons/hicolor/scalable/apps/geany.svg") }, -- <追加>
        { "Mousepad", gui_editor, menubar.utils.lookup_icon("accessories-text-editor") }, -- <追加>
        { "Notepadqq", gui_editor4, menubar.utils.lookup_icon("/usr/share/icons/hicolor/scalable/apps/notepadqq.svg") }, -- <追加>
        { "Terminal", terminal, menubar.utils.lookup_icon("utilities-terminal") },
        -- { "Browser", browser, menubar.utils.lookup_icon("internet-web-browser") }, -- <コメント化>
        { "Firefox", browser, menubar.utils.lookup_icon("firefox") }, -- <追加>

110行目: Awesome メニューのマニュアルの閲覧先の修正

メニュー→Awesome →マニュアル →「man awesome」が起動されますが、
awesome の「man ページ」はなくなって「html ページ」に変更されています。なのですぐ終了してしまいます。

ブラウザで参照できるように変更。逆に日本語翻訳できるので便利。

    { "マニュアル", terminal .. " -e man awesome", menubar.utils.lookup_icon("system-help") },

↓ 修正:

    { "マニュアル", browser .. " file:///usr/share/doc/awesome/doc/index.html", menubar.utils.lookup_icon("system-help") },

カスタマイズしたら、別名で保存がオススメ

別名(日時付き)で設定ファイルを保存しておくとよいです。
システム更新で変わっても、参考にはできます。

>>> cp ~/.config/awesome/rc.lua ~/.config/awesome/rc.lua-2020-0316

あとがき

設定ファイルを少しいじるだけなら、前もって保存しておけば、それほど難しくないと思いました。ただし、ひとつ文字が違うだけで動かなくなることもあるので、いじるときは注意が必要で、それは自己責任です。

メインメニューに「お気に入り」のアプリを追加したので、とても便利になりました。

次の投稿に続く


今までの投稿一覧は 「ここ

-

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0