From 608117225178a49638e3ec663b1940b0dc2d564e Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 5 Dec 2010 12:25:01 +0100 Subject: Added awesome's new-colors branch --- config/awesome/rc.lua | 307 +++++++++++++++++++++++--------------------------- 1 file changed, 141 insertions(+), 166 deletions(-) (limited to 'config/awesome/rc.lua') diff --git a/config/awesome/rc.lua b/config/awesome/rc.lua index 7e6d5fe..e7c1e04 100644 --- a/config/awesome/rc.lua +++ b/config/awesome/rc.lua @@ -6,49 +6,15 @@ require("awful.rules") require("beautiful") -- Notification library require("naughty") +require("vicious") +require("functions") -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers -beautiful.init("/usr/share/awesome/themes/zenburn/theme.lua") +beautiful.init(os.getenv("HOME") .. "/.config/awesome/themes/custom/theme.lua") theme.border_width = "0" - --- Functions -function switch_tag (i) - local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewonly(tags[screen][i]) - end -end - -function toggle_tag (i) - local screen = mouse.screen - if tags[screen][i] then - awful.tag.viewtoggle(tags[screen][i]) - end -end - -function move_to_tag (i) - if client.focus and tags[client.focus.screen][i] then - awful.client.movetotag(tags[client.focus.screen][i]) - end -end - -function toggle_client_tag (i) - if client.focus and tags[client.focus.screen][i] then - awful.client.toggletag(tags[client.focus.screen][i]) - end -end - -function fexists(n) - local f = io.open(n) - - if f == nil then - return false - end - - io.close(f) - return true -end +theme.font = "terminus 8" +awesome.font = theme.font -- This is used later as the default terminal and editor to run. terminal = "urxvt" @@ -60,7 +26,8 @@ locker = "i3lock -c 000000" -- Usually, Mod4 is the key with a logo between Control and Alt. -- If you do not like this or do not have such a key, -- I suggest you to remap Mod4 to another key using xmodmap or other tools. --- However, you can use another modifier like Mod1, but it may interact with others. +-- However, you can use another modifier like Mod1, but it may interact with +-- others. modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. @@ -86,7 +53,9 @@ layouts = tags = {} for s = 1, screen.count() do -- Each screen has its own tag table. - tags[s] = awful.tag({ "Q", "W", "E", "A", "S", "D", "Z", "X", "C" }, s, layouts[1]) + tags[s] = awful.tag({ "Q", "W", "E", "A", "S", "D", "Z", "X", "C" }, + s, + layouts[1]) end -- }}} @@ -99,28 +68,49 @@ myawesomemenu = { { "quit", awesome.quit } } -mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, +mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu }, { "open terminal", terminal } } }) -mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), +mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) -- }}} -- {{{ Wibox -- Create a textclock widget -mytextclock = awful.widget.textclock({ align = "right" }) +mytextclock = awful.widget.textclock() -- Create Network usage widget ---netwidget = widget({ type = "textbox" }) ---vicious.register(netwidget, vicious.net, "down:${eth0 down_kb} up:${eth0 up_kb}") - --- Create a systray -mysystray = widget({ type = "systray" }) +netwidget = wibox.widget.textbox() +vicious.register(netwidget, vicious.widgets.net, + function (widget, args) + return string.format(" down: %03dkb/s | up: %03dkb/s ", + args["{eth0 down_kb}"], + args["{eth0 up_kb}"]) + end) + +-- Create Package widget +pkgwidget = wibox.widget.textbox() +vicious.register(pkgwidget, vicious.widgets.pkg, " updates: $1 |", 60*60, "Arch") + +-- Create mpd widget +mpdwidget = wibox.widget.textbox() +vicious.register(mpdwidget, vicious.widgets.mpd, + function (widget, args) + if args["{state}"] == "Stop" then return "" + else return 'MPD: '.. + args["{Artist}"]..' - '.. args["{Title}"] .. " " + end + end) + +-- Create a cpu usage widget +cpuwidget = wibox.widget.textbox() +vicious.register(cpuwidget, vicious.widgets.cpu, " cpu: $1% |") -- Create a wibox for each screen and add it -mywibox = {} +mytopwibox = {} +mybottomwibox = {} mypromptbox = {} mylayoutbox = {} mytaglist = {} @@ -130,84 +120,41 @@ mytaglist.buttons = awful.util.table.join( 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({ }, 5, awful.tag.viewprev)) + mytasklist = {} -mytasklist.buttons = awful.util.table.join( - awful.button({ }, 1, function (c) - if not c:isvisible() then - awful.tag.viewonly(c:tags()[1]) - end - client.focus = c - c:raise() - end), - awful.button({ }, 3, function () - if instance then - instance:hide() - instance = nil - else - instance = awful.menu.clients({ 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)) -xmms2_playing = false --- Create a previous button -myprevbutton = widget({ type = "imagebox" }) -myprevbutton.image = image(beautiful.xmms2_previous_icon) -myprevbutton:buttons(awful.util.table.join( - awful.button({ }, 1, - function () - awful.util.spawn("xmms2 prev") - end) - )) --- Create a play button -myplaybutton = widget({ type = "imagebox" }) -myplaybutton.image = image(beautiful.xmms2_play_icon) -myplaybutton:buttons(awful.util.table.join( - awful.button({ }, 1, - function () - awful.util.spawn("xmms2 toggleplay") - if xmms2_playing then xmms2_playing = false else xmms2_playing = true end - if xmms2_playing then - myplaybutton.image = image(beautiful.xmms2_pause_icon) - else - myplaybutton.image = image(beautiful.xmms2_play_icon) - end - end) - )) --- Create a stop button -mystopbutton = widget({ type = "imagebox" }) -mystopbutton.image = image(beautiful.xmms2_stop_icon) -mystopbutton:buttons(awful.util.table.join( - awful.button({ }, 1, - function () - if xmms2_playing then - xmms2_playing = false - myplaybutton.image = image(beautiful.xmms2_play_icon) - end - awful.util.spawn("xmms2 stop") - end) - )) --- Create a next button -mynextbutton = widget({ type = "imagebox" }) -mynextbutton.image = image(beautiful.xmms2_next_icon) -mynextbutton:buttons(awful.util.table.join( - awful.button({ }, 1, - function () - awful.util.spawn("xmms2 next") - end) - )) +mytasklist.buttons = + awful.util.table.join(awful.button({ }, 1, + function (c) + if not c:isvisible() then + awful.tag.viewonly(c:tags()[1]) + end + client.focus = c + c:raise() + end), + awful.button({ }, 3, + function () + if instance then + instance:hide() + instance = nil + else + instance = awful.menu.clients({ 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)) 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) @@ -217,33 +164,49 @@ 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) - - -- 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], - mynextbutton, - mystopbutton, - myplaybutton, - myprevbutton, - mytextclock, - s == 1 and mysystray or nil, - mytasklist[s], - layout = awful.widget.layout.horizontal.rightleft - } + mytasklist[s] = + awful.widget.tasklist(s, + awful.widget.tasklist.filter.currenttags, + mytasklist.buttons) + + -- Create the top wibox + mytopwibox[s] = awful.wibox({ position = "top", screen = s }) + -- Create the bottom wibox + mybottomwibox[s] = awful.wibox({ position = "bottom", screen = s }) + -- Add widgets to the top wibox - order matters + local left_layout = wibox.layout.fixed.horizontal() + left_layout:add(mylauncher) + left_layout:add(mytaglist[s]) + left_layout:add(mypromptbox[s]) + + local right_layout = wibox.layout.fixed.horizontal() + right_layout:add(mpdwidget) + if s == 1 then right_layout:add(wibox.widget.systray()) end + right_layout:add(mylayoutbox[s]) + + local layout = wibox.layout.align.horizontal() + layout:set_left(left_layout) + layout:set_right(right_layout) + + mytopwibox[s]:set_widget(layout) + + left_layout = wibox.layout.fixed.horizontal() + left_layout:add(pkgwidget) + left_layout:add(netwidget) + + right_layout = wibox.layout.fixed.horizontal() + right_layout:add(cpuwidget) + right_layout:add(mytextclock) + + layout = wibox.layout.align.horizontal() + layout:set_left(left_layout) + layout:set_middle(mytasklist[s]) + layout:set_right(right_layout) + + mybottomwibox[s]:set_widget(layout) end -- }}} @@ -270,7 +233,7 @@ globalkeys = awful.util.table.join( function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end - end), + end), awful.key({ modkey, "Mod1" }, "w", function () mymainmenu:show(true) end), -- Layout manipulation @@ -288,19 +251,19 @@ globalkeys = awful.util.table.join( end), -- Standard program - awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), - awful.key({ modkey, "Control" }, "r", awesome.restart), - awful.key({ modkey, "Mod1" }, "q", awesome.quit), - awful.key({ "Mod1", "Control" }, "l", function () awful.util.spawn(locker) 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, }, "Return", function () awful.util.spawn(terminal) end), + awful.key({ modkey, "Control" }, "r", awesome.restart), + awful.key({ modkey, "Mod1" }, "q", awesome.quit), + awful.key({ "Mod1", "Control" }, "l", function () awful.util.spawn(locker) 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), -- Extra tag bindings awful.key({ modkey, }, "q", function () switch_tag(1) end), @@ -399,12 +362,18 @@ awful.rules.rules = { properties = { floating = true } }, { rule = { class = "pinentry" }, properties = { floating = true } }, - { rule = { class = "Gimp" }, + { rule = { class = "Gimp", machine ~= "raphael" }, properties = { floating = true } }, - { rule = { class = "gwibber", name = "gwibber" }, + { rule = { class = "Gwibber" }, properties = { floating = true } }, { rule = { class = "Xsane" }, properties = { floating = true } }, +-- { rule = { floating = true }, +-- properties = { callback = function(c) +-- io.stdout:write("it's floating") +-- end +-- } +-- }, -- Set Firefox to always map on tags number 2 of screen 1. -- { rule = { class = "Firefox" }, -- properties = { tag = tags[1][2] } }, @@ -435,7 +404,13 @@ client.add_signal("manage", function (c, startup) awful.placement.no_overlap(c) awful.placement.no_offscreen(c) end - end + end + + + -- floating windows need borders + if awful.client.floating.get(c) then + c.border_width = 1 + end end) client.add_signal("focus", function(c) -- cgit v1.2.3-54-g00ecf