+-- Standard awesome library
+local gears = require("gears")
+local awful = require("awful")
+require("awful.autofocus")
+-- Widget and layout library
+local wibox = require("wibox")
+-- Theme handling library
+local beautiful = require("beautiful")
+local naughty = require("naughty")
+local menubar = require("menubar")
+local hotkeys_popup = require("awful.hotkeys_popup").widget
+local lain = require("lain")
+local revelation = require("revelation")
+-- 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 })
+-- Handle runtime errors after startup
+ awesome.connect_signal("debug::error", function (err)
+ -- Make sure we don't go into an endless error loop
+ if in_error then return end
+ naughty.notify({ preset = naughty.config.presets.critical,
+ title = "Oops, an error happened!",
+ text = tostring(err) })
+-- {{{ Variable definitions
+-- Themes define colours, icons, font and wallpapers.
+beautiful.init("~/.config/awesome/theme.lua")
+-- This is used later as the default terminal and editor to run.
+editor = os.getenv("EDITOR") or "vim"
+editor_cmd = terminal .. " -e " .. editor
+-- 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.
+-- Table of layouts to cover with awful.layout.inc, order matters.
+awful.layout.layouts = {
+ awful.layout.suit.floating,
+ awful.layout.suit.tile,
+ awful.layout.suit.tile.left,
+ awful.layout.suit.tile.bottom,
+ awful.layout.suit.tile.top,
+ awful.layout.suit.fair,
+ awful.layout.suit.fair.horizontal,
+ awful.layout.suit.spiral,
+ awful.layout.suit.spiral.dwindle,
+ awful.layout.suit.max.fullscreen,
+ 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 client_menu_toggle_fn()
+ if instance and instance.wibox.visible then
+ instance = awful.menu.clients({ theme = { width = 250 } })
+-- Menubar configuration
+menubar.menu_gen.all_menu_dirs = { "/usr/share/applications/", "/usr/local/share/applications", os.getenv("HOME") .. "/.local/share/applications" }
+menubar.utils.terminal = terminal -- Set the terminal for applications that require it
+local cpu = lain.widgets.cpu({
+ widget:set_markup("☢ " .. cpu_now.usage .. "% | ")
+local ram = lain.widgets.mem({
+ widget:set_markup("⛁ " .. mem_now.perc .. "% | ")
+local wifi = wibox.widget.textbox()
+ awful.spawn.easy_async("sh -c \"iw dev wlp3s0 link | grep SSID\"", function(stdout, stderr, reason, exit_code)
+ local str = stdout:gsub("^.*SSID:%s*(.-)%s*$", "%1")
+ wifi:set_text("📶 " .. str .. " | ")
+local wifiTime = timer({ timeout = 10 })
+wifiTime:connect_signal("timeout", updateWifi)
+awful.spawn.easy_async("cat /sys/class/backlight/intel_backlight/max_brightness", function(stdout, stderr, reason, exit_code)
+ maxBright = tonumber(stdout)
+local bright = wibox.widget.textbox()
+function updateBright(num)
+ bright:set_text("☀ " .. math.floor(num * 100 / maxBright) .. "% | ")
+awful.spawn.easy_async("cat /sys/class/backlight/intel_backlight/brightness", function(stdout, stderr, reason, exit_code)
+ updateBright(tonumber(stdout))
+local batt = lain.widgets.contrib.tpbat({
+ if bat_now.status == "Charging" then
+ widget:set_markup("↯ " .. bat_now.perc .. "+% | ")
+ widget:set_markup("↯ " .. bat_now.perc .. "% | ")
+local vol = lain.widgets.alsa({
+ if volume_now.status == "off" then
+ widget:set_markup("𝄽 | ")
+ widget:set_markup("♫ " .. volume_now.level .. "% | ")
+-- Create a textclock widget
+mytextclock = awful.widget.textclock("🕐 %y-%m-%d %H:%M %a")
+-- Create a wibox for each screen and add it
+local taglist_buttons = awful.util.table.join(
+ awful.button({ }, 1, function(t) t:view_only() end),
+ awful.button({ modkey }, 1, function(t)
+ client.focus:move_to_tag(t)
+ awful.button({ }, 3, awful.tag.viewtoggle),
+ awful.button({ modkey }, 3, function(t)
+ client.focus:toggle_tag(t)
+ awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
+ awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
+local tasklist_buttons = awful.util.table.join(
+ awful.button({ }, 1, function (c)
+ if c == client.focus then
+ -- Without this, the following
+ -- :isvisible() makes no sense
+ if not c:isvisible() and c.first_tag then
+ c.first_tag:view_only()
+ -- This will also un-minimize
+ -- the client, if needed
+ awful.button({ }, 3, client_menu_toggle_fn()),
+ awful.button({ }, 4, function ()
+ awful.client.focus.byidx(1)
+ awful.button({ }, 5, function ()
+ awful.client.focus.byidx(-1)
+local function set_wallpaper(s)
+ if beautiful.wallpaper then
+ local wallpaper = beautiful.wallpaper
+ -- If wallpaper is a function, call it with the screen
+ if type(wallpaper) == "function" then
+ wallpaper = wallpaper(s)
+ gears.wallpaper.maximized(beautiful.wallpaper, s, "#1d1f21")
+-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
+screen.connect_signal("property::geometry", set_wallpaper)
+awful.screen.connect_for_each_screen(function(s)
+ s.quake = lain.util.quake({ app = terminal, argname = "-n %s" })
+ -- Each screen has its own tag table.
+ awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
+ -- Create a promptbox for each screen
+ s.mypromptbox = awful.widget.prompt()
+ -- Create an imagebox widget which will contains an icon indicating which layout we're using.
+ -- We need one layoutbox per screen.
+ s.mylayoutbox = awful.widget.layoutbox(s)
+ 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)))
+ -- Create a taglist widget
+ s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
+ -- Create a tasklist widget
+ s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
+ s.mywibox = awful.wibar({ position = "top", screen = s, height = "10" })
+ -- Add widgets to the wibox
+ layout = wibox.layout.align.horizontal,
+ layout = wibox.layout.fixed.horizontal,
+ s.mytasklist, -- Middle widget
+ layout = wibox.layout.fixed.horizontal,
+ wibox.widget.systray(),
+root.buttons(awful.util.table.join(
+ awful.button({ }, 4, awful.tag.viewnext),
+ awful.button({ }, 5, awful.tag.viewprev)
+globalkeys = awful.util.table.join(
+ awful.key({ modkey, }, "s", hotkeys_popup.show_help,
+ {description="show help", group="awesome"}),
+ awful.key({ modkey, }, "Left", awful.tag.viewprev,
+ {description = "view previous", group = "tag"}),
+ awful.key({ modkey, }, "Right", awful.tag.viewnext,
+ {description = "view next", group = "tag"}),
+ awful.key({ modkey, }, "Escape", awful.tag.history.restore,
+ {description = "go back", group = "tag"}),
+ awful.key({ modkey, }, "j",
+ awful.client.focus.byidx( 1)
+ {description = "focus next by index", group = "client"}
+ awful.key({ modkey, }, "k",
+ awful.client.focus.byidx(-1)
+ {description = "focus previous by index", group = "client"}
+ awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
+ {description = "swap with next client by index", group = "client"}),
+ awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
+ {description = "swap with previous client by index", group = "client"}),
+ awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
+ {description = "focus the next screen", group = "screen"}),
+ awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
+ {description = "focus the previous screen", group = "screen"}),
+ awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
+ {description = "jump to urgent client", group = "client"}),
+ awful.key({ modkey, }, "Tab",
+ awful.client.focus.history.previous()
+ {description = "go back", group = "client"}),
+ awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
+ {description = "open a terminal", group = "launcher"}),
+ awful.key({ modkey, "Control" }, "r", awesome.restart,
+ {description = "reload awesome", group = "awesome"}),
+ awful.key({ modkey, "Shift" }, "q", awesome.quit,
+ {description = "quit awesome", group = "awesome"}),
+ awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
+ {description = "increase master width factor", group = "layout"}),
+ awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
+ {description = "decrease master width factor", group = "layout"}),
+ awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
+ {description = "increase the number of master clients", group = "layout"}),
+ awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
+ {description = "decrease the number of master clients", group = "layout"}),
+ awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
+ {description = "increase the number of columns", group = "layout"}),
+ awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
+ {description = "decrease the number of columns", group = "layout"}),
+ awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
+ {description = "select next", group = "layout"}),
+ awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
+ {description = "select previous", group = "layout"}),
+ awful.key({ modkey, "Control" }, "n",
+ local c = awful.client.restore()
+ -- Focus restored client
+ {description = "restore minimized", group = "client"}),
+ awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
+ {description = "run prompt", group = "launcher"}),
+ awful.key({ modkey }, "x",
+ prompt = "Run Lua code: ",
+ textbox = awful.screen.focused().mypromptbox.widget,
+ exe_callback = awful.util.eval,
+ history_path = awful.util.get_cache_dir() .. "/history_eval"
+ {description = "lua execute prompt", group = "awesome"}),
+ awful.key({ modkey }, "p", function() menubar.show() end,
+ {description = "show the menubar", group = "launcher"}),
+ awful.key({}, "XF86MonBrightnessDown", function (c)
+ awful.spawn.easy_async("cat /sys/class/backlight/intel_backlight/brightness", function(stdout, stderr, reason, exit_code)
+ local file = io.open("/sys/class/backlight/intel_backlight/brightness", "w")
+ local num = tonumber(stdout - 100)
+ awful.key({}, "XF86MonBrightnessUp", function (c)
+ awful.spawn.easy_async("cat /sys/class/backlight/intel_backlight/brightness", function(stdout, stderr, reason, exit_code)
+ local file = io.open("/sys/class/backlight/intel_backlight/brightness", "w")
+ local num = tonumber(stdout) + 100
+ awful.key({ }, "XF86AudioRaiseVolume", function ()
+ awful.spawn("amixer set Master 9%+")
+ awful.key({ }, "XF86AudioLowerVolume", function ()
+ awful.spawn("amixer set Master 9%-")
+ awful.key({ }, "XF86AudioMute", function ()
+ awful.spawn("amixer sset Master toggle")
+ awful.key({ modkey, }, "z", function () awful.screen.focused().quake:toggle() end),
+ awful.key({ modkey, "Shift" }, "n", function () lain.util.add_tag() end),
+ awful.key({ modkey, "Shift" }, "r", function () lain.util.rename_tag() end),
+ awful.key({ modkey, "Shift" }, "Left", function () lain.util.move_tag(1) end), -- move to next tag
+ awful.key({ modkey, "Shift" }, "Right", function () lain.util.move_tag(-1) end), -- move to previous tag
+ awful.key({ modkey, "Shift" }, "d", function () lain.util.delete_tag() end),
+ awful.key({ modkey, }, "e", revelation),
+ awful.key({ }, "Print", function () os.execute("scrot ~/screenshots/%Y-%m-%d-%T-screenshot.png") end)
+clientkeys = awful.util.table.join(
+ awful.key({ modkey, }, "f",
+ c.fullscreen = not c.fullscreen
+ {description = "toggle fullscreen", group = "client"}),
+ awful.key({ modkey, }, "c", function (c) c:kill() end,
+ {description = "close", group = "client"}),
+ awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
+ {description = "toggle floating", group = "client"}),
+ awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
+ {description = "move to master", group = "client"}),
+ awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
+ {description = "move to screen", group = "client"}),
+ awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
+ {description = "toggle keep on top", group = "client"}),
+ awful.key({ modkey, }, "n",
+ -- The client currently has the input focus, so it cannot be
+ -- minimized, since minimized clients can't have the focus.
+ {description = "minimize", group = "client"}),
+ awful.key({ modkey, }, "m",
+ c.maximized = not c.maximized
+ {description = "maximize", group = "client"}),
+ awful.key({ modkey, "Control" }, "t",
+ c:emit_signal("request::titlebars")
+ awful.titlebar.toggle(c)
+ c.titlebar = not c.titlebar
+-- 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.
+ globalkeys = awful.util.table.join(globalkeys,
+ awful.key({ modkey }, "#" .. i + 9,
+ local screen = awful.screen.focused()
+ local tag = screen.tags[i]
+ {description = "view tag #"..i, group = "tag"}),
+ awful.key({ modkey, "Control" }, "#" .. i + 9,
+ local screen = awful.screen.focused()
+ local tag = screen.tags[i]
+ awful.tag.viewtoggle(tag)
+ {description = "toggle tag #" .. i, group = "tag"}),
+ awful.key({ modkey, "Shift" }, "#" .. i + 9,
+ local tag = client.focus.screen.tags[i]
+ client.focus:move_to_tag(tag)
+ {description = "move focused client to tag #"..i, group = "tag"}),
+ -- Toggle tag on focused client.
+ awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
+ local tag = client.focus.screen.tags[i]
+ client.focus:toggle_tag(tag)
+ {description = "toggle focused client on tag #" .. i, group = "tag"})
+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))
+-- Rules to apply to new clients (through the "manage" signal).
+ -- All clients will match this rule.
+ properties = { border_width = beautiful.border_width,
+ border_color = beautiful.border_normal,
+ focus = awful.client.focus.filter,
+ buttons = clientbuttons,
+ screen = awful.screen.preferred,
+ placement = awful.placement.no_overlap+awful.placement.no_offscreen,
+ size_hints_honor = false
+ "DTA", -- Firefox addon DownThemAll.
+ "copyq", -- Includes session name in class.
+ "MessageWin", -- kalarm.
+ "Event Tester", -- xev.
+ "AlarmWindow", -- Thunderbird's calendar.
+ "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
+ }, properties = { floating = true }},
+ -- Add titlebars to normal clients and dialogs
+ { rule_any = {type = { "dialog" }
+ }, properties = { titlebars_enabled = true }
+ -- Set Firefox to always map on the tag named "2" on screen 1.
+ { rule = { class = "Firefox" },
+ properties = { screen = 1, tag = "2" } },
+-- Signal function to execute when a new client appears.
+client.connect_signal("manage", function (c)
+ -- 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
+ 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)
+-- Add a titlebar if titlebars_enabled is set to true in the rules.
+client.connect_signal("request::titlebars", function(c)
+ -- buttons for the titlebar
+ local buttons = awful.util.table.join(
+ awful.button({ }, 1, function()
+ awful.mouse.client.move(c)
+ awful.button({ }, 3, function()
+ awful.mouse.client.resize(c)
+ awful.titlebar(c) : setup {
+ awful.titlebar.widget.iconwidget(c),
+ layout = wibox.layout.fixed.horizontal
+ widget = awful.titlebar.widget.titlewidget(c)
+ layout = wibox.layout.flex.horizontal
+ awful.titlebar.widget.floatingbutton (c),
+ awful.titlebar.widget.maximizedbutton(c),
+ awful.titlebar.widget.stickybutton (c),
+ awful.titlebar.widget.ontopbutton (c),
+ awful.titlebar.widget.closebutton (c),
+ layout = wibox.layout.fixed.horizontal()
+ layout = wibox.layout.align.horizontal
+-- 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.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)