Created
March 5, 2017 21:33
-
-
Save shoman4eg/88edf04a92720b2f00d2c6b9b341c02b to your computer and use it in GitHub Desktop.
awesomewm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Awesome WM configuration template | |
--]] | |
-- {{{ Required libraries | |
local awesome, client, screen, tag = awesome, client, screen, tag | |
local ipairs, string, os, table, tostring, tonumber, type = ipairs, string, os, table, tostring, tonumber, type | |
local gears = require("gears") | |
local gdebug = require("gears.debug") | |
local awful = require("awful") | |
require("awful.autofocus") | |
local wibox = require("wibox") | |
local beautiful = require("beautiful") | |
local naughty = require("naughty") | |
local lain = require("lain") | |
-- local menubar = require("menubar") | |
local hotkeys_popup = require("awful.hotkeys_popup").widget | |
-- }}} | |
-- {{{ Variable definitions | |
-- This is used later as the default terminal and editor to run. | |
local chosen_theme = "vertex" | |
local modkey = "Mod4" | |
local altkey = "Mod1" | |
local terminal = "urxvtc" or "xterm" | |
local editor = os.getenv("EDITOR") or "nano" or "vi" | |
local editor_cmd = editor | |
local gui_editor = "subl3" | |
local filemanager = "nautilus" | |
local browser = "firefox-developer" | |
-- 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, | |
} | |
-- }}} | |
local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), chosen_theme) | |
beautiful.init(theme_path) | |
naughty.config.defaults = awful.util.table.join(naughty.config.defaults, beautiful.notification) | |
-- {{{ Error handling | |
-- 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 | |
}) | |
end | |
-- Handle runtime errors after startup | |
do | |
local in_error = false | |
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 | |
naughty.notify({ | |
preset = naughty.config.presets.critical, | |
title = "Oops, an error happened!", | |
text = tostring(err) | |
}) | |
in_error = false | |
end) | |
end | |
-- }}} | |
awful.util.spawn_with_shell("feh --bg-fill --no-xinerama ~/Pictures/Wallpapers/GF.jpg") | |
-- {{{ Autostart windowless processes | |
local function run_once(cmd_arr) | |
for _, cmd in ipairs(cmd_arr) do | |
findme = cmd | |
firstspace = cmd:find(" ") | |
if firstspace then | |
findme = cmd:sub(0, firstspace-1) | |
end | |
awful.spawn.with_shell(string.format("pgrep -u $USER -x %s > /dev/null || (%s)", findme, cmd)) | |
end | |
end | |
run_once({ | |
"urxvtd", | |
"unclutter -root" | |
}) | |
-- }}} | |
-- {{{ Helper functions | |
local function client_menu_toggle_fn() | |
local instance = nil | |
return function () | |
if instance and instance.wibox.visible then | |
instance:hide() | |
instance = nil | |
else | |
instance = awful.menu.clients({ theme = { width = 250 } }) | |
end | |
end | |
end | |
-- }}} | |
-- {{{ Menu | |
-- Create a launcher widget and a main menu | |
myawesomemenu = { | |
{ "hotkeys", function() return false, hotkeys_popup.show_help end}, | |
{ "manual", terminal .. " -e man awesome" }, | |
{ "edit config", editor_cmd .. " " .. awesome.conffile }, | |
{ "restart", awesome.restart }, | |
{ "quit", function() awesome.quit() end} | |
} | |
mymainmenu = awful.menu({ | |
items = { | |
{ "awesome", myawesomemenu, beautiful.awesome_icon }, | |
{ "open terminal", terminal } | |
} | |
}) | |
mylauncher = awful.widget.launcher({ | |
image = beautiful.awesome_icon, | |
menu = mymainmenu | |
}) | |
-- Keyboard map indicator and switcher | |
-- {{{ Wibar | |
-- 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) | |
if client.focus then | |
client.focus:move_to_tag(t) | |
end | |
end), | |
awful.button({ }, 3, awful.tag.viewtoggle), | |
awful.button({ modkey }, 3, function(t) | |
if client.focus then | |
client.focus:toggle_tag(t) | |
end | |
end), | |
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 | |
c.minimized = true | |
else | |
-- Without this, the following | |
-- :isvisible() makes no sense | |
c.minimized = false | |
if not c:isvisible() and c.first_tag then | |
c.first_tag:view_only() | |
end | |
-- This will also un-minimize | |
-- the client, if needed | |
client.focus = c | |
c:raise() | |
end | |
end), | |
awful.button({ }, 3, client_menu_toggle_fn()), | |
awful.button({ }, 4, function () | |
awful.client.focus.byidx(1) | |
end), | |
awful.button({ }, 5, function () | |
awful.client.focus.byidx(-1) | |
end) | |
) | |
awful.screen.connect_for_each_screen(function(s) beautiful.at_screen_connect(s) end) | |
-- }}} | |
-- {{{ Mouse bindings | |
root.buttons(awful.util.table.join( | |
awful.button({ }, 3, function () mymainmenu:toggle() end), | |
awful.button({ }, 4, awful.tag.viewnext), | |
awful.button({ }, 5, awful.tag.viewprev) | |
)) | |
-- }}} | |
-- {{{ Key bindings | |
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", function () awful.client.focus.byidx( 1) end, | |
{description = "focus next by index", group = "client"}), | |
awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) end, | |
{description = "focus previous by index", group = "client"}), | |
awful.key({ modkey, }, "w", function () mymainmenu:show() end, | |
{description = "show main menu", group = "awesome"}), | |
-- Layout manipulation | |
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, "Control" }, "p", function () | |
local c = client.focus | |
if not c then | |
return | |
end | |
local geom = c:geometry() | |
local t = "" | |
if c.class then t = t .. "Class: " .. c.class .. "\n" end | |
if c.instance then t = t .. "Instance: " .. c.instance .. "\n" end | |
if c.role then t = t .. "Role: " .. c.role .. "\n" end | |
if c.name then t = t .. "Name: " .. c.name .. "\n" end | |
if c.type then t = t .. "Type: " .. c.type .. "\n" end | |
if geom.width and geom.height and geom.x and geom.y then | |
t = t .. "Dimensions: " .. "x:" .. geom.x .. " y:" .. geom.y .. " w:" .. geom.width .. " h:" .. geom.height | |
end | |
naughty.notify({ | |
text = t, | |
timeout = 30, | |
}) | |
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", function () | |
awful.menu.menu_keys.down = { "Down", "Tab" } | |
local cmenu = awful.menu.clients( | |
{ width=500 }, | |
{ keygrabber=true, coords={x=0, y=20}} | |
) | |
end, | |
{description = "go back", group = "client"}), | |
awful.key({ altkey, }, "Tab", function() | |
local tag = awful.tag.selected() | |
for i=1, #tag:clients() do | |
tag:clients()[i].minimized=false end | |
awful.client.focus.byidx(1) | |
if client.focus then | |
client.focus:raise() | |
end | |
end, | |
{description = "go back", group = "client"}), | |
awful.key({ altkey, "Shift" }, "Tab", function() | |
local tag = awful.tag.selected() | |
for i=1, #tag:clients() do | |
tag:clients()[i].minimized=false end | |
awful.client.focus.byidx(-1) | |
if client.focus then | |
client.focus:raise() | |
end | |
end, | |
{description = "go back", group = "client"}), | |
-- Standard program | |
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 () | |
local lang = awesome.xkb_get_layout_group() == 0 and 1 or 0 | |
awesome.xkb_set_layout_group(lang); | |
end, | |
{description = "Change keyboard layout", group = "layout"}), | |
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, | |
{description = "select previous", group = "layout"}), | |
awful.key({ modkey, "Control" }, "n", | |
function () | |
local c = awful.client.restore() | |
-- Focus restored client | |
if c then | |
client.focus = c | |
c:raise() | |
end | |
end, | |
{description = "restore minimized", group = "client"}), | |
-- Prompt | |
awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end, | |
{description = "run prompt", group = "launcher"}), | |
-- Widgets popups | |
awful.key({ altkey, }, "c", function () lain.widget.calendar.show(7) end), | |
-- awful.key({ altkey, }, "h", function () if beautiful.fs then beautiful.fs.show(7) end end), | |
-- awful.key({ altkey, }, "w", function () if beautiful.weather then beautiful.weather.show(7) end end) | |
-- ALSA volume control | |
awful.key({ altkey }, "Up", | |
function () | |
os.execute(string.format("amixer set %s 1%%+", beautiful.volume.channel)) | |
beautiful.volume.update() | |
end), | |
awful.key({ altkey }, "Down", | |
function () | |
os.execute(string.format("amixer set %s 1%%-", beautiful.volume.channel)) | |
beautiful.volume.update() | |
end), | |
awful.key({ altkey }, "m", | |
function () | |
os.execute(string.format("amixer set %s toggle", beautiful.volume.togglechannel or beautiful.volume.channel)) | |
beautiful.volume.update() | |
end), | |
awful.key({ altkey, "Control" }, "m", | |
function () | |
os.execute(string.format("amixer set %s 100%%", beautiful.volume.channel)) | |
beautiful.volume.update() | |
end), | |
awful.key({ altkey, "Control" }, "0", | |
function () | |
os.execute(string.format("amixer -q set %s 0%%", beautiful.volume.channel)) | |
beautiful.volume.update() | |
end), | |
-- MPD control | |
awful.key({ altkey, "Control" }, "Up", | |
function () | |
awful.spawn.with_shell("mpc toggle") | |
beautiful.mpd.update() | |
end), | |
awful.key({ altkey, "Control" }, "Down", | |
function () | |
awful.spawn.with_shell("mpc stop") | |
beautiful.mpd.update() | |
end), | |
awful.key({ altkey, "Control" }, "Left", | |
function () | |
awful.spawn.with_shell("mpc prev") | |
beautiful.mpd.update() | |
end), | |
awful.key({ altkey, "Control" }, "Right", | |
function () | |
awful.spawn.with_shell("mpc next") | |
beautiful.mpd.update() | |
end), | |
awful.key({ altkey }, "0", | |
function () | |
local common = { text = "MPD widget ", position = "top_right", timeout = 2 } | |
if beautiful.mpd.timer.started then | |
beautiful.mpd.timer:stop() | |
common.text = common.text .. lain.util.markup.bold("OFF") | |
else | |
beautiful.mpd.timer:start() | |
common.text = common.text .. lain.util.markup.bold("ON") | |
end | |
naughty.notify(common) | |
end) | |
) | |
clientkeys = awful.util.table.join( | |
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen c:raise() end, | |
{description = "toggle fullscreen", group = "client"}), | |
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end, | |
{description = "close", group = "client"}), | |
awful.key({ altkey, }, "F4", 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", function (c) | |
c.minimized = true | |
end, | |
{description = "minimize", group = "client"}), | |
awful.key({ modkey, }, "m", function (c) | |
c.maximized = not c.maximized | |
c:raise() | |
end, | |
{description = "maximize", group = "client"}) | |
) | |
-- 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, 9 do | |
globalkeys = awful.util.table.join(globalkeys, | |
-- View tag only. | |
awful.key({ modkey }, "#" .. i + 9, | |
function () | |
local screen = awful.screen.focused() | |
local tag = screen.tags[i] | |
if tag then | |
tag:view_only() | |
end | |
end, | |
{description = "view tag #"..i, group = "tag"}), | |
-- Toggle tag display. | |
awful.key({ modkey, "Control" }, "#" .. i + 9, | |
function () | |
local screen = awful.screen.focused() | |
local tag = screen.tags[i] | |
if tag then | |
awful.tag.viewtoggle(tag) | |
end | |
end, | |
{description = "toggle tag #" .. i, group = "tag"}), | |
-- Move client to tag. | |
awful.key({ modkey, "Shift" }, "#" .. i + 9, | |
function () | |
if client.focus then | |
local tag = client.focus.screen.tags[i] | |
if tag then | |
client.focus:move_to_tag(tag) | |
end | |
end | |
end, | |
{description = "move focused client to tag #"..i, group = "tag"}), | |
-- Toggle tag on focused client. | |
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, | |
function () | |
if client.focus then | |
local tag = client.focus.screen.tags[i] | |
if tag then | |
client.focus:toggle_tag(tag) | |
end | |
end | |
end, | |
{description = "toggle focused client on tag #" .. i, group = "tag"}) | |
) | |
end | |
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)) | |
-- Set keys | |
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 = awful.client.focus.filter, | |
raise = true, | |
keys = clientkeys, | |
buttons = clientbuttons, | |
screen = awful.screen.preferred, | |
placement = awful.placement.no_overlap+awful.placement.no_offscreen, | |
size_hints_honor = false | |
} | |
}, | |
-- Floating clients. | |
{ rule_any = { | |
instance = { | |
"DTA", -- Firefox addon DownThemAll. | |
"copyq", -- Includes session name in class. | |
"Devtools" | |
}, | |
class = { | |
"Arandr", | |
"Gpick", | |
"Kruler", | |
"MessageWin", -- kalarm. | |
"Sxiv", | |
"Wpa_gui", | |
"pinentry", | |
"veromix", | |
"xtightvncviewer" | |
}, | |
name = { | |
"Event Tester", -- xev. | |
}, | |
role = { | |
"AlarmWindow", -- Thunderbird's calendar. | |
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools. | |
}, | |
type = { | |
"dialog" | |
} | |
}, | |
properties = { floating = true } | |
}, | |
-- Add titlebars to normal clients and dialogs | |
{ | |
rule_any = {type = { "normal", "dialog" } }, | |
properties = { titlebars_enabled = true } | |
}, | |
-- Set Firefox to always map on the first tag on screen 1. | |
{ | |
rule = {class = "Firefox", instance = "Devtools" }, | |
properties = { titlebars_enabled = false }, | |
callback = function (c) | |
awful.placement.centered( c,nil ) | |
end | |
}, | |
{ | |
rule = {type = "dialog" }, | |
properties = { titlebars_enabled = false, border_width = 0 }, | |
callback = function (c) | |
awful.placement.centered( c,nil ) | |
end | |
}, | |
{ | |
rule_any = { class = { "skypeforlinux", "TelegramDesktop", "Slack" } }, | |
properties = { screen = 1, tag = screen[1].tags[3] } | |
}, | |
{ | |
rule = { class = "Slack" }, | |
properties = { floating = true } | |
}, | |
{ | |
rule = { class = "Firefox" }, | |
properties = { screen = 1, tag = screen[1].tags[1], titlebars_enabled = false } | |
}, | |
{ | |
rule = { class = "albert", type = "utility" }, | |
properties = { titlebars_enabled = false, border_width = 0, border_color = "#000000"} | |
}, | |
} | |
if screen:count() > 1 then | |
awful.rules.rules = awful.util.table.join(awful.rules.rules, { | |
{ | |
rule = { class = "jetbrains-phpstorm" }, | |
properties = { screen = 2, tag = screen[2].tags[2] } | |
}, | |
{ | |
rule = { class = "Subl3" }, | |
properties = { screen = 2, tag = screen[2].tags[3] } | |
} | |
}) | |
end | |
-- }}} | |
-- {{{ Signals | |
-- 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 | |
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) | |
-- 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() | |
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) | |
) | |
awful.titlebar(c, {size = 18}) : setup { | |
{ -- Left | |
buttons = buttons, | |
layout = wibox.layout.fixed.horizontal | |
}, | |
{ -- Middle | |
{ -- Title | |
align = "center", | |
widget = awful.titlebar.widget.titlewidget(c) | |
}, | |
buttons = buttons, | |
layout = wibox.layout.flex.horizontal | |
}, | |
{ -- Right | |
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 | |
} | |
end) | |
-- 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) | |
-- No border for maximized clients | |
client.connect_signal("focus", | |
function(c) | |
if c.maximized then -- no borders if only 1 client visible | |
c.border_width = 0 | |
elseif #awful.screen.focused().clients > 1 then | |
c.border_width = beautiful.border_width | |
c.border_color = beautiful.border_focus | |
end | |
end | |
) | |
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) | |
-- }}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Vertex Awesome WM theme | |
github.com/copycat-killer | |
--]] | |
local gears = require("gears") | |
local lain = require("lain") | |
local awful = require("awful") | |
local wibox = require("wibox") | |
local naughty = require("naughty") | |
local math, string, tag, tonumber, type, os = math, string, tag, tonumber, type, os | |
local theme = {} | |
theme.default_dir = require("awful.util").get_themes_dir() .. "default" | |
theme.dir_moss = os.getenv("HOME") .. "/.config/awesome/themes/moss/" | |
theme.icon_dir = os.getenv("HOME") .. "/.config/awesome/themes/vertex/icons" | |
theme.titlebar_icon = theme.icon_dir .. "/titlebar" | |
theme.wallpaper = os.getenv("HOME") .. "/.config/awesome/themes/vertex/wall.png" | |
theme.font = "Liberation Sans Bold 10" | |
theme.taglist_font = "FontAwesome 12" | |
theme.widget_font = "FontAwesome 10" | |
theme.bg_normal = "#2B303B" | |
theme.bg_focus = "#2B303B" | |
theme.bg_urgent = "#2B303B" | |
theme.bg_minimize = "#2B303B" | |
theme.fg_normal = "#BEC2C8" | |
theme.fg_focus = "#BF616A" | |
theme.fg_urgent = "#BEC2C8" | |
theme.fg_minimize = "#BEC2C8" | |
theme.border_width = "1" | |
theme.border_marked = "#91231c" | |
theme.border_normal = "#2B303B" | |
theme.border_focus = "#bf616a" | |
theme.tooltip_border_color = theme.fg_focus | |
theme.tooltip_border_width = theme.border_width | |
theme.menu_height = 15 | |
theme.menu_width = 140 | |
theme.awesome_icon = theme.icon_dir .. "/awesome.png" | |
-- theme.taglist_squares_sel = theme.icon_dir .. "/awesome.png" | |
-- theme.taglist_squares_unsel = theme.icon_dir .. "/awesome.png" | |
theme.panelbg = theme.icon_dir .. "/panel.png" | |
theme.ethon = theme.icon_dir .. "/ethernet-connected.png" | |
theme.ethoff = theme.icon_dir .. "/ethernet-disconnected.png" | |
theme.volhigh = theme.icon_dir .. "/volume-high.png" | |
theme.vollow = theme.icon_dir .. "/volume-low.png" | |
theme.volmed = theme.icon_dir .. "/volume-medium.png" | |
theme.volmutedblocked = theme.icon_dir .. "/volume-muted-blocked.png" | |
theme.volmuted = theme.icon_dir .. "/volume-muted.png" | |
theme.voloff = theme.icon_dir .. "/volume-off.png" | |
theme.layout_fairh = theme.default_dir.."/layouts/fairhw.png" | |
theme.layout_fairv = theme.default_dir.."/layouts/fairvw.png" | |
theme.layout_floating = theme.default_dir.."/layouts/floatingw.png" | |
theme.layout_magnifier = theme.default_dir.."/layouts/magnifierw.png" | |
theme.layout_max = theme.default_dir.."/layouts/maxw.png" | |
theme.layout_fullscreen = theme.default_dir.."/layouts/fullscreenw.png" | |
theme.layout_tilebottom = theme.default_dir.."/layouts/tilebottomw.png" | |
theme.layout_tileleft = theme.default_dir.."/layouts/tileleftw.png" | |
theme.layout_tile = theme.default_dir.."/layouts/tilew.png" | |
theme.layout_tiletop = theme.default_dir.."/layouts/tiletopw.png" | |
theme.layout_spiral = theme.default_dir.."/layouts/spiralw.png" | |
theme.layout_dwindle = theme.default_dir.."/layouts/dwindlew.png" | |
theme.layout_cornernw = theme.default_dir.."/layouts/cornernww.png" | |
theme.layout_cornerne = theme.default_dir.."/layouts/cornernew.png" | |
theme.layout_cornersw = theme.default_dir.."/layouts/cornersww.png" | |
theme.layout_cornerse = theme.default_dir.."/layouts/cornersew.png" | |
theme.tasklist_plain_task_name = true | |
theme.tasklist_disable_icon = true | |
theme.useless_gap = 1 | |
theme.titlebar_close_button_normal = theme.dir_moss .. "/titlebar/close_normal.png" | |
theme.titlebar_close_button_focus = theme.dir_moss .. "/titlebar/close_focus.png" | |
theme.titlebar_ontop_button_normal_inactive = theme.dir_moss .. "/titlebar/ontop_normal_inactive.png" | |
theme.titlebar_ontop_button_focus_inactive = theme.dir_moss .. "/titlebar/ontop_focus_inactive.png" | |
theme.titlebar_ontop_button_normal_active = theme.dir_moss .. "/titlebar/ontop_normal_active.png" | |
theme.titlebar_ontop_button_focus_active = theme.dir_moss .. "/titlebar/ontop_focus_active.png" | |
theme.titlebar_sticky_button_normal_inactive = theme.dir_moss .. "/default/titlebar/sticky_normal_inactive.png" | |
theme.titlebar_sticky_button_focus_inactive = theme.dir_moss .. "/titlebar/sticky_focus_inactive.png" | |
theme.titlebar_sticky_button_normal_active = theme.dir_moss .. "/titlebar/sticky_normal_active.png" | |
theme.titlebar_sticky_button_focus_active = theme.dir_moss .. "/titlebar/sticky_focus_active.png" | |
theme.titlebar_floating_button_normal_inactive = theme.dir_moss .. "/titlebar/floating_normal_inactive.png" | |
theme.titlebar_floating_button_focus_inactive = theme.dir_moss .. "/titlebar/floating_focus_inactive.png" | |
theme.titlebar_floating_button_normal_active = theme.dir_moss .. "/titlebar/floating_normal_active.png" | |
theme.titlebar_floating_button_focus_active = theme.dir_moss .. "/titlebar/floating_focus_active.png" | |
theme.titlebar_maximized_button_normal_inactive = theme.dir_moss .. "/titlebar/maximized_normal_inactive.png" | |
theme.titlebar_maximized_button_focus_inactive = theme.dir_moss .. "/titlebar/maximized_focus_inactive.png" | |
theme.titlebar_maximized_button_normal_active = theme.dir_moss .. "/titlebar/maximized_normal_active.png" | |
theme.titlebar_maximized_button_focus_active = theme.dir_moss .. "/titlebar/maximized_focus_active.png" | |
theme.notification = {} | |
theme.notification.screen = 1 | |
theme.notification.icon_size = 100 | |
theme.notification.width = 450 | |
theme.notification.height = 100 | |
theme.notification.margin = 12 | |
theme.notification.opacity = 0.9 | |
theme.notification.font = "Liberation Sans Bold 10" | |
theme.notification.border_width = 2 | |
theme.notification.border_color = theme.fg_focus | |
-- http://fontawesome.io/cheatsheet | |
awful.util.tagnames1 = { " ", " ", " ", " ", " "} | |
awful.util.tagnames2 = { " ", " ", " ", " ", " "} | |
local markup = lain.util.markup | |
-- Clock | |
os.setlocale(os.getenv("LANG")) -- to localize the clock | |
local mytextclock = wibox.widget.textclock(markup(theme.fg_normal, "%a %d %b, %H:%M")) | |
mytextclock.font = theme.font | |
lain.widget.calendar({ | |
attach_to = { mytextclock }, | |
notification_preset = { | |
fg = theme.fg_normal, | |
bg = theme.bg_normal, | |
position = "top_right", | |
font = "Monospace 10" | |
} | |
}) | |
local mytextclockicon = wibox.widget.textbox(markup.font(theme.widget_font, " ")) | |
-- MPD | |
theme.mpd = lain.widget.mpd({ | |
music_dir = "/mnt/storage/Downloads/Music", | |
settings = function() | |
if mpd_now.state == "play" then | |
title = mpd_now.title | |
artist = " " .. mpd_now.artist .. " " | |
elseif mpd_now.state == "pause" then | |
title = "mpd " | |
artist = "paused " | |
else | |
title = "" | |
artist = "" | |
end | |
widget:set_markup(markup.font(theme.font, title .. markup(theme.fg_focus, artist))) | |
end | |
}) | |
-- ALSA volume | |
local volicon = wibox.widget.imagebox() | |
local voltext = wibox.widget.textbox() | |
theme.volume = lain.widget.alsabar({ | |
togglechannel = "IEC958,3", | |
notification_preset = { font = theme.font, fg = theme.fg_normal }, | |
settings = function() | |
local index, perc = "", tonumber(volume_now.level) or 0 | |
if volume_now.status == "off" then | |
index = "volmutedblocked" | |
else | |
if perc <= 5 then | |
index = "volmuted" | |
elseif perc <= 25 then | |
index = "vollow" | |
elseif perc <= 75 then | |
index = "volmed" | |
else | |
index = "volhigh" | |
end | |
end | |
volicon:set_image(theme[index]) | |
voltext:set_text(perc) | |
end | |
}) | |
volicon:buttons( | |
awful.util.table.join ( | |
awful.button({}, 1, function() | |
awful.spawn.with_shell(string.format("%s -e alsamixer", awful.util.terminal)) | |
end), | |
awful.button({}, 2, function() | |
awful.spawn(string.format("%s set %s 100%%", theme.volume.cmd, theme.volume.channel)) | |
theme.volume.notify() | |
end), | |
awful.button({}, 3, function() | |
awful.spawn(string.format("%s set %s toggle", theme.volume.cmd, theme.volume.togglechannel or theme.volume.channel)) | |
theme.volume.notify() | |
end), | |
awful.button({}, 4, function() | |
awful.spawn(string.format("%s set %s 1%%+", theme.volume.cmd, theme.volume.channel)) | |
theme.volume.notify() | |
end), | |
awful.button({}, 5, function() | |
awful.spawn(string.format("%s set %s 1%%-", theme.volume.cmd, theme.volume.channel)) | |
theme.volume.notify() | |
end) | |
) | |
) | |
-- Weather | |
theme.weather = lain.widget.weather({ | |
city_id = 554234, -- Kaliningrad | |
notification_preset = { font = theme.font }, | |
settings = function() | |
units = math.floor(weather_now["main"]["temp"]) | |
widget:set_markup(" " .. markup.font(theme.font, units .. "°C") .. " ") | |
end | |
}) | |
-- Launcher | |
local mylauncher = awful.widget.button({image = theme.awesome_icon}) | |
mylauncher:connect_signal("button::press", function() awful.util.mymainmenu:toggle() end) | |
-- Memory | |
local mymem = lain.widget.mem({ | |
settings = function() | |
widget:set_markup(" " .. markup.font(theme.font, mem_now.perc .. "%") .. " ") | |
end | |
}) | |
local mymemicon = wibox.widget.textbox(markup.font(theme.widget_font, " ")) | |
local mycpu = lain.widget.cpu({ | |
settings = function() | |
widget:set_markup(" " .. markup.font(theme.font, cpu_now.usage .. "%") .. " ") | |
end | |
}) | |
local mycpuicon = wibox.widget.textbox(markup.font(theme.widget_font, " ")) | |
-- Separators | |
local space = wibox.widget.textbox(" ") | |
local rspace1 = wibox.widget.textbox() | |
local rspace0 = wibox.widget.textbox() | |
local rspace2 = wibox.widget.textbox() | |
local rspace3 = wibox.widget.textbox() | |
local tspace1 = wibox.widget.textbox() | |
tspace1.forced_width = 18 | |
rspace1.forced_width = 16 | |
rspace0.forced_width = 18 | |
rspace2.forced_width = 19 | |
rspace3.forced_width = 21 | |
local lspace1 = wibox.widget.textbox() | |
local lspace2 = wibox.widget.textbox() | |
local lspace3 = wibox.widget.textbox() | |
lspace1.forced_height = 18 | |
lspace2.forced_height = 10 | |
lspace3.forced_height = 16 | |
function theme.at_screen_connect(s) | |
-- Tags | |
if s == screen[1] then | |
awful.tag(awful.util.tagnames1, screen[1], awful.layout.layouts) | |
end | |
if screen:count() > 1 then | |
if s == screen[2] then | |
awful.tag(awful.util.tagnames2, screen[2], awful.layout.layouts) | |
end | |
end | |
-- Create a promptbox for each screen | |
s.mypromptbox = awful.widget.prompt() | |
s.mypromptbox.bg = theme.bg_normal | |
-- 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({ }, 2, function () awful.layout.inc( 3) end), | |
awful.button({ }, 3, function () awful.layout.inc(-1) end), | |
awful.button({ }, 4, function () awful.layout.inc( 3) end), | |
awful.button({ }, 5, function () awful.layout.inc(-1) end) | |
) | |
) | |
-- Create a tasklist widget | |
s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.focused, awful.util.tasklist_buttons, { bg_focus = theme.bg_focus }) | |
mykeyboardlayout = awful.widget.keyboardlayout() | |
mykeyboardiconlayout = wibox.widget.textbox(markup.font(theme.taglist_font, " ")) | |
-- Create a taglist widget | |
s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons) | |
-- Create the wibox | |
s.mywibox = awful.wibar({ position = "top", screen = s, height = 25}) | |
-- Add widgets to the wibox | |
if s == screen[1] then | |
s.mywibox:setup { | |
layout = wibox.layout.align.horizontal, | |
{ -- Left widgets | |
s.mytaglist, | |
layout = wibox.layout.fixed.horizontal, | |
s.mypromptbox, | |
tspace1, | |
wibox.container.constraint(s.mytasklist, "exact", s.workarea.width/2.6), | |
}, | |
{ -- Middle widgets | |
layout = wibox.layout.flex.horizontal, | |
space, | |
}, | |
{ -- Right widgets | |
layout = wibox.layout.fixed.horizontal, | |
rspace0, | |
mykeyboardiconlayout, | |
mykeyboardlayout, | |
rspace0, | |
mycpuicon, | |
mycpu, | |
rspace0, | |
mymemicon, | |
mymem, | |
rspace0, | |
theme.weather.icon, | |
theme.weather.widget, | |
rspace0, | |
volicon, | |
space, | |
voltext, | |
rspace2, | |
wibox.widget.systray(), | |
rspace2, | |
s.mylayoutbox | |
}, | |
} | |
end | |
if screen:count() > 1 then | |
if s == screen[2] then | |
s.mywibox:setup { | |
layout = wibox.layout.align.horizontal, | |
{ -- Left widgets | |
s.mytaglist, | |
layout = wibox.layout.fixed.horizontal, | |
s.mypromptbox, | |
tspace1, | |
wibox.container.constraint(s.mytasklist, "exact", s.workarea.width/2.6), | |
}, | |
{ -- Middle widgets | |
layout = wibox.layout.flex.horizontal, | |
space, | |
}, | |
{ -- Right widgets | |
layout = wibox.layout.fixed.horizontal, | |
wibox.container.constraint(wibox.widget { nil, nil, theme.mpd.widget, layout = wibox.layout.align.horizontal }, "exact", s.workarea.width/4), | |
mytextclockicon, | |
mytextclock, | |
space, | |
s.mylayoutbox, | |
}, | |
} | |
end | |
end | |
end | |
return theme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment