Separating the code related to various components in awesome wm config











up vote
1
down vote

favorite












This is the code in default awesome wm config for creating top bar:



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)


I'm trying to separate the code related to tag management and navigation in a separate module. As you can see the setup for the bar is done in the call to wibar:setup, which takes the description of various widgets as argument.



How can I separate the tag related code from this template? This is what I've done till now:



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









share|improve this question


























    up vote
    1
    down vote

    favorite












    This is the code in default awesome wm config for creating top bar:



    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)


    I'm trying to separate the code related to tag management and navigation in a separate module. As you can see the setup for the bar is done in the call to wibar:setup, which takes the description of various widgets as argument.



    How can I separate the tag related code from this template? This is what I've done till now:



    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









    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      This is the code in default awesome wm config for creating top bar:



      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)


      I'm trying to separate the code related to tag management and navigation in a separate module. As you can see the setup for the bar is done in the call to wibar:setup, which takes the description of various widgets as argument.



      How can I separate the tag related code from this template? This is what I've done till now:



      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









      share|improve this question













      This is the code in default awesome wm config for creating top bar:



      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)


      I'm trying to separate the code related to tag management and navigation in a separate module. As you can see the setup for the bar is done in the call to wibar:setup, which takes the description of various widgets as argument.



      How can I separate the tag related code from this template? This is what I've done till now:



      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






      window-manager window awesome lua






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 6 at 18:15









      saga

      781220




      781220



























          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486437%2fseparating-the-code-related-to-various-components-in-awesome-wm-config%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486437%2fseparating-the-code-related-to-various-components-in-awesome-wm-config%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Entries order in /etc/network/interfaces

          新発田市

          Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)