From 204dd157cf11233a553ff41427230464c73fa327 Mon Sep 17 00:00:00 2001 From: Artem Sheremet Date: Sat, 19 Oct 2013 12:59:50 +0300 Subject: [PATCH] Awesome: fix config, add autoruns --- .config/awesome/rc.lua | 296 +++++++++++++++++++++++++---------------- .xinitrc | 4 + 2 files changed, 189 insertions(+), 111 deletions(-) diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 2fb2c80..a472497 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -13,6 +13,33 @@ local menubar = require("menubar") -- External programs require("externals") +--{{{ Error handling +-- Check if awesome encountered an error during startup and fell back to +-- another config (This code will only ever execute for the fallback config) +if awesome.startup_errors then + naughty.notify({ + preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors + }) +end + +-- Handle runtime errors after startup +do + local in_error = false + 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 + + naughty.notify({ + preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = err }) + in_error = false + end) +end +--}}} --{{{ Variable definitions -- Themes define colours, icons, and wallpapers @@ -24,7 +51,6 @@ beautiful.init(".config/awesome/theme/theme.lua") terminal = "xterm" editor = os.getenv("EDITOR") or "vi" editor_cmd = terminal .. " -e " .. editor -height = 18 function exec(command) awful.util.spawn(command, false) @@ -61,13 +87,21 @@ local layouts = } --}}} +--{{{ 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 = {} for s = 1, screen.count() do -- Each screen has its own tag table. tags[s] = awful.tag( - { "1:term", "2:bw", "3:vim", "4:skype", "5:mcb", "6:vbox", 7, }, s, + { "1:term", "2:bw", "3:vim", "4:skype", "5:IM", "6:vbox", 7, }, s, { layouts[7], layouts[10], layouts[10], layouts[7], layouts[10], layouts[10], layouts[10] } ) end @@ -77,7 +111,7 @@ end -- Create a laucher widget and a main menu myawesomemenu = { { "manual", terminal .. " -e man awesome" }, - { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, { "restart", awesome.restart }, { "quit", awesome.quit } } @@ -93,6 +127,10 @@ mymainmenu = awful.menu({ items = { } } }}) +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it +--}}} + mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu @@ -100,7 +138,6 @@ mylauncher = awful.widget.launcher({ --}}} --{{{ Wibox - --{{{ Reusable separator separator = wibox.widget.imagebox() separator:set_image(beautiful.widget_sep) @@ -125,25 +162,24 @@ require('externals') mywibox = {} mypromptbox = {} mylayoutbox = {} - - mytaglist = {} mytaglist.buttons = awful.util.table.join( - awful.button({ }, 1, awful.tag.viewonly), - 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({ }, 1, awful.tag.viewonly), + awful.button({ modkey }, 1, awful.client.movetotag), + 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({ }, 1, function (c) 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 @@ -168,8 +204,7 @@ mytasklist.buttons = awful.util.table.join( awful.button({ }, 5, function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end - end) -) + end)) for s = 1, screen.count() do -- Create a promptbox for each screen @@ -181,8 +216,7 @@ for s = 1, screen.count() do awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), - awful.button({ }, 5, 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.filter.all, mytaglist.buttons) @@ -192,18 +226,14 @@ for s = 1, screen.count() do -- Create the wibox mywibox[s] = awful.wibox({ position = "top", screen = s }) - local left_widgets = { - mylauncher, - mytaglist[s], - mypromptbox[s] - } + -- Widgets that are aligned to the left local left_layout = wibox.layout.fixed.horizontal() - for i, widget in pairs(left_widgets) do - left_layout:add(widget) - end + left_layout:add(mylauncher) + left_layout:add(mytaglist[s]) + left_layout:add(mypromptbox[s]) - local right_widgets = awful.util.table.join({ --[[ + local right_widgets = awful.util.table.join({ cpuwidget.i, cpuwidget.g, cpuwidget.w, @@ -235,11 +265,9 @@ for s = 1, screen.count() do wifiwidget.i, wifiwidget.w, separator, ---]] s == 1 and wibox.widget.systray() or nil, ---[[ gmailwidget.i, gmailwidget.w, pkgwidget.i, @@ -251,17 +279,16 @@ for s = 1, screen.count() do datewidget.i, datewidget.w, separator, ---]] mylayoutbox[s] }) +--]] + -- Widgets that are aligned to the right local right_layout = wibox.layout.fixed.horizontal() - for i, widget in pairs(right_widgets) do - if widget then - right_layout:add(widget) - end - end - + if s == 1 then right_layout:add(wibox.widget.systray()) end + right_layout:add(awful.widget.textclock()) + 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]) @@ -282,59 +309,59 @@ root.buttons(awful.util.table.join( --{{{ Key bindings -- read with 'xev' (xorg-xev) globalkeys = awful.util.table.join( - awful.key({ modkey, }, "Left", awful.tag.viewprev ), - awful.key({ modkey, }, "Right", awful.tag.viewnext ), - awful.key({ modkey, }, "Escape", awful.tag.history.restore), + awful.key({ modkey, }, "Left", awful.tag.viewprev ), + awful.key({ modkey, }, "Right", awful.tag.viewnext ), + awful.key({ modkey, }, "Escape", awful.tag.history.restore), - awful.key({ modkey, }, "j", + awful.key({ modkey, }, "j", function () - awful.client.focus.byidx( 1) - if client.focus then client.focus:raise() end + awful.client.focus.byidx( 1) + if client.focus then client.focus:raise() end end), - awful.key({ modkey, }, "k", + awful.key({ modkey, }, "k", function () - awful.client.focus.byidx(-1) - if client.focus then client.focus:raise() end + 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({keygrabber=true}) end), -- Layout manipulation - awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), - awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), + awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), + awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), - awful.key({ modkey, }, "u", awful.client.urgent.jumpto), - awful.key({ modkey, }, "Tab", + awful.key({ modkey, }, "u", awful.client.urgent.jumpto), + awful.key({ modkey, }, "Tab", function () - awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end end), -- Standard program - awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), + awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), awful.key({ modkey, "Control" }, "r", awesome.restart), awful.key({ modkey, "Shift" }, "q", awesome.quit), - awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), - awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), - awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), - awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), - awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), - awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), - awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), + awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), + awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), + awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), + awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), + awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), + awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), + awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), awful.key({ modkey, "Control" }, "n", awful.client.restore), - awful.key({ modkey }, "F12", externals.display.screensaver), + awful.key({ modkey }, "F12", externals.display.screensaver), - --awful.key({ modkey, "Control" }, "Up", externals.player.toggle), + --awful.key({ modkey, "Control" }, "Up", externals.player.toggle), --awful.key({ modkey, "Control" }, "Down", externals.player.stop), --awful.key({ modkey, "Control" }, "Left", externals.player.prev), --awful.key({ modkey, "Control" }, "Right", externals.player.next), - awful.key({ modkey }, "Up", externals.sound.up), + awful.key({ modkey }, "Up", externals.sound.up), awful.key({ modkey }, "Down", externals.sound.down), -- Media Keys @@ -365,7 +392,7 @@ globalkeys = awful.util.table.join( awful.key({ }, "Print", externals.display.save), -- Prompt - awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), + awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), -- TODO: unite in a single prompt with prefix (=2+2, g weather in Minsk, http://tut.by/ etc) @@ -411,64 +438,64 @@ globalkeys = awful.util.table.join( ) clientkeys = awful.util.table.join( - awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), - awful.key({ modkey, }, "F4", function (c) c:kill() end), - awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), + awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), + awful.key({ modkey, }, "F4", function (c) c:kill() end), + 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", + awful.key({ modkey, }, "o", awful.client.movetoscreen ), + awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end), + awful.key({ modkey, }, "n", function (c) - -- The client currently has the input focus, so it cannot be - -- minimized, since minimized clients can't have the focus. - c.minimized = true + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true end), - awful.key({ modkey, }, "m", + awful.key({ modkey, }, "m", function (c) - c.maximized_horizontal = not c.maximized_horizontal - c.maximized_vertical = not c.maximized_vertical + c.maximized_horizontal = not c.maximized_horizontal + c.maximized_vertical = not c.maximized_vertical 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, 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), awful.key({ modkey, "Control" }, "#" .. i + 9, - function () - local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewtoggle(tags[screen][i]) - end - end), + function () + local screen = mouse.screen + local tag = awful.tag.gettags(screen)[i] + if tag then + awful.tag.viewtoggle(tag) + end + end), 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]) + function () + if client.focus then + local tag = awful.tag.gettags(client.focus.screen)[i] + if tag then + awful.client.movetotag(tag) end - end), + end + end), 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]) + function () + if client.focus then + local tag = awful.tag.gettags(client.focus.screen)[i] + if tag then + awful.client.toggletag(tag) end - end) - ) + end + end)) end clientbuttons = awful.util.table.join( @@ -585,15 +612,62 @@ client.connect_signal("manage", function (c, startup) awful.placement.no_offscreen(c) end 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 + local titlebars_enabled = false + 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.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) - +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) for s = 1, screen.count() do screen[s]:add_signal("tag::history::update", function() client.focus = client.focus diff --git a/.xinitrc b/.xinitrc index 4bc2599..820c048 100644 --- a/.xinitrc +++ b/.xinitrc @@ -8,5 +8,9 @@ pulseaudio --start xrdb -merge .Xresources setxkbmap -layout "us,ru" -option "grp:caps_toggle,grp_led:caps,compose:ralt" xset r rate 290 30 +redshift & +skype & +chromium & +psi-plus & exec awesome