From: Benjamin Mako Hill Date: Tue, 15 Dec 2015 17:14:22 +0000 (-0800) Subject: updated rc file for the Awesome 3.5 (widgets are still not working) X-Git-Url: https://projects.mako.cc/source/awesome-config/commitdiff_plain/e8bd059bee1da40d165a813352ad494d767a6803 updated rc file for the Awesome 3.5 (widgets are still not working) --- diff --git a/rc.lua b/rc.lua index dc8e13e..7c28b67 100644 --- a/rc.lua +++ b/rc.lua @@ -1,14 +1,15 @@ -- Standard awesome library -require("awful") +local gears = require("gears") +local awful = require("awful") +awful.rules = require("awful.rules") require("awful.autofocus") -require("awful.rules") +-- Widget and layout library +local wibox = require("wibox") -- Theme handling library -require("beautiful") +local beautiful = require("beautiful") -- Notification library -require("naughty") - --- require vicious widgets -require("vicious") +local naughty = require("naughty") +local menubar = require("menubar") -- Load Debian menu entries require("debian.menu") @@ -25,7 +26,7 @@ end -- Handle runtime errors after startup do local in_error = false - awesome.add_signal("debug::error", function (err) + awesome.connect_signal("debug::error", function (err) -- Make sure we don't go into an endless error loop if in_error then return end in_error = true @@ -38,12 +39,15 @@ do end -- }}} - -- {{{ Variable definitions --- Themes define colours, icons, and wallpapers --- beautiful.init("/usr/share/awesome/themes/default/theme.lua") +-- Themes define colours, icons, font and wallpapers. beautiful.init("/usr/share/awesome/themes/sky/theme.lua") --- beautiful.init(os.getenv("HOME") .. "/.config/awesome/theme.lua") +theme.wallpaper = "/home/mako/images/Flag_of_Cascadia.png" +-- beautiful.init("~/.config/awesome/themes/default/theme.lua") +for s = 1, screen.count() do + gears.wallpaper.maximized(beautiful.wallpaper, s, true) +end +-- recipes here: https://wiki.archlinux.org/index.php/Awesome#Wallpaper -- This is used later as the default terminal and editor to run. terminal = "x-terminal-emulator" @@ -58,23 +62,23 @@ editor_cmd = terminal .. " -e " .. editor modkey = "Mod1" -- Table of layouts to cover with awful.layout.inc, order matters. -layouts = +local layouts = { awful.layout.suit.tile, --- awful.layout.suit.tile.left, --- awful.layout.suit.tile.bottom, --- awful.layout.suit.tile.top, --- awful.layout.suit.fair, --- awful.layout.suit.fair.horizontal, --- awful.layout.suit.spiral, --- awful.layout.suit.spiral.dwindle, awful.layout.suit.max, --- awful.layout.suit.max.fullscreen, --- awful.layout.suit.magnifier, - awful.layout.suit.floating, + awful.layout.suit.floating } -- }}} +-- {{{ Wallpaper +-- if beautiful.wallpaper then +-- for s = 1, screen.count() do +-- gears.wallpaper.maximized(beautiful.wallpaper, s, true) +-- end +-- end +-- }}} + + -- {{{ Tags -- Define a tag table which hold all screen tags. tags = {} @@ -99,31 +103,16 @@ mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesom } }) -mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), +mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) + +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it -- }}} -- {{{ Wibox -- Create a textclock widget -mytextclock = awful.widget.textclock({ align = "right" }) - --- Create a systray -mysystray = widget({ type = "systray" }) - --- Initialize widget -mycpuwidget = widget({ type = "textbox" }) --- Register widget -vicious.register(mycpuwidget, vicious.widgets.cpu, "CPU:$1%") - -mynetwidget = widget({ type = "textbox" }) - vicious.register(mynetwidget, vicious.widgets.net, "${wlan23 up_kb}(OUT) ${wlan23 down_kb}(IN)", 1) --- vicious.register(mynetwidget, vicious.widgets.net, "${wlan26 up_kb}(OUT) ${wlan26 down_kb}(IN)", 1) - -spacer = widget({ type = "textbox"}) -spacer.text = " " - -sep = widget({ type = "textbox"}) -sep.text = "|" +mytextclock = awful.widget.textclock() -- Create a wibox for each screen and add it mywibox = {} @@ -135,8 +124,8 @@ mytaglist.buttons = awful.util.table.join( awful.button({ modkey }, 1, awful.client.movetotag), awful.button({ }, 3, awful.tag.viewtoggle), awful.button({ modkey }, 3, awful.client.toggletag), - awful.button({ }, 4, awful.tag.viewnext), - awful.button({ }, 5, awful.tag.viewprev) + 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( @@ -144,6 +133,9 @@ mytasklist.buttons = awful.util.table.join( if c == client.focus then c.minimized = true else + -- Without this, the following + -- :isvisible() makes no sense + c.minimized = false if not c:isvisible() then awful.tag.viewonly(c:tags()[1]) end @@ -158,7 +150,9 @@ mytasklist.buttons = awful.util.table.join( instance:hide() instance = nil else - instance = awful.menu.clients({ width=250 }) + instance = awful.menu.clients({ + theme = { width = 250 } + }) end end), awful.button({ }, 4, function () @@ -172,7 +166,7 @@ mytasklist.buttons = awful.util.table.join( for s = 1, screen.count() do -- Create a promptbox for each screen - mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }) + mypromptbox[s] = awful.widget.prompt() -- Create an imagebox widget which will contains an icon indicating which layout we're using. -- We need one layoutbox per screen. mylayoutbox[s] = awful.widget.layoutbox(s) @@ -182,31 +176,33 @@ for s = 1, screen.count() do awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) -- Create a taglist widget - mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons) + mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons) -- Create a tasklist widget - mytasklist[s] = awful.widget.tasklist(function(c) - return awful.widget.tasklist.label.currenttags(c, s) - end, mytasklist.buttons) + mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons) -- Create the wibox mywibox[s] = awful.wibox({ position = "top", screen = s }) - -- Add widgets to the wibox - order matters - mywibox[s].widgets = { - { - mylauncher, - mytaglist[s], - mypromptbox[s], - layout = awful.widget.layout.horizontal.leftright - }, - mylayoutbox[s], - mytextclock, - s == 1 and mysystray or nil, - mycpuwidget, - mynetwidget, - mytasklist[s], - layout = awful.widget.layout.horizontal.rightleft - } + + -- Widgets that are aligned to the left + local left_layout = wibox.layout.fixed.horizontal() + left_layout:add(mylauncher) + left_layout:add(mytaglist[s]) + left_layout:add(mypromptbox[s]) + + -- Widgets that are aligned to the right + local right_layout = wibox.layout.fixed.horizontal() + if s == 1 then right_layout:add(wibox.widget.systray()) end + right_layout:add(mytextclock) + right_layout:add(mylayoutbox[s]) + + -- 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(mytasklist[s]) + layout:set_right(right_layout) + + mywibox[s]:set_widget(layout) end -- }}} @@ -234,7 +230,7 @@ globalkeys = awful.util.table.join( awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end), - awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end), + awful.key({ modkey, }, "w", function () mymainmenu:show() end), -- Layout manipulation awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), @@ -275,21 +271,20 @@ globalkeys = awful.util.table.join( mypromptbox[mouse.screen].widget, function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end), - awful.key({ modkey, "Shift"}, "x", + awful.key({ modkey, "Shift" }, "x", function () awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen].widget, awful.util.eval, nil, awful.util.getdir("cache") .. "/history_eval") end), - - -- key to make the 4 column setup for the big screen awful.key({ modkey }, "q", - function () - awful.tag.incnmaster(-1) - awful.tag.incncol(3) - end) - + function () + awful.tag.incnmaster(-1) + awful.tag.incncol(3) + end), + -- Menubar + awful.key({ modkey }, "p", function() menubar.show() end) ) clientkeys = awful.util.table.join( @@ -298,7 +293,6 @@ clientkeys = awful.util.table.join( awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), awful.key({ modkey, }, "o", awful.client.movetoscreen ), - awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end), awful.key({ modkey, }, "n", function (c) @@ -313,41 +307,47 @@ clientkeys = awful.util.table.join( end) ) --- Compute the maximum number of digit we need, limited to 9 -keynumber = 0 -for s = 1, screen.count() do - keynumber = math.min(9, math.max(#tags[s], keynumber)); -end - -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it works on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. -for i = 1, keynumber do +for i = 1, 9 do globalkeys = awful.util.table.join(globalkeys, + -- View tag only. awful.key({ modkey }, "#" .. i + 9, function () local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewonly(tags[screen][i]) + local tag = awful.tag.gettags(screen)[i] + if tag then + awful.tag.viewonly(tag) end end), + -- Toggle tag. awful.key({ modkey, "Control" }, "#" .. i + 9, function () local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewtoggle(tags[screen][i]) + local tag = awful.tag.gettags(screen)[i] + if tag then + awful.tag.viewtoggle(tag) end end), + -- Move client to tag. awful.key({ modkey, "Shift" }, "#" .. i + 9, function () - if client.focus and tags[client.focus.screen][i] then - awful.client.movetotag(tags[client.focus.screen][i]) - end + if client.focus then + local tag = awful.tag.gettags(client.focus.screen)[i] + if tag then + awful.client.movetotag(tag) + end + end end), + -- Toggle tag. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function () - if client.focus and tags[client.focus.screen][i] then - awful.client.toggletag(tags[client.focus.screen][i]) + if client.focus then + local tag = awful.tag.gettags(client.focus.screen)[i] + if tag then + awful.client.toggletag(tag) + end end end)) end @@ -362,12 +362,14 @@ root.keys(globalkeys) -- }}} -- {{{ Rules +-- Rules to apply to new clients (through the "manage" signal). awful.rules.rules = { -- All clients will match this rule. { rule = { }, properties = { border_width = beautiful.border_width, border_color = beautiful.border_normal, - focus = true, + focus = awful.client.focus.filter, + raise = true, keys = clientkeys, buttons = clientbuttons } }, { rule = { class = "MPlayer" }, @@ -377,25 +379,16 @@ awful.rules.rules = { { rule = { class = "gimp" }, properties = { floating = true } }, -- Set Firefox to always map on tags number 2 of screen 1. - -- { rule = { class = "Iceweasel" }, - -- properties = { tag = tags[1][3] } }, - { rule = { name = "oli" }, - properties = { tag = tags[1][9] } }, - -- { rule = { name = "emacs" }, - -- properties = { tag = tags[1][2] } }, - { rule = { name = "tunnel" }, - properties = { tag = tags[1][9] } }, + -- { rule = { class = "Firefox" }, + -- properties = { tag = tags[1][2] } }, } -- }}} -- {{{ Signals -- Signal function to execute when a new client appears. -client.add_signal("manage", function (c, startup) - -- Add a titlebar - -- awful.titlebar.add(c, { modkey = modkey }) - +client.connect_signal("manage", function (c, startup) -- Enable sloppy focus - c:add_signal("mouse::enter", function(c) + c:connect_signal("mouse::enter", function(c) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) then client.focus = c @@ -412,9 +405,57 @@ client.add_signal("manage", function (c, startup) awful.placement.no_overlap(c) awful.placement.no_offscreen(c) end + elseif not c.size_hints.user_position and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count change + awful.placement.no_offscreen(c) + end + + local titlebars_enabled = false + if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then + -- buttons for the titlebar + local buttons = awful.util.table.join( + awful.button({ }, 1, function() + client.focus = c + c:raise() + awful.mouse.client.move(c) + end), + awful.button({ }, 3, function() + client.focus = c + c:raise() + awful.mouse.client.resize(c) + end) + ) + + -- Widgets that are aligned to the left + local left_layout = wibox.layout.fixed.horizontal() + left_layout:add(awful.titlebar.widget.iconwidget(c)) + left_layout:buttons(buttons) + + -- Widgets that are aligned to the right + local right_layout = wibox.layout.fixed.horizontal() + right_layout:add(awful.titlebar.widget.floatingbutton(c)) + right_layout:add(awful.titlebar.widget.maximizedbutton(c)) + right_layout:add(awful.titlebar.widget.stickybutton(c)) + right_layout:add(awful.titlebar.widget.ontopbutton(c)) + right_layout:add(awful.titlebar.widget.closebutton(c)) + + -- The title goes in the middle + local middle_layout = wibox.layout.flex.horizontal() + local title = awful.titlebar.widget.titlewidget(c) + title:set_align("center") + middle_layout:add(title) + middle_layout:buttons(buttons) + + -- Now bring it all together + local layout = wibox.layout.align.horizontal() + layout:set_left(left_layout) + layout:set_right(right_layout) + layout:set_middle(middle_layout) + + awful.titlebar(c):set_widget(layout) end end) -client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end) -client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) +client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) +client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) -- }}}