Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- {{{ License
- --
- -- Awesome configuration, using awesome 3.4.13 on Arch GNU/Linux
- -- * Adrian C. <anrxc@sysphere.org>
- -- Screenshot: http://sysphere.org/gallery/snapshots
- -- This work is licensed under the Creative Commons Attribution-Share
- -- Alike License: http://creativecommons.org/licenses/by-sa/3.0/
- -- }}}
- -- {{{ Libraries
- require("awful")
- require("awful.rules")
- require("awful.autofocus")
- freedesktop_utils = require('freedesktop.utils')
- freedesktop_menu = require('freedesktop.menu')
- -- User libraries
- vicious = require("vicious")
- -- }}}
- -- {{{ Variable definitions
- local altkey = "Mod1"
- local modkey = "Mod4"
- local os = os
- local home = os.getenv("HOME")
- local exec = awful.util.spawn
- local sexec = awful.util.spawn_with_shell
- local scount = screen.count()
- -- Beautiful theme
- beautiful.init("/opt/local/share/awesome/themes/default/theme.lua")
- -- Window management layouts
- layouts = {
- awful.layout.suit.tile, -- 1
- awful.layout.suit.tile.bottom, -- 2
- awful.layout.suit.fair, -- 3
- awful.layout.suit.max, -- 4
- awful.layout.suit.magnifier, -- 5
- awful.layout.suit.floating -- 6
- }
- -- }}}
- -- {{{ Tags
- tags = {
- names = { "1", "2", "3", "4", "5", 6, 7, "8", "9" },
- layout = { layouts[2], layouts[1], layouts[1], layouts[4], layouts[1],
- layouts[6], layouts[6], layouts[5], layouts[6]
- }}
- for s = 1, scount do
- tags[s] = awful.tag(tags.names, s, tags.layout)
- for i, t in ipairs(tags[s]) do
- awful.tag.setproperty(t, "mwfact", i==5 and 0.13 or 0.5)
- awful.tag.setproperty(t, "hide", (i==6 or i==7) and true)
- end
- end
- -- }}}
- -- {{{ Wibox
- --
- -- {{{ Widgets configuration
- --
- -- {{{ Reusable separator
- separator = widget({ type = "imagebox" })
- separator.image = image(beautiful.widget_sep)
- -- }}}
- -- {{{ Reusable spacer
- spacer = widget({ type = "textbox" })
- spacer.text = " "
- -- }}}
- -- {{{ Battery state
- baticon = widget({ type = "imagebox" })
- baticon.image = image(beautiful.widget_bat)
- -- Initialize widget
- batwidget = widget({ type = "textbox" })
- -- Register widget
- vicious.register(batwidget, vicious.widgets.bat, "$1$2%", 61, "BAT0")
- -- }}}
- -- }}}
- -- {{{ File system usage
- fsicon = widget({ type = "imagebox" })
- fsicon.image = image(beautiful.widget_fs)
- -- Initialize widgets
- fs = {
- b = awful.widget.progressbar(), r = awful.widget.progressbar(),
- h = awful.widget.progressbar(), s = awful.widget.progressbar()
- }
- -- Progressbar properties
- for _, w in pairs(fs) do
- w:set_vertical(true):set_ticks(true)
- w:set_height(14):set_width(5):set_ticks_size(2)
- w:set_border_color(beautiful.border_widget)
- w:set_background_color(beautiful.fg_off_widget)
- w:set_gradient_colors({ beautiful.fg_widget,
- beautiful.fg_center_widget, beautiful.fg_end_widget
- }) -- Register buttons
- w.widget:buttons(awful.util.table.join(
- awful.button({ }, 1, function () exec("rox", false) end)
- ))
- end -- Enable caching
- vicious.cache(vicious.widgets.fs)
- -- Register widgets
- vicious.register(fs.b, vicious.widgets.fs, "${/boot used_p}", 599)
- vicious.register(fs.r, vicious.widgets.fs, "${/ used_p}", 599)
- vicious.register(fs.h, vicious.widgets.fs, "${/home used_p}", 599)
- vicious.register(fs.s, vicious.widgets.fs, "${/mnt/storage used_p}", 599)
- -- }}}
- -- {{{ Mail subject
- mygmail = widget({ type = "textbox" })
- gmail_t = awful.tooltip({ objects = { mygmail },})
- mygmailimg = widget({ type = "imagebox" })
- mygmailimg.image = image(beautiful.widget_mail)
- vicious.register(mygmail, vicious.widgets.gmail,
- function (widget, args)
- gmail_t:set_text(args["{subject}"])
- gmail_t:add_to_object(mygmailimg)
- return args["{count}"]
- end, 120)
- --the '120' here means check every 2 minutes.
- mygmail:buttons(awful.util.table.join(
- awful.button({ }, 1, function () exec("google-chrome\ https://gmail.com") end)
- ))
- -- }}}
- -- {{{ Volume level
- volicon = widget({ type = "imagebox" })
- volicon.image = image(beautiful.widget_vol)
- -- Initialize widgets
- volbar = awful.widget.progressbar()
- volwidget = widget({ type = "textbox" })
- -- Progressbar properties
- volbar:set_vertical(true):set_ticks(false)
- volbar:set_height(12):set_width(8):set_ticks_size(2)
- volbar:set_background_color(beautiful.fg_off_widget)
- volbar:set_gradient_colors({ beautiful.fg_end_widget,
- beautiful.fg_center_widget, beautiful.fg_widget
- }) -- Enable caching
- vicious.cache(vicious.widgets.volume)
- -- Register widgets
- vicious.register(volbar, vicious.widgets.volume, "$1", 2, "Master")
- vicious.register(volwidget, vicious.widgets.volume, "$1%", 2, "Master")
- -- }}}
- -- {{{ Date and time
- dateicon = widget({ type = "imagebox" })
- dateicon.image = image(beautiful.widget_date)
- -- Initialize widget
- datewidget = widget({ type = "textbox" })
- -- Register widget
- vicious.register(datewidget, vicious.widgets.date, "<span font-family='terminus' color='#999999'>%b %d, %l:%M:</span>%p", 1)
- -- Register buttons
- datewidget:buttons(awful.util.table.join(
- awful.button({ }, 1, function () exec("pylendar.py") end)
- ))
- -- }}}
- -- {{{ System tray
- systray = widget({ type = "systray" })
- -- }}}
- -- }}}
- -- MPD Initialize widget
- mpdwidget = widget({ type = "textbox"})
- mpdwidget.align = "center"
- mpdwidget.width = 600
- -- Register widget
- vicious.register(mpdwidget, vicious.widgets.mpd,
- function (widget, args)
- if args["{state}"] == "Stop" then
- return "...No music :("
- else
- a = "<span color='#35A1D7'>" .. args["{Artist}"] .. "</span>"
- return a..' - '.. args["{Title}"]
- end
- end, 1)
- -- {{{ Wibox initialisation
- wibox = {}
- promptbox = {}
- layoutbox = {}
- taglist = {}
- taglist.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({ }, 5, awful.tag.viewnext),
- awful.button({ }, 4, awful.tag.viewprev
- ))
- for s = 1, scount do
- -- Create a promptbox
- promptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
- -- Create a layoutbox
- layoutbox[s] = awful.widget.layoutbox(s)
- layoutbox[s]:buttons(awful.util.table.join(
- 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)
- ))
- -- Create the taglist
- taglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, taglist.buttons)
- -- Create the wibox
- wibox[s] = awful.wibox({ screen = s,
- fg = beautiful.fg_normal, height = 12,
- bg = beautiful.bg_normal, position = "top",
- border_color = beautiful.border_focus,
- border_width = beautiful.border_width
- })
- -- Add widgets to the wibox
- wibox[s].widgets = {
- { taglist[s], layoutbox[s], separator, promptbox[s],
- mpdwidget,
- ["layout"] = awful.widget.layout.horizontal.leftright
- },
- s == 1 and systray or nil,
- datewidget, dateicon,
- -- separator, upicon, netwidget, dnicon,
- separator, netwidget,
- separator, fs.s.widget, fs.h.widget, fs.r.widget, fs.b.widget, fsicon,
- separator, memicon,
- separator, tzswidget, cpuicon,
- separator, pacwidget, pacicon,
- separator, ["layout"] = awful.widget.layout.horizontal.rightleft
- }
- end
- -- }}}
- -- }}}
- -- {{{ Mouse bindings
- root.buttons(awful.util.table.join(
- awful.button({ }, 5, awful.tag.viewnext),
- awful.button({ }, 4, awful.tag.viewprev)
- ))
- -- Client bindings
- clientbuttons = awful.util.table.join(
- awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
- awful.button({ modkey }, 1, awful.mouse.client.move),
- awful.button({ modkey }, 3, awful.mouse.client.resize)
- )
- -- {{{ Client manipulation
- clientkeys = awful.util.table.join(
- awful.key({ modkey }, "c", function (c) c:kill() end),
- awful.key({ modkey }, "d", function (c) scratch.pad.set(c, 0.60, 0.60, true) end),
- awful.key({ modkey }, "f", function (c) c.fullscreen = not c.fullscreen end),
- awful.key({ modkey }, "m", function (c)
- c.maximized_horizontal = not c.maximized_horizontal
- c.maximized_vertical = not c.maximized_vertical
- end),
- awful.key({ modkey }, "o", awful.client.movetoscreen),
- awful.key({ modkey }, "Next", function () awful.client.moveresize( 20, 20, -40, -40) end),
- awful.key({ modkey }, "Prior", function () awful.client.moveresize(-20, -20, 40, 40) end),
- awful.key({ modkey }, "Down", function () awful.client.moveresize( 0, 20, 0, 0) end),
- awful.key({ modkey }, "Up", function () awful.client.moveresize( 0, -20, 0, 0) end),
- awful.key({ modkey }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end),
- awful.key({ modkey }, "Right", function () awful.client.moveresize( 20, 0, 0, 0) end),
- awful.key({ modkey, "Control"},"r", function (c) c:redraw() end),
- awful.key({ modkey, "Shift" }, "0", function (c) c.sticky = not c.sticky end),
- awful.key({ modkey, "Shift" }, "m", function (c) c:swap(awful.client.getmaster()) end),
- awful.key({ modkey, "Shift" }, "c", function (c) exec("kill -CONT " .. c.pid) end),
- awful.key({ modkey, "Shift" }, "s", function (c) exec("kill -STOP " .. c.pid) end),
- awful.key({ modkey, "Shift" }, "t", function (c)
- if c.titlebar then awful.titlebar.remove(c)
- else awful.titlebar.add(c, { modkey = modkey }) end
- end),
- awful.key({ modkey, "Shift" }, "f", function (c) if awful.client.floating.get(c)
- then awful.client.floating.delete(c); awful.titlebar.remove(c)
- else awful.client.floating.set(c, true); awful.titlebar.add(c) end
- end)
- )
- -- }}}
- -- {{{ Keyboard digits
- local keynumber = 0
- for s = 1, scount do
- keynumber = math.min(9, math.max(#tags[s], keynumber));
- end
- -- }}}
- -- {{{ Tag controls
- for i = 1, keynumber 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]) 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),
- 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
- 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])
- end
- end))
- end
- -- }}}
- -- Set keys
- root.keys(globalkeys)
- -- }}}
- -- {{{ Rules
- function titlebarwithsettings(c)
- awful.titlebar.add(c, {modkey = modkey})
- end
- awful.rules.rules = {
- { rule = { }, properties = {
- focus = true, size_hints_honor = false,
- keys = clientkeys, buttons = clientbuttons,
- border_width = beautiful.border_width,
- border_color = beautiful.border_normal }
- },
- { rule = { class = "Firefox", instance = "Navigator" },
- properties = { tag = tags[scount][3] } },
- { rule = { class = "Google-chrome", instance = "google-chrome" },
- properties = { tag = tags[scount][3] } },
- { rule = { class = "Emacs", instance = "emacs" },
- properties = { tag = tags[1][2] } },
- { rule = { class = "Emacs", instance = "_Remember_" },
- properties = { floating = true }, callback = awful.titlebar.add },
- { rule = { class = "Xmessage", instance = "xmessage" },
- properties = { floating = true }, callback = awful.titlebar.add },
- { rule = { instance = "plugin-container" },
- properties = { floating = true }, callback = awful.titlebar.add },
- { rule = { class = "Akregator" }, properties = { tag = tags[scount][8]}},
- { rule = { name = "Alpine" }, properties = { tag = tags[1][4]} },
- { rule = { class = "Gajim" }, properties = { tag = tags[1][5]} },
- { rule = { class = "Ark" }, properties = { floating = true } },
- { rule = { class = "Geeqie" }, properties = { floating = true } },
- { rule = { class = "ROX-Filer" }, properties = { floating = true } },
- { rule = { class = "Pinentry.*" }, properties = { floating = true } },
- { rule = { class = "Conky", instance = "Conky" },
- properties = { floating = true }, callback = awful.titlebar.add },
- { rule = { class = "Xfce4-notifyd", instance = "xfce4-notifyd" },
- properties = { floating = true }, callback = awful.titlebar.add },
- }
- -- }}}
- -- {{{ Signals
- --
- -- {{{ Manage signal handler
- client.add_signal("manage", function (c, startup)
- -- Add titlebar to floaters, but remove those from rule callback
- if awful.client.floating.get(c)
- or awful.layout.get(c.screen) == awful.layout.suit.floating then
- if c.titlebar then awful.titlebar.remove(c)
- else awful.titlebar.add(c, {modkey = modkey}) end
- end
- -- Enable sloppy focus
- c:add_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)
- -- Client placement
- if not startup then
- awful.client.setslave(c)
- if not c.size_hints.program_position
- and not c.size_hints.user_position then
- awful.placement.no_overlap(c)
- awful.placement.no_offscreen(c)
- end
- end
- end)
- -- }}}
- -- {{{ Focus signal handlers
- 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)
- -- }}}
- -- {{{ Arrange signal handler
- for s = 1, scount do screen[s]:add_signal("arrange", function ()
- local clients = awful.client.visible(s)
- local layout = awful.layout.getname(awful.layout.get(s))
- for _, c in pairs(clients) do -- Floaters are always on top
- if awful.client.floating.get(c) or layout == "floating"
- then if not c.fullscreen then c.above = true end
- else c.above = false end
- end
- end)
- end
- -- }}}
- -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement