diff options
Diffstat (limited to 'awesome')
| -rw-r--r-- | awesome/rc.lua | 216 | ||||
| -rw-r--r-- | awesome/theme.lua | 18 |
2 files changed, 158 insertions, 76 deletions
diff --git a/awesome/rc.lua b/awesome/rc.lua index 72f421a..bb8033d 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -1,13 +1,18 @@ -- 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") +local naughty = require("naughty") +local menubar = require("menubar") require("vicious") +require("wibox") -- Load Debian menu entries require("debian.menu") @@ -24,7 +29,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,7 +43,7 @@ end -- }}} -- {{{ Variable definitions --- Themes define colours, icons, and wallpapers +-- Themes define colours, icons, font and wallpapers. beautiful.init("/home/reiner/.config/awesome/theme.lua") -- This is used later as the default terminal and editor to run. @@ -54,7 +59,7 @@ editor_cmd = terminal .. " -e " .. editor modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. -layouts = +local layouts = { awful.layout.suit.tile, awful.layout.suit.tile.left, @@ -71,6 +76,14 @@ 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 = {} @@ -95,24 +108,28 @@ 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" }, ' %H:%M ') +mytextclock = awful.widget.textclock(' %H:%M ') -acwidget = widget({ type = 'imagebox' }) -acwidget.image = image("/home/reiner/.config/awesome/power-ac.png") -acwidget.visible = true +acwidget = wibox.widget.imagebox() +acwidget:set_image(awful.util.getdir("config") .. "/power-ac.png") +acwidget.visible = false for bat = 0, 1 do local batpath = '/sys/class/power_supply/BAT' .. bat local batexists = io.open(batpath) if batexists~=nil then io.close(batexists) - batwidget = widget({ type = 'textbox', name = 'batwidget', align = 'right' }) + --batwidget = widget({ type = 'textbox', name = 'batwidget', align = 'right' }) + batwidget = wibox.widget.textbox() function batstate() local fcur = io.open(batpath .. '/charge_now') if not fcur then fcur = io.open(batpath .. '/energy_now') end @@ -158,12 +175,10 @@ function cpu_string() return result .. " " end -cpuwidget = widget({ type = 'textbox', name = 'cpuwidget', align = 'right' }) +--cpuwidget = widget({ type = 'textbox', name = 'cpuwidget', align = 'right' }) +cpuwidget = wibox.widget.textbox() vicious.register(cpuwidget, vicious.widgets.cpu, cpu_string(), 2) --- Create a systray -mysystray = widget({ type = "systray" }) - -- Create a wibox for each screen and add it mywibox = {} mypromptbox = {} @@ -174,8 +189,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( @@ -183,6 +198,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 @@ -197,7 +215,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 () @@ -211,7 +231,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) @@ -221,32 +241,36 @@ 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 - }, - mytextclock, - s == 1 and mysystray or nil, - mylayoutbox[s], - acwidget, - batwidget, - cpuwidget, - 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() + right_layout:add(cpuwidget) + if batwidget then right_layout:add(batwidget) end + right_layout:add(acwidget) + right_layout:add(mylayoutbox[s]) + if s == 1 then right_layout:add(wibox.widget.systray()) end + right_layout:add(mytextclock) + + -- 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 -- }}} @@ -274,7 +298,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), @@ -332,7 +356,9 @@ globalkeys = awful.util.table.join( mypromptbox[mouse.screen].widget, awful.util.eval, nil, awful.util.getdir("cache") .. "/history_eval") - end) + end), + -- Menubar + awful.key({ modkey }, "p", function() menubar.show() end) ) clientkeys = awful.util.table.join( @@ -341,7 +367,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) @@ -356,41 +381,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 @@ -405,12 +436,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, size_hints_honor = false, buttons = clientbuttons } }, @@ -430,12 +463,9 @@ awful.rules.rules = { -- {{{ 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 @@ -452,9 +482,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) -- }}} diff --git a/awesome/theme.lua b/awesome/theme.lua index 983c126..e29d724 100644 --- a/awesome/theme.lua +++ b/awesome/theme.lua @@ -10,13 +10,14 @@ theme.bg_normal = "#222222" theme.bg_focus = "#535d6c" theme.bg_urgent = "#ff0000" theme.bg_minimize = "#444444" +theme.bg_systray = theme.bg_normal theme.fg_normal = "#aaaaaa" theme.fg_focus = "#ffffff" theme.fg_urgent = "#ffffff" theme.fg_minimize = "#ffffff" -theme.border_width = "1" +theme.border_width = 1 theme.border_normal = "#000000" theme.border_focus = "#535d6c" theme.border_marked = "#91231c" @@ -24,7 +25,8 @@ theme.border_marked = "#91231c" -- There are other variable sets -- overriding the default one when -- defined, the sets are: --- [taglist|tasklist]_[bg|fg]_[focus|urgent] +-- taglist_[bg|fg]_[focus|urgent|occupied|empty] +-- tasklist_[bg|fg]_[focus|urgent] -- titlebar_[bg|fg]_[normal|focus] -- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color] -- mouse_finder_[color|timeout|animate_timeout|radius|factor] @@ -41,8 +43,8 @@ theme.tasklist_floating_icon = "/usr/share/awesome/themes/default/tasklist/float -- menu_[bg|fg]_[normal|focus] -- menu_[border_color|border_width] theme.menu_submenu_icon = "/usr/share/awesome/themes/default/submenu.png" -theme.menu_height = "15" -theme.menu_width = "100" +theme.menu_height = 15 +theme.menu_width = 100 -- You can add as many variables as -- you wish and access them by using @@ -73,9 +75,7 @@ theme.titlebar_maximized_button_focus_inactive = "/usr/share/awesome/themes/def theme.titlebar_maximized_button_normal_active = "/usr/share/awesome/themes/default/titlebar/maximized_normal_active.png" theme.titlebar_maximized_button_focus_active = "/usr/share/awesome/themes/default/titlebar/maximized_focus_active.png" --- You can use your own command to set your wallpaper ---theme.wallpaper_cmd = { "awsetbg /usr/share/awesome/themes/default/background.png" } -theme.wallpaper_cmd = { "awsetbg /home/reiner/.config/awesome/wallpaper.png" } +theme.wallpaper = "/home/reiner/.config/awesome/wallpaper.png" -- You can use your own layout icons like this: theme.layout_fairh = "/usr/share/awesome/themes/default/layouts/fairhw.png" @@ -93,5 +93,9 @@ theme.layout_dwindle = "/usr/share/awesome/themes/default/layouts/dwindlew.png" theme.awesome_icon = "/usr/share/awesome/icons/awesome16.png" +-- Define the icon theme for application icons. If not set then the icons +-- from /usr/share/icons and /usr/share/icons/hicolor will be used. +theme.icon_theme = nil + return theme -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 |
