]> git.rmz.io Git - dotfiles.git/commitdiff
awesome: update topbar.lua to v4.0
authorSamir Benmendil <me@rmz.io>
Tue, 31 Jan 2017 00:40:05 +0000 (00:40 +0000)
committerSamir Benmendil <me@rmz.io>
Tue, 31 Jan 2017 00:40:05 +0000 (00:40 +0000)
awesome/topbar.lua

index 571e5c92bd4fd0285d8c4b79f172ef6864a9f0b5..938e7ed59673273b8396276f8d8e080b9c2c715f 100644 (file)
@@ -10,20 +10,24 @@ separator:set_markup('<span font="Symbola 10" color="#404040">│</span>')
 
 -- Wibox {{{1
 -- Create a wibox for each screen and add it
-mywibox = {}
-mypromptbox = {}
-mylayoutbox = {}
-mytaglist = {}
-mytaglist.buttons = awful.util.table.join(
-                    awful.button({ }, 1, awful.tag.viewonly),
-                    awful.button({ modkey }, 1, awful.client.movetotag),
+local taglist_buttons = awful.util.table.join(
+                    awful.button({ }, 1, function(t) t:view_only() end),
+                    awful.button({ modkey }, 1, function(t)
+                                              if client.focus then
+                                                  client.focus:move_to_tag(t)
+                                              end
+                                          end),
                     awful.button({ }, 3, awful.tag.viewtoggle),
-                    awful.button({ modkey }, 3, awful.client.toggletag),
-                    awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
-                    awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
-                    )
-mytasklist = {}
-mytasklist.buttons = awful.util.table.join(
+                    awful.button({ modkey }, 3, function(t)
+                                              if client.focus then
+                                                  client.focus:toggle_tag(t)
+                                              end
+                                          end),
+                    awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
+                    awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
+                )
+
+local tasklist_buttons = awful.util.table.join(
                      awful.button({ }, 1, function (c)
                                               if c == client.focus then
                                                   c.minimized = true
@@ -31,8 +35,8 @@ mytasklist.buttons = awful.util.table.join(
                                                   -- Without this, the following
                                                   -- :isvisible() makes no sense
                                                   c.minimized = false
-                                                  if not c:isvisible() then
-                                                      awful.tag.viewonly(c:tags()[1])
+                                                  if not c:isvisible() and c.first_tag then
+                                                      c.first_tag:view_only()
                                                   end
                                                   -- This will also un-minimize
                                                   -- the client, if needed
@@ -42,20 +46,18 @@ mytasklist.buttons = awful.util.table.join(
                                           end),
                      awful.button({ }, 2, function (c) c:kill() end),
                      awful.button({ }, 3, function ()
-                                              if instance then
-                                                  instance:hide()
-                                                  instance = nil
-                                              else
-                                                  instance = awful.menu.clients({ width=250 })
-                                              end
+                                            if instance and instance.wibox.visible then
+                                                instance:hide()
+                                                instance = nil
+                                            else
+                                                instance = awful.menu.clients({ theme = { width=250 }})
+                                            end
                                           end),
                      awful.button({ }, 4, function ()
                                               awful.client.focus.byidx(1)
-                                              if client.focus then client.focus:raise() end
                                           end),
                      awful.button({ }, 5, function ()
                                               awful.client.focus.byidx(-1)
-                                              if client.focus then client.focus:raise() end
                                           end))
 
 
@@ -71,43 +73,43 @@ awful.screen.connect_for_each_screen(function(s)
                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
     -- Create a taglist widget
-    s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
+    s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
 
     -- Create a tasklist widget
-    s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
+    s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
 
     -- Create the wibox
-    s.mywibox = awful.wibox({ position = "top", screen = s })
-
-    -- Widgets that are aligned to the left
-    local left_layout = wibox.layout.fixed.horizontal()
-    -- left_layout:add(mylauncher)
-    left_layout:add(s.mytaglist)
-    left_layout:add(s.mypromptbox)
-
-    -- Widgets that are aligned to the right
-    local right_layout = wibox.layout.fixed.horizontal()
-    right_layout:add(wibox.widget.systray())
-    right_layout:add(separator)
-    right_layout:add(require("widgets/pomodoro"))
-    right_layout:add(separator)
-    right_layout:add(require("widgets/awesompd"))
-    right_layout:add(require("widgets/volume_widget"))
-    if utils.has_battery() then
-        right_layout:add(separator)
-        right_layout:add(require("widgets/battery_widget"))
-    end
-    right_layout:add(separator)
-    right_layout:add(require("widgets/network_widget"))
-    right_layout:add(separator)
-    right_layout:add(require("widgets/calendar"))
-    right_layout:add(s.mylayoutbox)
-
-    -- Now bring it all together (with the tasklist in the middle)
-    local layout = wibox.layout.align.horizontal()
-    layout:set_left(left_layout)
-    layout:set_middle(s.mytasklist)
-    layout:set_right(right_layout)
+    s.mywibox = awful.wibar({ position = "top", screen = s })
 
-    s.mywibox:set_widget(layout)
+    -- 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(),
+            separator,
+            require("widgets/pomodoro"),
+            separator,
+            require("widgets/awesompd"),
+            require("widgets/volume_widget"),
+            utils.has_battery() and {
+                layout = wibox.layout.fixed.horizontal,
+                separator,
+                require("widgets/battery_widget"),
+            },
+            separator,
+            require("widgets/network_widget"),
+            separator,
+            require("widgets/calendar"),
+            s.mylayoutbox,
+        },
+    }
 end)