素晴らしいwm構成から各コンポーネントに関連するコードを分離してください。

素晴らしいwm構成から各コンポーネントに関連するコードを分離してください。

これは、基本的なAwesome wm構成でトップバーを作成するために使用されるコードです。

awful.screen.connect_for_each_screen(function(s)
    -- Wallpaper
    set_wallpaper(s)

    -- Each screen has its own tag table.
    awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])

    -- Create a promptbox for each screen
    s.mypromptbox = awful.widget.prompt()
    -- Create an imagebox widget which will contain an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    s.mylayoutbox = awful.widget.layoutbox(s)
    s.mylayoutbox:buttons(gears.table.join(
                           awful.button({ }, 1, function () awful.layout.inc( 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(-1) end),
                           awful.button({ }, 4, function () awful.layout.inc( 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(-1) end)))
    -- Create a taglist widget
    s.mytaglist = awful.widget.taglist {
        screen  = s,
        filter  = awful.widget.taglist.filter.all,
        buttons = taglist_buttons
    }

    -- Create a tasklist widget
    s.mytasklist = awful.widget.tasklist {
        screen  = s,
        filter  = awful.widget.tasklist.filter.currenttags,
        buttons = tasklist_buttons
    }

    -- Create the wibox
    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,
        },
        s.mytasklist, -- Middle widget
        { -- Right widgets
            layout = wibox.layout.fixed.horizontal,
            mykeyboardlayout,
            wibox.widget.systray(),
            mytextclock,
            s.mylayoutbox,
        },
    }
end)

タグ管理、ナビゲーション関連のコードを別々のモジュールに分割しようとしています。ご覧のとおり、バーの設定は、wibar:setupさまざまなウィジェットの説明をパラメータとして使用する呼び出しで行われます。

このテンプレートからタグ関連コードをどのように分離できますか?これが私がこれまでにしたことです:

function pkg.SetTags(lst)
    pkg.taglist = lst

    keys = {}
    for i,c in ipairs(tagList) do
        keys = gears.table.join(keys,
            -- View tag only.
            awful.key(
                { modkey }, c,
                viewTagHook(i)
            ),
            -- Toggle tag display.
            awful.key(
                { modkey, "Control" }, c,
                viewToggleHook(i)
            ),
            -- Move client to tag.
            awful.key(
                { modkey, "Shift" }, c,
                moveClientHook(i)
            ),
            -- Toggle tag on focused client.
            awful.key(
                { modkey, "Control", "Shift" }, c,
                viewClienHook(i)
            )
        )
    end

end

ベストアンサー1

おすすめ記事