diff --git a/autobeautiful.lua b/autobeautiful.lua index abae7ee..524cbde 100644 --- a/autobeautiful.lua +++ b/autobeautiful.lua @@ -7,15 +7,17 @@ beautiful.init(awful.util.getdir("config") .. "/theme.lua") local wallpaperrc = awful.util.getdir("config") .. "/wallpaperrc" local f=io.open(wallpaperrc,"r") if f~=nil then - io.close(f) - dofile(wallpaperrc) -elseif beautiful.wallpaper then - f = io.open(beautiful.wallpaper) - if f ~= nil then - io.close(f) - for s = 1, screen.count() do - gears.wallpaper.maximized(beautiful.wallpaper, s, true) - end + io.close(f) + require("wallpaperrc") + screen.connect_signal("property::geometry", set_wallpaper) +else if beautiful.wallpaper then + f = io.open(beautiful.wallpaper) + if f ~= nil then + io.close(f) + screen.connect_signal("property::geometry", function(s) + gears.wallpaper.maximized(beautiful.wallpaper, s, true) + end) + end end end diff --git a/awsetbg b/awsetbg index 28dc4db..e3ce5db 100755 --- a/awsetbg +++ b/awsetbg @@ -1,6 +1,6 @@ #!/bin/zsh -WALLPAPERRC=$(awesome-client <<<'return awful.util.getdir("config") .. "/wallpaperrc"' | sed -e 's/.*string "\(.*\)"/\1/') +WALLPAPERRC=$(awesome-client <<<'return require("awful").util.getdir("config") .. "/wallpaperrc.lua"' | sed -e 's/.*string "\(.*\)"/\1/') mode="-f" @@ -73,12 +73,13 @@ require('gears').wallpaper.${method}(\"${wall}\",s${extra_args}) end" | awesome-client if [[ -n "$update" ]]; then - echo "-- wallpaperrc generated by awsetbg +echo "-- wallpaperrc generated by awsetbg +gears = require(\"gears\") +function set_wallpaper(s) local wall=\"${wall}\" local f = io.open(wall, \"r\") if f~= nil then - for s = 1, screen.count() do - require('gears').wallpaper.${method}(wall,s${extra_args}) - end - end" > $WALLPAPERRC + gears.wallpaper.${method}(wall,s${extra_args}) + end +end" > $WALLPAPERRC fi diff --git a/mybindings.lua b/mybindings.lua index e4f6cd7..083d2c5 100644 --- a/mybindings.lua +++ b/mybindings.lua @@ -8,7 +8,7 @@ local mb = binder.modal local mpd = require("separable.mpd") local scratch = require("scratch") -local calendar = require("separable.calendar") +--local calendar = require("separable.calendar") local myglobalkeys = {} @@ -65,11 +65,11 @@ local reloadmap = { end, desc = "Bindings" }, } -local calendarmap = { - o = { func = function() calendar:next() end, desc = "Next" }, - i = { func = function() calendar:prev() end, desc = "Prev" }, - onClose = function() calendar:hide() end -} +--local calendarmap = { +-- o = { func = function() calendar:next() end, desc = "Next" }, +-- i = { func = function() calendar:prev() end, desc = "Prev" }, +-- onClose = function() calendar:hide() end +--} local myglobalkeys = awful.util.table.join( @@ -111,17 +111,17 @@ local myglobalkeys = awful.util.table.join( awful.key({ }, "XF86AudioPlay", mpd.ctrl.toggle), awful.key({ }, "XF86AudioNext", mpd.ctrl.next), - awful.key({ }, "XF86AudioPrev", mpd.ctrl.prev), + awful.key({ }, "XF86AudioPrev", mpd.ctrl.prev) --}}} -- calendar {{{ - awful.key({ modkey }, "y", - function() - calendar:show() - mb.grab(calendarmap, "Calendar", true) - end - ) + --awful.key({ modkey }, "y", + --function() + -- calendar:show() + -- mb.grab(calendarmap, "Calendar", true) + --end + --) --}}} ) diff --git a/rc.lua b/rc.lua index da37e95..fe4f48a 100644 --- a/rc.lua +++ b/rc.lua @@ -1,11 +1,11 @@ -- libraries {{{ -awful = require("awful") -awful.rules = require("awful.rules") - require("awful.autofocus") -beautiful = require("autobeautiful") -naughty = require("naughty") -conf = require("localconf") - require("errors") +local awful = require("awful") + require("awful.autofocus") + --require("autobeautiful") +beautiful = require("autobeautiful") +naughty = require("naughty") +conf = require("localconf") + require("errors") inspect = require("lib.inspect") -- }}} @@ -25,10 +25,10 @@ tags.setup() -- {{{ widgets widgets = require("widgets") for s = 1, screen.count() do - local ltop = widgets.layout(s, "left", "top") - local rtop = widgets.layout(s, "right", "top") - local lbottom = widgets.layout(s, "left", "bottom") - local rbottom = widgets.layout(s, "right", "bottom") + local ltop = widgets.container(s, "left", "top") + local rtop = widgets.container(s, "right", "top") + local lbottom = widgets.container(s, "left", "bottom") + local rbottom = widgets.container(s, "right", "bottom") local clock = widgets.add.clock("clock", ltop) @@ -67,11 +67,7 @@ binder.apply() -- }}} --- {{{ rules -rules = require("rules") -rules.setup() --- }}} - +require("rules") require("signals") -- diff --git a/rules.lua b/rules.lua index 12e7f21..092fe08 100644 --- a/rules.lua +++ b/rules.lua @@ -1,235 +1,169 @@ -local rules = { mt={} } local awful = require("awful") -local tags = tags +awful.rules = require("awful.rules") + local beautiful = require("beautiful") local binder = binder or require("separable.binder") -local rule_screen = 1 - -local function popup_urgent(message) - return function(client) - client:connect_signal("property::urgent", function (c) - if c.urgent and not c.focus then - naughty.notify({ text=message }) - end - end) - end +-- create a notification when given client becomes urgent +local function popup_urgent(client, message) + client:connect_signal("property::urgent", function (c) + if c.urgent and not c.focus then + naughty.notify({ text=message }) + end + end) end -local function setup(self) - awful.rules.rules = { - -- All clients will match this rule. - { - rule = { }, - properties = { - border_width = beautiful.border_width, - border_color = beautiful.border_normal, - focus = awful.client.focus.filter, - raise = true, - minimized = false, - size_hints_honor = false, - keys = binder.client.keys(), - buttons = binder.client.buttons(), - }, - -- print name and class of new windows for debugging purposes - callback = function(c) - print("-----------\nnew client\n") - if (c["name"] ~= nil) then - print("name: " .. c["name"]) - end - if (c["class"] ~= nil) then - print("class: " .. c["class"]) - end - end - }, - { - rule = { class = "Passprompt" }, - properties = { ontop = true, focus = true} - }, - { - rule = { class = "Sm" }, - properties = { - floating = true, - size_hints_honor = true, - -- --ontop = true, - fullscreen = true, - -- border_width = 0 - } - }, - { - rule_any = { class = { - "pinentry", "Passprompt", "MPlayer" - }}, - properties = { floating = true, size_hints_honor = true } - }, - { - rule = { class = "Firefox", instance = "Navigator" }, - properties = { - tag = tags[rule_screen][2], - floating = false, minimized = false - }, - }, - { - rule_any = { class = {"Pidgin"}, instance = {"Weechat"} }, - properties = { - tag = tags[rule_screen][3], opacity = 0.8 - }, - callback = popup_urgent("new chat message") - }, - { - rule = { role = "buddy_list" }, - callback = awful.client.setmaster - }, - { - rule = { class = "Eclipse" }, - properties = { - float = false - } - }, - { - rule = { class = "Steam", name = "Friends" }, - properties = { - tag = tags[rule_screen][3], - }, - callback = awful.client.setmaster - }, - { - rule = { class = "Steam", name = "Chat" }, - properties = { - tag = tags[rule_screen][3], - }, - callback = awful.client.setslave - }, - { - rule = { class = "Steam", name = "Steam" }, - properties = { - tag = tags[rule_screen][11], - } - }, - { - rule = { class = "Telegram" }, - properties = { - tag = tags[rule_screen][3], - }, - callback = awful.client.setslave - }, - { - rule_any = { role ={ "conversation" }, instance = { "Weechat" } }, - callback = awful.client.setslave - }, - { - rule = { class = "Irssi"}, - properties = { - tag = tags[rule_screen][3] - } , - callback = awful.client.setslave - }, - { - rule = { class = "Claws-mail" }, - properties = { - tag = tags[rule_screen][4] - } - }, - { - rule = { instance = "Gmutt" }, - properties = { - tag = tags[rule_screen][4] - } - }, - { - rule = { instance = "Gcanto" }, - properties = { - tag = tags[rule_screen][5] - } - }, - { - rule = { instance = "Gncmpcpp" }, - properties = { - tag = tags[rule_screen][6] - } - }, - { - rule = { class = "Gmpc" }, - properties = { - tag = tags[rule_screen][6] - } - }, - { - rule = { class = "Deluge" }, - properties = { - tag = tags[rule_screen][7] - } - }, - { - rule = { class = "Pdfpc" }, - properties = { - size_hints_honor = true, - float = true, - fullscreen = true - } - }, - { - rule = { class = "Cellwriter" }, - properties = { - tag = tags[rule_screen][1], - ontop = true, - size_hints_honor = true, - float = true, - sticky = true, - fullscreen = true - } - }, - { - rule = { class = "Xhtop" }, - properties = { - tag = tags[rule_screen][22] - } - }, - { - rule = { class = "Dmenu" }, - properties = { - opacity = 0.8 - } - }, - { - rule = { class = "URxvt" }, - properties = { - opacity = 0.8 - } - }, - { - rule = { class = "Gvim" }, - properties = { - opacity = 0.8 - } - }, - { - rule = { class = "feh", name = "timetable" }, - properties = { - tag = tags[rule_screen][13], - skip_taskbar = true, - type = desktop, - focusable = false, - border_width = 0 - } - }, - { - rule = { instance = "Awesomelog" }, - properties = { - tag = tags[rule_screen][14] - } - }, - { - rule = { class = "GLSlideshow" }, - properties = { - - } - } - } -end - -rules.setup = setup - -rules.mt.__call = setup - -return setmetatable(rules, rules.mt) +awful.rules.rules = { + -- All clients will match this rule. + { + rule = { }, + properties = { + border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + minimized = false, + size_hints_honor = false, + keys = binder.client.keys(), + buttons = binder.client.buttons(), + screen = awful.screen.preferred, + placement = awful.placement.no_overlap+awful.placement.no_offscreen + }, + -- print name and class of new windows for debugging purposes + callback = function(c) + print("-----------\nnew client\n") + if (c["name"] ~= nil) then + print("name: " .. c["name"]) + end + if (c["class"] ~= nil) then + print("class: " .. c["class"]) + end + end + }, + { + rule = { class = "Passprompt" }, + properties = { ontop = true, focus = true} + }, + { + rule = { class = "Sm" }, + properties = { + floating = true, + size_hints_honor = true, + -- --ontop = true, + fullscreen = true, + -- border_width = 0 + } + }, + { + rule_any = { class = { + "pinentry", "Passprompt", "MPlayer" + }}, + properties = { floating = true, size_hints_honor = true } + }, + { + rule = { class = "Firefox", instance = "Navigator" }, + properties = { + screen = 1, tag = "2", + floating = false, minimized = false + }, + }, + { + rule_any = { class = {"Pidgin"}, instance = {"Weechat"} }, + properties = { + tag = "3", opacity = 0.8 + }, + callback = function(c) popup_urgent(c, "new chat message") end + }, + { + rule = { role = "buddy_list" }, + callback = awful.client.setmaster + }, + { + rule = { class = "Eclipse" }, + properties = { + float = false + } + }, + { + rule = { class = "Steam", name = "Friends" }, + properties = { + tag = "3" + }, + callback = awful.client.setmaster + }, + { + rule = { class = "Steam", name = "Chat" }, + properties = { + tag = "3" + }, + callback = awful.client.setslave + }, + { + rule = { class = "Steam", name = "Steam" }, + properties = { + tag = "F1" + } + }, + { + rule = { class = "Telegram" }, + properties = { + tag = "3" + }, + callback = awful.client.setslave + }, + { + rule_any = { role ={ "conversation" }, instance = { "Weechat" } }, + callback = awful.client.setslave + }, + { + rule = { class = "Irssi"}, + properties = { + tag = "3" + } , + callback = awful.client.setslave + }, + { + rule = { instance = "Gmutt" }, + properties = { + tag = "4" + } + }, + { + rule = { class = "Gmpc" }, + properties = { + tag = "6" + } + }, + { + rule = { class = "Pdfpc" }, + properties = { + size_hints_honor = true, + float = true, + fullscreen = true + } + }, + { + rule = { class = "Dmenu" }, + properties = { + opacity = 0.8 + } + }, + { + rule = { class = "URxvt" }, + properties = { + opacity = 0.8 + } + }, + { + rule = { class = "Gvim" }, + properties = { + opacity = 0.8 + } + }, + { + rule = { instance = "Awesomelog" }, + properties = { + tag = "F4" + } + } +} diff --git a/separable/modalbind.lua b/separable/modalbind.lua index 615a548..ff45912 100644 --- a/separable/modalbind.lua +++ b/separable/modalbind.lua @@ -1,8 +1,10 @@ local modalbind = {} local wibox = require("wibox") +local awful = require("awful") +local beautiful = require("beautiful") local inited = false local modewidget = {} -local modewibox = { screen = -1 } +local modewibox = { screen = nil } local nesting = 0 --local functions @@ -22,17 +24,168 @@ for key, value in pairs(defaults) do settings[key] = value end +local aliases = {} +aliases[" "] = "Space" + + + + +local function getXOffset(s, position) + local offset = 0 + if type(position) == "table" then + offset = position.x + s.geometry.x + elseif position == "topleft" or position == "bottomleft" then + offset = s.geometry.x + elseif position == "topright" or position == "bottomright" then + offset = s.geometry.x + s.geometry.width - modewibox[s].width + end + return offset + settings.x_offset +end + + +local function getYOffset(s,position) + local offset = 0 + if type(position) == "table" then + offset = position.y + s.geometry.y + elseif position == "topleft" or position == "topright" then + offset = s.geometry.y + elseif position == "bottomleft" or position == "bottomright" then + offset = s.geometry.y + s.geometry.height - modewibox[s].height + end + return offset + settings.y_offset +end + +local function set_default(s, position) + local minwidth, minheight = modewidget[s]:fit({dpi=96}, s.geometry.width, + s.geometry.height) + modewibox[s].width = minwidth + 1; + modewibox[s].height = math.max(settings.height, minheight) + + -- modewibox[s].width = 250 + -- modewibox[s].height = 550 + + local pos = position or "bottomleft" + modewibox[s].x = getXOffset(s, pos) + modewibox[s].y = getYOffset(s, pos) +end + local function update_settings() - for s, value in ipairs(modewibox) do + for s, value in pairs(modewibox) do value.border_width = settings.border_width set_default(s) value.opacity = settings.opacity end end -local aliases = {} -aliases[" "] = "Space" +local function ensure_init() + awful.screen.connect_for_each_screen(function(s) + modewidget[s] = wibox.widget.textbox() + modewidget[s]:set_align("left") + if beautiful.fontface then + modewidget[s]:set_font(beautiful.fontface .. " " .. (beautiful.fontsize + 4)) + end + + modewibox[s] = wibox({ + fg = beautiful.fg_normal, + bg = beautiful.bg_normal, + border_width = settings.border_width, + border_color = beautiful.bg_focus, + screen = s + }) + + local modelayout = {} + modelayout[s] = wibox.layout.fixed.horizontal() + modelayout[s]:add(modewidget[s]) + modewibox[s]:set_widget(modelayout[s]); + set_default(s) + modewibox[s].visible = false + modewibox[s].ontop = true + + -- Widgets for prompt wibox + modewibox[s].widgets = { + modewidget[s], + layout = wibox.layout.fixed.horizontal + } + end) +end + +local function show_box(s, map, name) + modewibox.screen = s + local label = "" .. name .. "" + if settings.show_options then + for key, mapping in pairs(map) do + if key ~= "onClose" then + label = label .. "\n" .. key .. "" + if type(mapping) == "table" then + label = label .. "\t" .. (mapping.desc or "???") + end + end + end + end + modewidget[s]:set_markup(label) + modewibox[s].visible = true + set_default(s) +end + +local function hide_box() + local s = modewibox.screen + if s ~= nil then modewibox[s].visible = false end +end + +function grab(keymap, name, stay_in_mode) + if name then + show_box(mouse.screen, keymap, name) + nesting = nesting + 1 + end + + keygrabber.run(function(mod, key, event) + if key == "Escape" then + if keymap["onClose"] then + keymap["onClose"]() + end + keygrabber.stop() + nesting = 0 + hide_box(); + return true + end + + if event == "release" then return true end + + if aliases[key] then + key = aliases[key] + end + + if keymap[key] then + keygrabber.stop() + if type(keymap[key]) == "table" then + keymap[key].func() + else + keymap[key]() + end + if stay_in_mode then + grab(keymap, name, true) + else + nesting = nesting - 1 + if nesting < 1 then hide_box() end + return true + end + else + print("Unmapped key: \"" .. key .. "\"") + end + + return true + end) +end +modalbind.grab = grab + +function grabf(keymap, name, stay_in_mode) + return function() grab(keymap, name, stay_in_mode) end +end +modalbind.grabf = grabf + +function modebox() return modewibox[mouse.screen] end +modalbind.modebox = modebox --- Change the opacity of the modebox. -- @param amount opacity between 0.0 and 1.0, or nil to use default @@ -100,155 +253,5 @@ function set_show_options(bool) end modalbind.set_show_options = set_show_options - -local function getXOffset(s, position) - local offset = 0 - if type(position) == "table" then - offset = position.x + screen[s].geometry.x - elseif position == "topleft" or position == "bottomleft" then - offset = screen[s].geometry.x - elseif position == "topright" or position == "bottomright" then - offset = screen[s].geometry.x + screen[s].geometry.width - modewibox[s].width - end - return offset + settings.x_offset -end - - -local function getYOffset(s,position) - local offset = 0 - if type(position) == "table" then - offset = position.y + screen[s].geometry.y - elseif position == "topleft" or position == "topright" then - offset = screen[s].geometry.y - elseif position == "bottomleft" or position == "bottomright" then - offset = screen[s].geometry.y + screen[s].geometry.height - modewibox[s].height - end - return offset + settings.y_offset -end - -local function set_default(s, position) - local minwidth, minheight = modewidget[s]:fit(screen[s].geometry.width, - screen[s].geometry.height) - modewibox[s].width = minwidth + 1; - modewibox[s].height = math.max(settings.height, minheight) - - local pos = position or "bottomleft" - modewibox[s].x = getXOffset(s, pos) - modewibox[s].y = getYOffset(s, pos) -end - -local function ensure_init() - if inited then - return - end - inited = true - for s = 1, screen.count() do - modewidget[s] = wibox.widget.textbox() - modewidget[s]:set_align("left") - if beautiful.fontface then - modewidget[s]:set_font(beautiful.fontface .. " " .. (beautiful.fontsize + 4)) - end - - modewibox[s] = wibox({ - fg = beautiful.fg_normal, - bg = beautiful.bg_normal, - border_width = settings.border_width, - border_color = beautiful.bg_focus, - screen = s - }) - - local modelayout = {} - modelayout[s] = wibox.layout.fixed.horizontal() - modelayout[s]:add(modewidget[s]) - modewibox[s]:set_widget(modelayout[s]); - set_default(s) - modewibox[s].visible = false - modewibox[s].ontop = true - - -- Widgets for prompt wibox - modewibox[s].widgets = { - modewidget[s], - layout = wibox.layout.fixed.horizontal - } - end -end - -local function show_box(s, map, name) - ensure_init() - modewibox.screen = s - local label = "" .. name .. "" - if settings.show_options then - for key, mapping in pairs(map) do - if key ~= "onClose" then - label = label .. "\n" .. key .. "" - if type(mapping) == "table" then - label = label .. "\t" .. (mapping.desc or "???") - end - end - end - end - modewidget[s]:set_markup(label) - modewibox[s].visible = true - set_default(s) -end - -local function hide_box() - local s = modewibox.screen - if s ~= -1 then modewibox[s].visible = false end -end - -function grab(keymap, name, stay_in_mode) - if name then - show_box(mouse.screen, keymap, name) - nesting = nesting + 1 - end - - keygrabber.run(function(mod, key, event) - if key == "Escape" then - if keymap["onClose"] then - keymap["onClose"]() - end - keygrabber.stop() - nesting = 0 - hide_box(); - return true - end - - if event == "release" then return true end - - if aliases[key] then - key = aliases[key] - end - - if keymap[key] then - keygrabber.stop() - if type(keymap[key]) == "table" then - keymap[key].func() - else - keymap[key]() - end - if stay_in_mode then - grab(keymap, name, true) - else - nesting = nesting - 1 - if nesting < 1 then hide_box() end - return true - end - else - print("Unmapped key: \"" .. key .. "\"") - end - - return true - end) -end -modalbind.grab = grab - -function grabf(keymap, name, stay_in_mode) - return function() grab(keymap, name, stay_in_mode) end -end -modalbind.grabf = grabf - -function modebox() return modewibox[mouse.screen] end -modalbind.modebox = modebox - +ensure_init() return modalbind diff --git a/signals.lua b/signals.lua index 87ec7f4..f5d1dcd 100644 --- a/signals.lua +++ b/signals.lua @@ -1,69 +1,38 @@ -local awful = awful +local awful = require("awful") local beautiful = beautiful -client.connect_signal("manage", function (c, startup) - -- Enable sloppy focus - c:connect_signal("mouse::enter", function(c) - if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier - and awful.client.focus.filter(c) - and not( - client.focus ~= nil - and client.focus.class == "jetbrains-idea" - and c.class == "jetbrains-idea" - and client.focus.type == "dialog" - ) then - client.focus = c - end - end) - if not startup then - -- Set the windows at the slave, - -- i.e. put it at the end of others instead of setting it master. - awful.client.setslave(c) +client.connect_signal("manage", 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) + -- and not( + -- client.focus ~= nil + -- and client.focus.class == "jetbrains-idea" + -- and c.class == "jetbrains-idea" + -- and client.focus.type == "dialog" + -- ) then + -- client.focus = c + -- end + --end) - -- Put windows in a smart way, only if they does not set an initial position. - if not c.size_hints.user_position and not c.size_hints.program_position then - awful.placement.no_overlap(c) - awful.placement.no_offscreen(c) - end + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + -- if not awesome.startup then awful.client.setslave(c) end + + if awesome.startup and + not c.size_hints.user_position + and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) end +end) - local titlebars_enabled = false - if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then - -- Widgets that are aligned to the left - local left_layout = wibox.layout.fixed.horizontal() - left_layout:add(awful.titlebar.widget.iconwidget(c)) - - -- 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 title = awful.titlebar.widget.titlewidget(c) - title: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) - )) - - -- Now bring it all together - local layout = wibox.layout.align.horizontal() - layout:set_left(left_layout) - layout:set_right(right_layout) - layout:set_middle(title) - - awful.titlebar(c):set_widget(layout) +-- Enable sloppy focus, so that focus follows mouse. +client.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 end end) diff --git a/tags.lua b/tags.lua index 15ad5d5..99ad14d 100644 --- a/tags.lua +++ b/tags.lua @@ -3,103 +3,105 @@ local awful = require("awful") local conf = conf local modkey = conf.modkey or "Mod4" -local tags={ mt={} } +local tags={} + +awful.layout.layouts = { + awful.layout.suit.fair, + awful.layout.suit.fair.horizontal, + awful.layout.suit.tile, + awful.layout.suit.tile.bottom, + awful.layout.suit.max, + awful.layout.suit.max.fullscreen, + awful.layout.suit.floating, + -- awful.layout.suit.magnifier, + -- awful.layout.suit.corner.nw, + -- awful.layout.suit.corner.ne, + -- awful.layout.suit.corner.sw, + -- awful.layout.suit.corner.se, +} + local function getfunc_viewonly(i) return function () - local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewonly(tags[screen][i]) + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() end end end local function getfunc_viewtoggle(i) return function () - local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewtoggle(tags[screen][i]) + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) end end end local function getfunc_moveto(i) return function () - if client.focus and tags[client.focus.screen][i] then - awful.client.movetotag(tags[client.focus.screen][i]) + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end end end end local function getfunc_clienttoggle(i) return 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 = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end end end end -local defaultsetup = { - {"1:⚙"}, - { name = "2:⌘", layout = awful.layout.suit.max }, - { name = "3:☻", layout = awful.layout.suit.tile, mwfact = 0.20, ncol = 2, nmaster = 2}, - { name = "4:✉", layout = awful.layout.suit.max }, - {"5:☑"}, - {"6:♫"}, - {"7:☣"}, - {"8:☕"}, - {"9:⚂"}, - {"0:☠"}, - { name = "F1:☭", layout = awful.layout.suit.max }, - {"F2:♚"}, - {"F3:♛"}, - {"F4:♜"}--, - -- {"F5:♝"}, - -- {"F6:♞"}, - -- {"F7:♟"}, - -- {"F8:⚖"}, - -- {"F9:⚛"}, - -- {"F10:⚡"}, - -- {"F11:⚰"}, - -- {"F12:⚙"} +local tagdef = { + {"1"}, + {"2", { layout = awful.layout.suit.max }}, + {"3", { + layout = awful.layout.suit.tile, + master_width_factor = 0.20, + column_count = 2, + master_count = 2 + }}, + {"4", { layout = awful.layout.suit.max }}, + {"5"}, + {"6"}, + {"7"}, + {"8"}, + {"9"}, + {"0"}, + {"F1", { layout = awful.layout.suit.max }}, + {"F2"}, + {"F3"}, + {"F4", { layout = awful.layout.suit.max }}, } -local list = {} - -function tags.setup(setuptable) - local setup = setuptable or defaultsetup - for s = 1, screen.count() do - list[s] = {} - for i, t in ipairs(setup) do - local layout = t.layout or conf.default_layout or awful.layout.suit.fair - local name = t.name or t[1] - list[s][i] = awful.tag.new({name}, s, layout)[1]; - list[s][i].selected = false - if(t.mwfact) then - awful.tag.setmwfact(t.mwfact,list[s][i]) - end - if(t.ncol) then - awful.tag.setncol(t.ncol,list[s][i]) - end - if(t.nmaster) then - awful.tag.setnmaster(t.nmaster,list[s][i]) - end +function tags.setup() + awful.screen.connect_for_each_screen(function(s) + for _,t in ipairs(tagdef) do + awful.tag.add(t[1], awful.util.table.join( + {screen = s}, + t[2] or { layout = awful.layout.layouts[1] } + )) end - list[s][1].selected = true - end + s.tags[1]:view_only() + end) end function tags.create_bindings() - -- Compute the maximum number of digit we need, limited to 22 - keynumber = 0 - for s = 1, screen.count() do - keynumber = math.min(22, math.max(#(list[s]), keynumber)); - end - local tagkeys = {} - -- Bind all key numbers to tags, using keycodes - for i = 1, keynumber do + -- Bind all number keys and F-keys to tags + for i = 1, 21 do if i < 10 then k = "#" .. i + 9 -- number keys 1-9 elseif i == 10 then @@ -108,23 +110,21 @@ function tags.create_bindings() k = "F" .. i - 10 -- F keys end tagkeys = awful.util.table.join(tagkeys, - awful.key( { modkey }, k, getfunc_viewonly(i)), - awful.key( { modkey, "Control" }, k, getfunc_viewtoggle(i)), - awful.key( { modkey, "Shift" }, k, getfunc_moveto(i)), - awful.key( { modkey, "Control", "Shift" }, k, getfunc_clienttoggle(i)) + awful.key( { modkey }, k, getfunc_viewonly(i)), + awful.key( { modkey, "Control" }, k, getfunc_viewtoggle(i)), + awful.key( { modkey, "Shift" }, k, getfunc_moveto(i)), + awful.key( { modkey, "Control", "Shift" }, k, getfunc_clienttoggle(i)) ) end -- keys for all tags tagkeys = awful.util.table.join(tagkeys, - awful.key({ modkey }, "u", awful.client.urgent.jumpto), - 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 }, "u", awful.client.urgent.jumpto), + awful.key({ modkey }, "Left", awful.tag.viewprev ), + awful.key({ modkey }, "Right", awful.tag.viewnext ), + awful.key({ modkey }, "Escape", awful.tag.history.restore) ) return tagkeys; end -tags.mt.__index = list -tags.mt.__newindex = list -return setmetatable(tags, tags.mt) +return tags diff --git a/theme.lua b/theme.lua index ce49687..2635f92 100644 --- a/theme.lua +++ b/theme.lua @@ -1,6 +1,7 @@ -- {{{ Main theme = {} theme.wallpaper = "~/.wallpaper" + -- }}} -- {{{ Styles theme.fontface = "Dina" @@ -17,10 +18,11 @@ theme.bg_urgent = "#DA4E4E" -- }}} -- {{{ Borders -theme.border_width = "2" -theme.border_normal = "#3F3F3F" -theme.border_focus = "#AAAAFF" -theme.border_marked = "#CC9393" +theme.useless_gap = 0 +theme.border_width = 2 +theme.border_normal = "#3f3f3f" +theme.border_focus = "#aaaaff" +theme.border_marked = "#cc9393" -- }}} -- {{{ Titlebars diff --git a/widgets.lua b/widgets.lua index a33fd9b..3fbccc7 100644 --- a/widgets.lua +++ b/widgets.lua @@ -3,6 +3,7 @@ local vicious = require("vicious") local modkey = conf.modkey or "Mod4" local awful = require("awful") local tag = require("awful.tag") +local beautiful = require("beautiful") local widgets = { add = {} } -------------------------------------------------------------------------------- @@ -10,8 +11,8 @@ local widgets = { add = {} } -------------------------------------------------------------------------------- local wlist = {} local bars = {} -local leftwibox = {} -local rightwibox = {} +local leftwibar = {} +local rightwibar = {} local mytaglist = {} mytaglist.buttons = awful.util.table.join( @@ -28,64 +29,64 @@ awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end) -------------------------------------------------------------------------------- -- setup {{{ -------------------------------------------------------------------------------- -local function setup() -- {{{ +local function setup() for s = 1, screen.count() do wlist[s]={} bars[s]={} - -- Create the wibox - leftwibox[s] = awful.wibox({ + -- Create the wibar + leftwibar[s] = awful.wibar({ position = "left", screen = s, width = 18 }) - rightwibox[s] = awful.wibox({ + rightwibar[s] = awful.wibar({ position = "right", screen = s, width = 18 }) - -- {{{ create layouts - local left_bottom_layout = wibox.layout.fixed.horizontal() - local left_top_layout = wibox.layout.fixed.horizontal() + -- {{{ create containers + local left_bottom_container = wibox.layout.fixed.horizontal() + local left_top_container = wibox.layout.fixed.horizontal() - local left_layout = wibox.layout.align.horizontal() - left_layout:set_left(left_bottom_layout) - left_layout:set_right(left_top_layout) + local left_container = wibox.layout.align.horizontal() + left_container:set_left(left_bottom_container) + left_container:set_right(left_top_container) - local right_bottom_layout = wibox.layout.fixed.horizontal() - local right_top_layout = wibox.layout.fixed.horizontal() + local right_bottom_container = wibox.layout.fixed.horizontal() + local right_top_container = wibox.layout.fixed.horizontal() - local right_layout = wibox.layout.align.horizontal() - right_layout:set_left(right_top_layout) - right_layout:set_right(right_bottom_layout) + local right_container = wibox.layout.align.horizontal() + right_container:set_left(right_top_container) + right_container:set_right(right_bottom_container) --}}} - -- {{{ rotate layouts and add to wibox - local leftrotate = wibox.layout.rotate() + -- {{{ rotate containers and add to wibox + local leftrotate = wibox.container.rotate() leftrotate:set_direction('east') - leftrotate:set_widget(left_layout) - leftwibox[s]:set_widget(leftrotate) + leftrotate:set_widget(left_container) + leftwibar[s]:set_widget(leftrotate) - local rightrotate = wibox.layout.rotate() + local rightrotate = wibox.container.rotate() rightrotate:set_direction('west') - rightrotate:set_widget(right_layout) - rightwibox[s]:set_widget(rightrotate) + rightrotate:set_widget(right_container) + rightwibar[s]:set_widget(rightrotate) --}}} bars[s] = {} bars[s].left = {} - bars[s].left.bottom = left_bottom_layout - bars[s].left.top = left_top_layout + bars[s].left.bottom = left_bottom_container + bars[s].left.top = left_top_container bars[s].right = {} - bars[s].right.bottom = right_bottom_layout - bars[s].right.top = right_top_layout + bars[s].right.bottom = right_bottom_container + bars[s].right.top = right_top_container end -end -- }}} +end -- }}} -------------------------------------------------------------------------------- @@ -95,7 +96,7 @@ end -- }}} -------------------------------------------------------------------------------- -- force update of a widget -local function update(widgetname, index) -- {{{ +local function update(widgetname, index) for s = 1, screen.count() do if wlist[s] ~= nil and wlist[s][widgetname] ~= nil then if index ~= nil then @@ -109,13 +110,13 @@ end --}}} widgets.update = update --- get layout for adding widgets -local function get_layout(screen, bar, align) --{{{ +-- get container for adding widgets +local function get_container(screen, bar, align) if bars[screen][bar] == nil then return nil end - return {screen = screen, layout = bars[screen][bar][align]} -end --}}} -widgets.layout = get_layout + return {screen = screen, container = bars[screen][bar][align]} +end +widgets.container = get_container -- }}} -------------------------------------------------------------------------------- @@ -133,21 +134,21 @@ local hide = function(self) end local function wrap_and_add(name, parent, widget, callback_widget) - local container = wibox.layout.margin(widget) + local container = wibox.container.margin(widget) container.widget = widget container.show = show container.hide = hide wlist[parent.screen][name] = callback_widget == nil and widget or callback_widget - parent.layout:add(container) + parent.container:add(container) return container end -- mail widget -local function mailwidget(name, parent, mailboxes, notify_pos, title) --{{{ +local function mailwidget(name, parent, mailboxes, notify_pos, title) local widget = wibox.widget.textbox() - local bg = wibox.widget.background() + local bg = wibox.container.background() bg:set_widget(widget) local container = wrap_and_add(name, parent, bg, widget) @@ -159,16 +160,16 @@ local function mailwidget(name, parent, mailboxes, notify_pos, title) --{{{ position = notify_pos or "top_left" }) - bg:set_bg(theme.bg_urgent) - bg:set_fg(theme.fg_urgent) + bg:set_bg(beautiful.bg_urgent) + bg:set_fg(beautiful.fg_urgent) container:show() elseif args[2] > 0 then - bg:set_bg(theme.bg_focus) - bg:set_fg(theme.fg_focus) + bg:set_bg(beautiful.bg_focus) + bg:set_fg(beautiful.fg_focus) container:show() else - bg:set_bg(theme.bg_normal) - bg:set_fg(theme.fg_normal) + bg:set_bg(beautiful.bg_normal) + bg:set_fg(beautiful.fg_normal) container:hide() end return "⬓⬓ Unread "..args[2].." / New "..args[1].. " " @@ -180,21 +181,29 @@ end widgets.add.mail = mailwidget -- text clock -local function clockwidget(name, parent) -- {{{ - return wrap_and_add(name, parent, awful.widget.textclock()) +local function clockwidget(name, parent) + return wrap_and_add(name, parent, wibox.widget.textclock()) end --}}} widgets.add.clock = clockwidget --- layoutbox -local function layoutwidget(parent) -- {{{ - return wrap_and_add("layout", parent, awful.widget.layoutbox(s)) +-- containerbox +local function layoutwidget(parent) + local mylayoutbox = awful.widget.layoutbox(s) + + mylayoutbox:buttons(awful.util.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) + )) + return wrap_and_add("layout", parent, mylayoutbox); end --}}} widgets.add.layout_indicator = layoutwidget -- taglist -local function taglistwidget(name, parent) --{{{ +local function taglistwidget(name, parent) local filter_urgentonly = function(t, args) for k, c in pairs(t:clients()) do if c.urgent then return true end @@ -203,25 +212,25 @@ local function taglistwidget(name, parent) --{{{ end -- Create a taglist widget return wrap_and_add(name, parent, - awful.widget.taglist(parent.screen, awful.widget.taglist.filter.noempty, mytaglist.buttons) + awful.widget.taglist(parent.screen, awful.widget.taglist.filter.noempty, mytaglist.buttons) ) end --}}} widgets.add.taglist = taglistwidget -- system tray -- not using a name argument, because only one systray is allowed -local function systraywidget(parent) --{{{ +local function systraywidget(parent) if (wlist["systray"] ~= nil) then return end wlist["systray"] = wibox.widget.systray() - parent.layout:add(wlist["systray"]) + parent.container:add(wlist["systray"]) return wlist["systray"] end --}}} widgets.add.systray = systraywidget -- cpu usage -local function cpuwidget(name, parent) --{{{ +local function cpuwidget(name, parent) local cpu = wrap_and_add(name, parent, wibox.widget.textbox()) vicious.register(wlist[parent.screen][name], vicious.widgets.cpu, "CPU: $1%") return cpu @@ -229,22 +238,22 @@ end --}}} widgets.add.cpu = cpuwidget -- battery -local function batterywidget(name, parent, batname) --{{{ +local function batterywidget(name, parent, batname) local widget = wibox.widget.textbox() - local bg = wibox.widget.background() + local bg = wibox.container.background() bg:set_widget(widget) vicious.register(widget, vicious.widgets.bat, function (widget, args) if args[2] == 0 then return "" else if args[2] < 15 then - bg:set_bg(theme.bg_urgent) - bg:set_fg(theme.fg_urgent) + bg:set_bg(beautiful.bg_urgent) + bg:set_fg(beautiful.fg_urgent) else - bg:set_bg(theme.bg_normal) - bg:set_fg(theme.fg_normal) + bg:set_bg(beautiful.bg_normal) + bg:set_fg(beautiful.fg_normal) end return name .. ": " .. - args[1]..args[2].."% - "..args[3] + args[1]..args[2].."% - "..args[3] end end, 61, batname) widgets.update(name) @@ -253,7 +262,7 @@ end --}}} widgets.add.battery = batterywidget -- wireless status -local function wifiwidget(name, parent, interface) --{{{ +local function wifiwidget(name, parent, interface) local wifi = wrap_and_add(name, parent, wibox.widget.textbox()) vicious.register(wlist[parent.screen][name], vicious.widgets.wifi, "WLAN ${ssid} @ ${sign}dBm, Q:${link}/70", 31, interface) @@ -272,13 +281,13 @@ local spacer = wibox.widget.textbox() spacer:set_text(" ") -- manual spacing between widgets -local function spacerwidget(parent) --{{{ - parent.layout:add(spacer) +local function spacerwidget(parent) + parent.container:add(spacer) end --}}} widgets.add.spacer = spacerwidget -- change appearance of spacers -local function spacertext(text) --{{{ +local function spacertext(text) spacer:set_text(text) end --}}} widgets.set_spacer_text = spacertext