-- This source code form is subject to the terms of the MPL-v2 https://mozilla.org/MPL/2.0/ -- local Async, Tree = require("async"), require("tree") local X, C, Conf = require("x"), require("c"), require("conf") local Util = require("util") local tilers = require("tree.tilers") -- {{{ Settings os.setlocale("") -- Set the locale to $LANG Conf.shell = "sh" -- Used by Async.spawnShell local term = "konsole" local theme = { gap = 5, margin = 5, borderWidth = 2, defaultBorderColour = 0x444444, focusedBorderColour = 0xaaaaaa, } local tilerStack = { tilers.masterLeft, tilers.masterRight, tilers.masterTop, tilers.masterBottom, getNext = Util.getNext -- Convenience to do tiler:getNext() } for t,tiler in ipairs(tilerStack) do tiler:setGap(theme.gap) end -- }}} -- {{{ Events Conf.on("newMonitor", function(mon) mon.tiler = tilerStack[1] mon:setMargins({ top = theme.margin, bottom = theme.margin, left = theme.margin, right = theme.margin }) end) Conf.on("newWindow", function(win) if win.managed then win:focus() end end) Conf.on("delWindow", function(win) if win.managed then if win.focused and #Tree.focusedMonitor.stack > 1 then win:getNext(-1):focus() end end end) -- }}} -- {{{ Bar local barStdin = Async.spawn("lemonbar", "-B", "#111111", "-f", "Source Code Pro 50", "-g", "1920x25+0+0") Async.timer(0.0, 1.0, function() -- Start after 0 seconds, repeat after 1 second local tagStr = "[1][2][3][4][5][6][7][8][9][0]" barStdin:write(string.format(" %s%%{r}%s \n", tagStr, os.date("%a %b %d %H:%M:%S"))) end) -- }}} -- {{{ Keybindings -- See https://wiki.linuxquestions.org/wiki/List_of_keysyms for all keysyms local shift, ctrl, alt, super = X.Shift, X.Control, X.Mod1, X.Mod2 local master = alt -- Meta -- Conf.onKeyPress("r", master + shift, function() Conf.init() end) Conf.onKeyPress("q", master + shift, function() os.exit(0) end) -- Spawn -- Conf.onKeyPress("Return", master, function() Async.spawn(term) end) Conf.onKeyPress("p", master, function() Async.spawn("dmenu_run", "-l", "20", "-p", "Run: ") end) -- Tiling -- local function focus(ev) if #Tree.focusedMonitor.stack < 2 then return end local d = ({ j = 1, k = -1 })[ev.key] Tree.focusedWindow:getNext(d):focus() end Conf.onKeyPress("j", master, focus) Conf.onKeyPress("k", master, focus) local function swap(ev) local stack = Tree.focusedMonitor.stack if #stack < 2 then return end local d = ({ j = 1, k = -1 })[ev.key] local cur = Tree.focusedWindow local curi = cur:getIndex() local newi = cur:getNext(d):getIndex() stack[curi], stack[newi] = stack[newi], stack[curi] Tree.focusedMonitor:updateTiling() end Conf.onKeyPress("j", master + shift, swap) Conf.onKeyPress("k", master + shift, swap) local function layout(ev) local d = ({ [master] = 1, [master+shift] = -1 })[ev.mask] local fm = Tree.focusedMonitor fm.tiler = tilerStack:getNext(fm.tiler, d) fm:updateTiling() end Conf.onKeyPress("space", master, layout) Conf.onKeyPress("space", master + shift, layout) -- Tags -- -- for t,tag in pairs(tags) do -- Conf.onKeyPress(tag.key, master, function() -- -- print(tag.id) -- Tree.tags.default:hide() -- end) -- end -- Misc -- -- Conf.onKeyPress("space", master, function() -- Lists all windows in a dmenu prompt -- local windows, rwindows = {}, {} -- for w,win in pairs(Tree.windows) do -- local name = win:getName() -- if name and not rwindows[name] then -- table.insert(windows, name) -- rwindows[name] = win -- end -- end -- Async.spawn("dmenu", function(out, err, status) -- print(out) -- end):write(table.concat(windows, "\n")):close() -- end) -- }}} -- {{{ Autostart Async.spawn("xcompmgr") Async.timer(0.1, function() Async.spawn("st") end) Async.spawn("xsetroot", "-cursor_name", "left_ptr") Async.spawn("/usr/bin/feh", "--no-fehbg", "--bg-fill", '/home/eiko/Niðurhal/anime/veggfóður/cirnohehe.png') -- Async.spawnShell([[ -- setxkbmap -model pc105 -layout is,ru-is -option caps:escape grp:rctrl_switch grp:shift_caps_toggle compose:sclk shift:both_capslock >/dev/null -- xset r rate 300 35 -- ]]) -- }}} -- Async.readFile("./thornWM", print) -- vim: fdm=marker:noet