Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Alexander Gehrke
ce56320097 WIP: Somewm migration 2026-08-12 18:09:07 +02:00
17 changed files with 342 additions and 238 deletions

26
.definitions/client.d.lua Normal file
View file

@ -0,0 +1,26 @@
---@meta
---@class client: gearsobject
client = {}
---Commands the character to say "Hello {name}"
---@param name string
function client.hello(name) end
--- Get the number of instances.
--- @return integer # The number of client objects alive.
function client.instances() end
--- Set a __index metamethod for all client instances.
--- @param cb function The meta-method
function client.set_index_miss_handler(cb) end
--- Set a __newindex metamethod for all client instances.
--- @param cb function The meta-method
function client.set_newindex_miss_handler(cb) end
--- Get all clients into a table.
---
--- @param screen? integer|screen A screen number to filter clients on.
--- @param stacked? boolean Return clients in stacking order? (ordered from
--- top to bottom).
--- @return table # A table with clients.
function client.get(screen, stacked) end

14
.definitions/object.d.lua Normal file
View file

@ -0,0 +1,14 @@
---@meta
---@class gearsobject
gearsobject = {}
---
--- Connect to a signal
--- @param signal string
--- @param handler function
function gearsobject.connect_signal(signal, handler) end
--- Disconnect from a signal
--- @param signal string
--- @param handler function
function gearsobject.disconnect_signal(signal, handler) end

8
.luarc.json Normal file
View file

@ -0,0 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"workspace.library": [
"/usr/local/share/somewm/lua/",
".definitions/"
],
"runtime.version": "Lua 5.1"
}

View file

@ -5,9 +5,9 @@ local actions = {}
function actions.toggle_naughty() function actions.toggle_naughty()
if naughty.is_suspended() then if naughty.is_suspended() then
naughty.resume() naughty.resume()
naughty.notify({ text = "Notifications enabled", timeout = 2 }) naughty.notification({ text = "Notifications enabled", timeout = 2 })
else else
naughty.notify({ text = "Notifications disabled", timeout = 2 }) naughty.notification({ text = "Notifications disabled", timeout = 2 })
naughty.suspend() naughty.suspend()
end end
end end

36
inspect_client.lua Normal file
View file

@ -0,0 +1,36 @@
string.lpad = function(str, len, char)
if char == nil then char = ' ' end
return str .. string.rep(char, len - #str)
end
local properties = {
"window",
"name", "type", "class", "instance", "role",
"pid", "machine",
"icon_name", "icon", "icon_sizes",
"screen",
"hidden", "minimized", "size_hints_honor", "size_hints",
"border_width", "border_color",
"urgent",
"content",
"opacity",
"ontop", "above", "below",
"fullscreen", "maximized", "maximized_horizontal",
"maximized_vertical",
"transient_for", "modal", "group_window", "leader_window",
"valid", "first_tag", "marked", "is_fixed", "floating",
"sticky", "focusable", "skip_taskbar", "dockable", "shape",
"shape_bounding", "shape_clip", "shape_input",
"shape_client_bounding", "shape_client_clip", "startup_id",
"x", "y", "width", "height",
}
return function(c)
str = "client info:\n------------\n"
if (c ~= nil) then for _,prop in ipairs(properties) do
if (c[prop] ~= nil) then
str = str .. prop:lpad(20) .. "\t" .. tostring(c[prop]) .. "\n"
end
end end
return str
end

View file

@ -40,7 +40,7 @@ conf.cmd = {
} }
-- Mod-r binding for running programs -- Mod-r binding for running programs
conf.cmd.run = function() awful.util.spawn("dmenu_run -l 10 -y 350") end conf.cmd.run = function() awful.spawn("dmenu_run -l 10 -y 350") end
local menubar = require("menubar") local menubar = require("menubar")
conf.cmd.drun = menubar.show conf.cmd.drun = menubar.show

37
mpd.lua
View file

@ -13,11 +13,11 @@ defaults.host = "127.0.0.1"
defaults.port = "6600" defaults.port = "6600"
for key, value in pairs(defaults) do for key, value in pairs(defaults) do
settings[key] = value settings[key] = value
end end
for key, value in pairs(conf.mpd) do for key, value in pairs(conf.mpd) do
settings[key] = value settings[key] = value
end end
-- {{{ local helpers -- {{{ local helpers
@ -26,14 +26,22 @@ local function mpc(command)
end end
local function dmenu(opts) local function dmenu(opts)
log.spawn("dmpc -h " .. settings.host .. " -p " .. settings.port .. " " .. log.spawn(
(settings.replace_on_search and "-r" or "-R") .. " " .. opts) "dmpc -h "
.. settings.host
.. " -p "
.. settings.port
.. " "
.. (settings.replace_on_search and "-r" or "-R")
.. " "
.. opts
)
end end
local function notify(stext) local function notify(stext)
if not (naughty == nil) then if not (naughty == nil) then
naughty.notify({ naughty.notification({
text= stext text = stext,
}) })
end end
end end
@ -45,28 +53,27 @@ M.set_server = function(host, port)
notify("Using mpd server " .. settings.host .. ":" .. settings.port) notify("Using mpd server " .. settings.host .. ":" .. settings.port)
end end
-- {{{ mpd.ctrl submodule -- {{{ mpd.ctrl submodule
M.ctrl = {} M.ctrl = {}
M.ctrl.toggle = function () M.ctrl.toggle = function()
mpc("toggle") mpc("toggle")
end end
M.ctrl.play = function () M.ctrl.play = function()
mpc("play") mpc("play")
end end
M.ctrl.pause = function () M.ctrl.pause = function()
mpc("pause") mpc("pause")
end end
M.ctrl.next = function () M.ctrl.next = function()
mpc("next") mpc("next")
end end
M.ctrl.prev = function () M.ctrl.prev = function()
mpc("prev") mpc("prev")
end end
@ -88,7 +95,6 @@ M.prompt.album = function()
dmenu("-A -b") dmenu("-A -b")
end end
M.prompt.title = function() M.prompt.title = function()
dmenu("-A -b -t") dmenu("-A -b -t")
end end
@ -103,14 +109,11 @@ end
M.prompt.toggle_replace_on_search = function() M.prompt.toggle_replace_on_search = function()
settings.replace_on_search = not settings.replace_on_search settings.replace_on_search = not settings.replace_on_search
notify("MPD prompts now " ..( notify("MPD prompts now " .. (settings.replace_on_search and "replace" or "add to") .. " the playlist")
settings.replace_on_search and "replace" or "add to"
).. " the playlist")
end end
-- }}} -- }}}
return M return M
-- vim: set fenc=utf-8 tw=80 foldmethod=marker : -- vim: set fenc=utf-8 tw=80 foldmethod=marker :

View file

@ -1,5 +1,6 @@
-- key bindings -- key bindings
local awful = require("awful") local awful = require("awful")
local gears = require("gears")
local conf = require("localconf") local conf = require("localconf")
local actions = require("actions") local actions = require("actions")
@ -23,7 +24,7 @@ lockhl:setup(wibars, "#F2C740", require("beautiful").bg_normal, { Caps = false }
local function mpdserver(host) local function mpdserver(host)
return function() return function()
mpd.set_server(host, "6600") mpd.set_server(host, "6600")
awful.util.spawn("mpd-host set " .. host .. " 6600") awful.spawn("mpd-host set " .. host .. " 6600")
end end
end end
@ -124,7 +125,7 @@ local notifymap = {
{ "m", binder.spawn("newmails -p"), "Show unread mails" }, { "m", binder.spawn("newmails -p"), "Show unread mails" },
} }
local myglobalkeys = awful.util.table.join( local myglobalkeys = gears.table.join(
awful.key({}, "Pause", binder.spawn("rofi -show window")), awful.key({}, "Pause", binder.spawn("rofi -show window")),
awful.key({ modkey }, "w", binder.spawn("rofi -show window")), awful.key({ modkey }, "w", binder.spawn("rofi -show window")),
awful.key({}, "Print", binder.spawn("flameshot gui")), awful.key({}, "Print", binder.spawn("flameshot gui")),

13
rc.lua
View file

@ -1,10 +1,11 @@
-- If LuaRocks is installed, make sure that packages installed through it are -- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing. -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader") --pcall(require, "luarocks.loader")
-- libraries {{{ -- libraries {{{
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local gears = require("gears") local gears = require("gears")
beautiful.init(gears.filesystem.get_dir("config") .. "/theme.lua")
---@diagnostic disable-next-line: unused-local ---@diagnostic disable-next-line: unused-local
--- for debugging --- for debugging
local inspect = require("inspect") local inspect = require("inspect")
@ -13,10 +14,10 @@ require("awful.autofocus")
require("util.errors") require("util.errors")
-- }}} -- }}}
beautiful.init(awful.util.getdir("config") .. "/theme.lua")
require("tapestry") require("tapestry")
awful.input.xkb_layout = "us_de"
-- {{{ Logging -- {{{ Logging
local log = require("talkative") local log = require("talkative")
log.add_logger(log.loggers.stdio, log.level.DEBUG) log.add_logger(log.loggers.stdio, log.level.DEBUG)
@ -76,12 +77,12 @@ binder.modal.set_opacity(0.8)
binder.add_default_bindings() binder.add_default_bindings()
binder.add_reloadable(tags.create_bindings) binder.add_reloadable(tags.create_bindings)
local mybindings = awful.util.getdir("config") .. "/mybindings.lua" local mybindings = gears.filesystem.get_dir("config") .. "/mybindings.lua"
binder.add_reloadable(function() binder.add_reloadable(function()
return dofile(mybindings) return dofile(mybindings)
end) end)
binder.add_bindings(awful.util.table.join( binder.add_bindings(gears.table.join(
awful.key({}, "XF86AudioRaiseVolume", function() awful.key({}, "XF86AudioRaiseVolume", function()
speakerwheel:up() speakerwheel:up()
end), end),
@ -109,7 +110,7 @@ binder.apply()
require("rules") require("rules")
require("signals") require("signals")
local autorun_file = awful.util.getdir("config") .. "/autorun" local autorun_file = gears.filesystem.get_dir("config") .. "/autorun"
if gears.filesystem.file_readable(autorun_file) then if gears.filesystem.file_readable(autorun_file) then
awful.spawn(autorun_file) awful.spawn(autorun_file)
end end

View file

@ -1,8 +1,8 @@
local awful = require("awful")
awful.rules = require("awful.rules")
local localconf = require("localconf")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local awful = require("awful")
local localconf = require("localconf")
local ruled = require("ruled")
local naughty = require("naughty") local naughty = require("naughty")
local binder = require("separable.binder") local binder = require("separable.binder")
local log = require("talkative") local log = require("talkative")
@ -11,7 +11,7 @@ local log = require("talkative")
local function popup_urgent(client, message) local function popup_urgent(client, message)
client:connect_signal("property::urgent", function(c) client:connect_signal("property::urgent", function(c)
if c.urgent and not c.focus then if c.urgent and not c.focus then
naughty.notify({ text = message }) naughty.notification({ text = message })
end end
end) end)
end end
@ -19,12 +19,12 @@ end
local function keyboard_layer(num) local function keyboard_layer(num)
return function(client) return function(client)
client:connect_signal("focus", function(c) client:connect_signal("focus", function(c)
awful.util.spawn("kontroll-launch set-layer --index " .. num) awful.spawn("kontroll-launch set-layer --index " .. num)
naughty.notify({ text = "kontroll: switching to layer " .. num }) naughty.notification({ text = "kontroll: switching to layer " .. num })
end) end)
client:connect_signal("unfocus", function(c) client:connect_signal("unfocus", function(c)
awful.util.spawn("kontroll-launch set-layer --index 0") awful.spawn("kontroll-launch set-layer --index 0")
naughty.notify({ text = "kontroll: switching to base layer" }) naughty.notification({ text = "kontroll: switching to base layer" })
end) end)
end end
end end
@ -41,7 +41,7 @@ function startswith(str, start)
return str:sub(1, #start) == start return str:sub(1, #start) == start
end end
awful.rules.rules = { ruled.client.append_rules({
-- All clients will match this rule. -- All clients will match this rule.
{ {
rule = {}, rule = {},
@ -158,4 +158,4 @@ awful.rules.rules = {
rule = { class = "zenity" }, rule = { class = "zenity" },
properties = { ontop = true, floating = true, placement = awful.placement.centered }, properties = { ontop = true, floating = true, placement = awful.placement.centered },
}, },
} })

View file

@ -1,5 +1,6 @@
-- key bindings -- key bindings
local awful = require("awful") local awful = require("awful")
local gears = require("gears")
local naughty = require("naughty") local naughty = require("naughty")
local conf = require("localconf") local conf = require("localconf")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
@ -101,12 +102,13 @@ local function screen_in_wrapdir(dir, _screen)
for s = 1, screen.count() do for s = 1, screen.count() do
geomtbl[s] = screen[s].geometry geomtbl[s] = screen[s].geometry
end end
local target = awful.util.get_rectangle_in_direction(dir, geomtbl, screen[sel].geometry) local target = gears.geometry.rectangle.get_in_direction(dir, geomtbl, screen[sel].geometry)
if not target then if not target then
local new_target = sel local new_target = sel
while new_target do while new_target do
target = new_target target = new_target
new_target = awful.util.get_rectangle_in_direction(opposite_dirs[dir], geomtbl, screen[target].geometry) new_target =
gears.geometry.rectangle.get_in_direction(opposite_dirs[dir], geomtbl, screen[target].geometry)
end end
end end
@ -114,22 +116,15 @@ local function screen_in_wrapdir(dir, _screen)
end end
end end
local function screen_focus_wrapdir(dir)
return function()
local target = screen_in_wrapdir(dir)
awful.screen.focus(target)
end
end
local function screen_move_client_wrapdir(dir) local function screen_move_client_wrapdir(dir)
return function(c) return function(c)
local target = screen_in_wrapdir(dir) local target = screen_in_wrapdir(dir)
awful.client.movetoscreen(c, target) c:move_to_screen(target)
end end
end end
function binder.add_bindings(keys) function binder.add_bindings(keys)
globalkeys = awful.util.table.join(globalkeys, keys) globalkeys = gears.table.join(globalkeys, keys)
return binder return binder
end end
@ -144,11 +139,11 @@ function binder.clear()
end end
function binder.apply() function binder.apply()
naughty.notify({ text = "Reloading key bindings" }) naughty.notification({ text = "Reloading key bindings" })
local allkeys = awful.util.table.clone(globalkeys) local allkeys = gears.table.clone(globalkeys)
for _, v in pairs(globalkeyfuncs) do for _, v in pairs(globalkeyfuncs) do
local loadedkeys = v() local loadedkeys = v()
allkeys = awful.util.table.join(allkeys, loadedkeys) allkeys = gears.table.join(allkeys, loadedkeys)
end end
root.keys(allkeys) root.keys(allkeys)
end end
@ -165,7 +160,7 @@ local function client_opacity_set(c, default, max, step)
end end
end end
local clientkeys = awful.util.table.join( local clientkeys = gears.table.join(
awful.key({ modkey, "Shift" }, "f", function(c) awful.key({ modkey, "Shift" }, "f", function(c)
c.fullscreen = not c.fullscreen c.fullscreen = not c.fullscreen
end), end),
@ -176,7 +171,9 @@ local clientkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "Return", function(c) awful.key({ modkey, "Control" }, "Return", function(c)
c:swap(awful.client.getmaster()) c:swap(awful.client.getmaster())
end), end),
awful.key({ modkey }, "o", awful.client.movetoscreen), awful.key({ modkey }, "o", function(c)
c:move_to_screen()
end),
awful.key({ modkey, "Shift" }, "h", screen_move_client_wrapdir("left")), awful.key({ modkey, "Shift" }, "h", screen_move_client_wrapdir("left")),
awful.key({ modkey, "Shift" }, "l", screen_move_client_wrapdir("right")), awful.key({ modkey, "Shift" }, "l", screen_move_client_wrapdir("right")),
awful.key({ modkey, "Control" }, "o", function(c) awful.key({ modkey, "Control" }, "o", function(c)
@ -193,7 +190,7 @@ local clientkeys = awful.util.table.join(
end), end),
awful.key({}, "XF86Calculater", awful.client.movetoscreen), awful.key({}, "XF86Calculater", awful.client.movetoscreen),
awful.key({ modkey }, "i", function(c) awful.key({ modkey }, "i", function(c)
require("naughty").notify({ naughty.notification({
text = string.format( text = string.format(
"name: '%s'\nclass: '%s'\ninstance: '%s'\ntype: '%s'\npid: %d", "name: '%s'\nclass: '%s'\ninstance: '%s'\ntype: '%s'\npid: %d",
c["name"], c["name"],
@ -206,9 +203,9 @@ local clientkeys = awful.util.table.join(
end) end)
) )
root.buttons(awful.util.table.join(awful.button({}, 4, awful.tag.viewnext), awful.button({}, 5, awful.tag.viewprev))) root.buttons(gears.table.join(awful.button({}, 4, awful.tag.viewnext), awful.button({}, 5, awful.tag.viewprev)))
local clientbuttons = awful.util.table.join( local clientbuttons = gears.table.join(
awful.button({}, 1, function(c) awful.button({}, 1, function(c)
if c.name ~= "Onboard" then if c.name ~= "Onboard" then
client.focus = c client.focus = c
@ -230,14 +227,14 @@ function binder.client.keys()
end end
function binder.client.add_buttons(buttons) function binder.client.add_buttons(buttons)
clientbuttons = awful.util.table.join(clientbuttons, buttons) clientbuttons = gears.table.join(clientbuttons, buttons)
end end
function binder.client.add_bindings(keys) function binder.client.add_bindings(keys)
clientkeys = awful.util.table.join(clientkeys, keys) clientkeys = gears.table.join(clientkeys, keys)
end end
local default_bindings = awful.util.table.join( local default_bindings = gears.table.join(
awful.key({ modkey, "Control" }, "r", awesome.restart), awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Shift" }, "q", awesome.quit), awful.key({ modkey, "Shift" }, "q", awesome.quit),
awful.key({ modkey }, "Return", spawnf(conf.cmd.terminal)), awful.key({ modkey }, "Return", spawnf(conf.cmd.terminal)),

View file

@ -1,43 +1,49 @@
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local ruled = require("ruled")
client.connect_signal("request::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
client.connect_signal("manage", function (c) if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
-- Set the windows at the slave, -- Prevent clients from being unreachable after screen count changes.
-- i.e. put it at the end of others instead of setting it master. awful.placement.no_offscreen(c)
-- if not awesome.startup then awful.client.setslave(c) end 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) end)
local fixed_clients = { local fixed_clients = {
-- action search and similar windows in IDEA -- action search and similar windows in IDEA
{ rule = { name = "", class = "jetbrains-idea", type = "dialog" } }, { rule = { name = "", class = "jetbrains-idea", type = "dialog" } },
-- password inputs -- password inputs
{ rule = { class = "Pinentry-gtk-2" } }, { rule = { class = "Pinentry-gtk-2" } },
{ rule = { class = "pinentry-qt" } }, { rule = { class = "pinentry-qt" } },
-- nextcloud closes on focus loss -- nextcloud closes on focus loss
{ rule = { class = "Nextcloud" } }, { rule = { class = "Nextcloud" } },
} }
local function may_lose_focus(c) local function may_lose_focus(c)
if c == nil then return true end if c == nil then
return not awful.rules.matches_list(c, fixed_clients) return true
end
return not ruled.client.matches_list(c, fixed_clients)
end end
-- Enable sloppy focus, so that focus follows mouse. -- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c) client.connect_signal("mouse::enter", function(c)
if may_lose_focus(client.focus) if
and awful.layout.get(c.screen) ~= awful.layout.suit.magnifier may_lose_focus(client.focus)
and awful.client.focus.filter(c) then and awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
client.focus = c and awful.client.focus.filter(c)
end then
client.focus = c
end
end) end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("focus", function(c)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) c.border_color = beautiful.border_focus
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
end)

View file

@ -1,11 +1,12 @@
-- tags -- tags
local awful = require("awful") local awful = require("awful")
local gears = require("gears")
local conf = require("localconf") local conf = require("localconf")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
local tags={} local tags = {}
awful.layout.layouts = { awful.layout.append_default_layouts({
awful.layout.suit.fair, awful.layout.suit.fair,
awful.layout.suit.fair.horizontal, awful.layout.suit.fair.horizontal,
awful.layout.suit.tile, awful.layout.suit.tile,
@ -13,16 +14,10 @@ awful.layout.layouts = {
awful.layout.suit.max, awful.layout.suit.max,
awful.layout.suit.max.fullscreen, awful.layout.suit.max.fullscreen,
awful.layout.suit.floating, awful.layout.suit.floating,
-- 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 getfunc_viewonly(i) local function getfunc_viewonly(i)
return function () return function()
local screen = awful.screen.focused() local screen = awful.screen.focused()
local tag = screen.tags[i] local tag = screen.tags[i]
if tag then if tag then
@ -32,7 +27,7 @@ local function getfunc_viewonly(i)
end end
local function getfunc_viewtoggle(i) local function getfunc_viewtoggle(i)
return function () return function()
local screen = awful.screen.focused() local screen = awful.screen.focused()
local tag = screen.tags[i] local tag = screen.tags[i]
if tag then if tag then
@ -42,7 +37,7 @@ local function getfunc_viewtoggle(i)
end end
local function getfunc_moveto(i) local function getfunc_moveto(i)
return function () return function()
if client.focus then if client.focus then
local tag = client.focus.screen.tags[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
@ -53,7 +48,7 @@ local function getfunc_moveto(i)
end end
local function getfunc_clienttoggle(i) local function getfunc_clienttoggle(i)
return function () return function()
if client.focus then if client.focus then
local tag = client.focus.screen.tags[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
@ -64,20 +59,20 @@ local function getfunc_clienttoggle(i)
end end
local tagdef = { local tagdef = {
{"1"}, { "1" },
{"2", { layout = awful.layout.suit.max }}, { "2", { layout = awful.layout.suit.max } },
{"3"}, { "3" },
{"4", { layout = awful.layout.suit.max }}, { "4", { layout = awful.layout.suit.max } },
{"5"}, { "5" },
{"6"}, { "6" },
{"7"}, { "7" },
{"8"}, { "8" },
{"9"}, { "9" },
{"0"}, { "0" },
{"F1", { layout = awful.layout.suit.max }}, { "F1", { layout = awful.layout.suit.max } },
{"F2"}, { "F2" },
{"F3"}, { "F3" },
{"F4", { layout = awful.layout.suit.max }}, { "F4", { layout = awful.layout.suit.max } },
} }
local function defaultlayout(s) local function defaultlayout(s)
@ -90,11 +85,8 @@ end
function tags.setup() function tags.setup()
awful.screen.connect_for_each_screen(function(s) awful.screen.connect_for_each_screen(function(s)
for _,t in ipairs(tagdef) do for _, t in ipairs(tagdef) do
awful.tag.add(t[1], awful.util.table.join( awful.tag.add(t[1], gears.table.join({ screen = s }, t[2] or { layout = defaultlayout(s) }))
{screen = s},
t[2] or { layout = defaultlayout(s) }
))
end end
s.tags[1]:view_only() s.tags[1]:view_only()
end) end)
@ -113,22 +105,24 @@ function tags.create_bindings()
else --if i > 10 then else --if i > 10 then
k = "F" .. i - 10 -- F keys k = "F" .. i - 10 -- F keys
end end
tagkeys = awful.util.table.join(tagkeys, tagkeys = gears.table.join(
awful.key( { modkey }, k, getfunc_viewonly(i)), tagkeys,
awful.key( { modkey, "Control" }, k, getfunc_viewtoggle(i)), awful.key({ modkey }, k, getfunc_viewonly(i)),
awful.key( { modkey, "Shift" }, k, getfunc_moveto(i)), awful.key({ modkey, "Control" }, k, getfunc_viewtoggle(i)),
awful.key( { modkey, "Control", "Shift" }, k, getfunc_clienttoggle(i)) awful.key({ modkey, "Shift" }, k, getfunc_moveto(i)),
awful.key({ modkey, "Control", "Shift" }, k, getfunc_clienttoggle(i))
) )
end end
-- keys for all tags -- keys for all tags
tagkeys = awful.util.table.join(tagkeys, tagkeys = gears.table.join(
awful.key({ modkey }, "u", awful.client.urgent.jumpto), tagkeys,
awful.key({ modkey }, "Left", awful.tag.viewprev ), awful.key({ modkey }, "u", awful.client.urgent.jumpto),
awful.key({ modkey }, "Right", awful.tag.viewnext ), awful.key({ modkey }, "Left", awful.tag.viewprev),
awful.key({ modkey }, "Escape", awful.tag.history.restore) awful.key({ modkey }, "Right", awful.tag.viewnext),
awful.key({ modkey }, "Escape", awful.tag.history.restore)
) )
return tagkeys; return tagkeys
end end
return tags return tags

@ -1 +1 @@
Subproject commit 95b709fa483363c894c22e5bf0e3060915e49411 Subproject commit ca93752bef7cd662f9a102d3aa05c7b1c6adb4b5

@ -1 +1 @@
Subproject commit 5bb7a7d0510ea1adecf1a175444cdbcca13b7e71 Subproject commit fdf23d8580ea94cad21a2221b41931c4289bb74f

View file

@ -5,23 +5,29 @@ local naughty = require("naughty")
-- Check if awesome encountered an error during startup and fell back to -- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config) -- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical, naughty.notification({
title = "Oops, there were errors during startup!", preset = naughty.config.presets.critical,
text = awesome.startup_errors }) title = "Oops, there were errors during startup!",
text = awesome.startup_errors,
})
end end
-- Handle runtime errors after startup -- Handle runtime errors after startup
do do
local in_error = false local in_error = false
awesome.connect_signal("debug::error", function (err) awesome.connect_signal("debug::error", function(err)
-- Make sure we don't go into an endless error loop -- Make sure we don't go into an endless error loop
if in_error then return end if in_error then
in_error = true return
end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical, naughty.notification({
title = "Oops, an error happened!", preset = naughty.config.presets.critical,
text = err }) title = "Oops, an error happened!",
in_error = false text = err,
end) })
in_error = false
end)
end end
-- }}} -- }}}

View file

@ -10,23 +10,23 @@ local gears = require("gears")
local wlist = {} local wlist = {}
local mytaglist = {} local mytaglist = {}
mytaglist.buttons = awful.util.table.join( mytaglist.buttons = gears.table.join(
awful.button({ }, 1, awful.tag.viewonly), awful.button({}, 1, awful.tag.viewonly),
awful.button({ modkey }, 1, awful.client.movetotag), awful.button({ modkey }, 1, awful.client.movetotag),
awful.button({ }, 3, awful.tag.viewtoggle), awful.button({}, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag), awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end), awful.button({}, 4, function(t)
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end) awful.tag.viewnext(t.screen)
end),
awful.button({}, 5, function(t)
awful.tag.viewprev(t.screen)
end)
) )
local function percentage_overlay(p, color, prefix, suffix) local function percentage_overlay(p, color, prefix, suffix)
return ( return ('<span color="%s">%s%d%%%s</span>'):format(color, prefix or "", p, suffix or "")
'<span color="%s">%s%d%%%s</span>'
):format(color, prefix or "", p, suffix or "")
end end
local function add_bar(s, position, direction, first, second) local function add_bar(s, position, direction, first, second)
local newbar = awful.wibar({ local newbar = awful.wibar({
position = position, position = position,
@ -35,29 +35,33 @@ local function add_bar(s, position, direction, first, second)
width = math.floor(s.dpi / 5), width = math.floor(s.dpi / 5),
}) })
newbar:setup { newbar:setup({
{ {
first, first,
nil, nil,
second, second,
layout = wibox.layout.align.horizontal layout = wibox.layout.align.horizontal,
}, },
direction = direction, direction = direction,
widget = wibox.container.rotate widget = wibox.container.rotate,
} })
return newbar return newbar
end end
function widgets.setup(s) function widgets.setup(s)
return { return {
left = function(bottom, top) s.leftwibar = add_bar(s, "left", "east", bottom, top) end, left = function(bottom, top)
right = function(top, bottom) s.rightwibar = add_bar(s, "right", "west", top, bottom) end s.leftwibar = add_bar(s, "left", "east", bottom, top)
end,
right = function(top, bottom)
s.rightwibar = add_bar(s, "right", "west", top, bottom)
end,
} }
end end
function widgets.mail(mailboxes, notify_pos, title) function widgets.mail(mailboxes, notify_pos, title)
local widget = wibox.widget.textbox() local widget = wibox.widget.textbox()
local bg = wibox.widget { widget, widget = wibox.container.background } local bg = wibox.widget({ widget, widget = wibox.container.background })
local callback = function(widget, args) local callback = function(widget, args)
if args[1] > 0 then if args[1] > 0 then
@ -71,7 +75,7 @@ function widgets.mail(mailboxes, notify_pos, title)
else else
bg.visible = false bg.visible = false
end end
return "⬓⬓ Unread "..args[2].." / New "..args[1].. " " return "⬓⬓ Unread " .. args[2] .. " / New " .. args[1] .. " "
end end
vicious.register(widget, vicious.widgets.mdir, callback, 60, mailboxes) vicious.register(widget, vicious.widgets.mdir, callback, 60, mailboxes)
table.insert(wlist, widget) table.insert(wlist, widget)
@ -81,23 +85,29 @@ end
function widgets.layout(s) function widgets.layout(s)
local mylayoutbox = awful.widget.layoutbox(s) local mylayoutbox = awful.widget.layoutbox(s)
mylayoutbox:buttons(awful.util.table.join( mylayoutbox:buttons(gears.table.join(
awful.button({ }, 1, function () awful.layout.inc( 1) end), awful.button({}, 1, function()
awful.button({ }, 3, function () awful.layout.inc(-1) end), awful.layout.inc(1)
awful.button({ }, 4, function () awful.layout.inc( 1) end), end),
awful.button({ }, 5, 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)
)) ))
return mylayoutbox return mylayoutbox
end end
function widgets.screennum(s) function widgets.screennum(s)
return wibox.widget.textbox("Screen " .. s.index) return wibox.widget.textbox("Screen " .. s.index)
end end
function widgets.taglist(s) function widgets.taglist(s)
return awful.widget.taglist( return awful.widget.taglist(s, awful.widget.taglist.filter.noempty, mytaglist.buttons)
s, awful.widget.taglist.filter.noempty, mytaglist.buttons
)
end end
function widgets.systray(s) function widgets.systray(s)
@ -109,18 +119,19 @@ function widgets.systray(s)
end end
local function graph_label(graph, label, rotation, fontsize) local function graph_label(graph, label, rotation, fontsize)
return wibox.widget { return wibox.widget({
{ {
{ {
text = label, text = label,
font = beautiful.fontface and (beautiful.fontface .. " " .. (fontsize or 7)) or beautiful.font, font = beautiful.fontface and (beautiful.fontface .. " " .. (fontsize or 7)) or beautiful.font,
widget = wibox.widget.textbox widget = wibox.widget.textbox,
}, },
direction = rotation or 'east', widget = wibox.container.rotate direction = rotation or "east",
widget = wibox.container.rotate,
}, },
graph, graph,
layout = wibox.layout.fixed.horizontal layout = wibox.layout.fixed.horizontal,
} })
end end
function widgets.cpu(s) function widgets.cpu(s)
@ -133,16 +144,16 @@ function widgets.ram(s)
end end
function widgets.graph(s, label, viciouswidget, viciousformat, interval) function widgets.graph(s, label, viciouswidget, viciousformat, interval)
local graph = wibox.widget { local graph = wibox.widget({
width = 60, width = 60,
background_color = beautiful.bg_focus, background_color = beautiful.bg_focus,
color = "linear:0,0:0,20:0,#FF0000:0.3,#FFFF00:0.6," .. beautiful.fg_normal, color = "linear:0,0:0,20:0,#FF0000:0.3,#FFFF00:0.6," .. beautiful.fg_normal,
widget = wibox.widget.graph, widget = wibox.widget.graph,
} })
local overlay = wibox.widget { local overlay = wibox.widget({
align = 'center', align = "center",
widget = wibox.widget.textbox widget = wibox.widget.textbox,
} })
local callback = function(widget, args) local callback = function(widget, args)
overlay.markup = percentage_overlay(args[1], beautiful.bg_normal) overlay.markup = percentage_overlay(args[1], beautiful.bg_normal)
return args[1] return args[1]
@ -153,39 +164,34 @@ function widgets.graph(s, label, viciouswidget, viciousformat, interval)
return { return {
layout = awful.widget.only_on_screen, layout = awful.widget.only_on_screen,
screen = s and s.index or "primary", screen = s and s.index or "primary",
graph_label( graph_label({
{ graph,
graph, overlay,
overlay, layout = wibox.layout.stack,
layout = wibox.layout.stack }, label, nil, 7),
},
label,
nil,
7
)
} }
end end
local function bar_with_overlay(fg, bg, width, height) local function bar_with_overlay(fg, bg, width, height)
local progress = wibox.widget { local progress = wibox.widget({
max_value = 1, max_value = 1,
color = fg, color = fg,
background_color = bg, background_color = bg,
forced_width = width, forced_width = width,
forced_height = height, forced_height = height,
widget = wibox.widget.progressbar, widget = wibox.widget.progressbar,
} })
progress.overlay = wibox.widget { progress.overlay = wibox.widget({
font = beautiful.fontface and (beautiful.fontface .. " " .. 7) or beautiful.font, font = beautiful.fontface and (beautiful.fontface .. " " .. 7) or beautiful.font,
align = 'center', align = "center",
widget = wibox.widget.textbox widget = wibox.widget.textbox,
} })
return { return {
progress, progress,
progress.overlay, progress.overlay,
layout = wibox.layout.stack layout = wibox.layout.stack,
} }
end end
@ -193,12 +199,9 @@ end
function widgets.battery(s) function widgets.battery(s)
local bat1 = bar_with_overlay(beautiful.fg_focus, beautiful.bg_focus, 100, math.floor(s.dpi / 10)) local bat1 = bar_with_overlay(beautiful.fg_focus, beautiful.bg_focus, 100, math.floor(s.dpi / 10))
local combined_bats = graph_label( local combined_bats = graph_label(bat1, "BAT")
bat1,
"BAT"
)
local callback = function (widget, args) local callback = function(widget, args)
if args[2] == 0 then if args[2] == 0 then
combined_bats:set_visible(false) combined_bats:set_visible(false)
return "" return ""
@ -209,9 +212,7 @@ function widgets.battery(s)
else else
widget.background_color = beautiful.bg_focus widget.background_color = beautiful.bg_focus
end end
widget.overlay.markup = percentage_overlay( widget.overlay.markup = percentage_overlay(args[2], beautiful.bg_normal, args[1] .. " ")
args[2], beautiful.bg_normal, args[1] .. " "
)
return args[2] return args[2]
end end
end end
@ -223,26 +224,33 @@ function widgets.battery(s)
end end
local tasklist_buttons = gears.table.join( local tasklist_buttons = gears.table.join(
awful.button({ }, 1, function(c) awful.button({}, 1, function(c)
if c == client.focus then if c == client.focus then
c.minimized = true c.minimized = true
else else
c:emit_signal("request::activate", "tasklist", {raise = true}) c:emit_signal("request::activate", "tasklist", { raise = true })
end end
end), end),
awful.button({ }, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end), awful.button({}, 3, function()
awful.button({ }, 4, function() awful.client.focus.byidx(1) end), awful.menu.client_list({ theme = { width = 250 } })
awful.button({ }, 5, function() awful.client.focus.byidx(-1) end)) end),
awful.button({}, 4, function()
awful.client.focus.byidx(1)
end),
awful.button({}, 5, function()
awful.client.focus.byidx(-1)
end)
)
-- display a taskbar -- display a taskbar
-- `when` is a function taking the current screen, that is called on the given signal, and should return true if the -- `when` is a function taking the current screen, that is called on the given signal, and should return true if the
-- taskbar should be shown. -- taskbar should be shown.
-- If signal and when are not given, the taskbar will be visible on tags with "max" layout -- If signal and when are not given, the taskbar will be visible on tags with "max" layout
function widgets.dynamic_taskbar(s, signal, when) function widgets.dynamic_taskbar(s, signal, when)
s.mytasklist = awful.widget.tasklist { s.mytasklist = awful.widget.tasklist({
screen = s, screen = s,
filter = awful.widget.tasklist.filter.currenttags, filter = awful.widget.tasklist.filter.currenttags,
style = { style = {
shape_border_width = 2, shape_border_width = 2,
bg_focus = beautiful.bg_focus, bg_focus = beautiful.bg_focus,
shape_border_color = beautiful.border_focus, shape_border_color = beautiful.border_focus,
@ -253,32 +261,32 @@ function widgets.dynamic_taskbar(s, signal, when)
{ {
{ {
{ {
{ id = 'icon_role', { id = "icon_role", widget = wibox.widget.imagebox },
widget = wibox.widget.imagebox, },
margins = 2, margins = 2,
widget = wibox.container.margin, widget = wibox.container.margin,
}, },
{ id = 'text_role', { id = "text_role", widget = wibox.widget.textbox },
widget = wibox.widget.textbox, },
layout = wibox.layout.fixed.horizontal, layout = wibox.layout.fixed.horizontal,
}, },
left = 20, left = 20,
right = 15, right = 15,
widget = wibox.container.margin widget = wibox.container.margin,
}, },
id = 'background_role', id = "background_role",
widget = wibox.container.background, widget = wibox.container.background,
}, },
} })
s.taskbar = awful.wibar({ s.taskbar = awful.wibar({
position = "top", position = "top",
screen = s, screen = s,
opacity = 0.8, opacity = 0.8,
height = math.floor(s.dpi / 4), height = math.floor(s.dpi / 4),
widget = s.mytasklist widget = s.mytasklist,
}) })
local condition = when or function(s) return awful.layout.get(s).name == "max" end local condition = when or function(s)
return awful.layout.get(s).name == "max"
end
s:connect_signal(signal or "tag::history::update", function() s:connect_signal(signal or "tag::history::update", function()
s.taskbar.visible = condition(s) s.taskbar.visible = condition(s)
end) end)
@ -290,4 +298,8 @@ function widgets.update(name)
vicious.force(wlist) vicious.force(wlist)
end end
return setmetatable(widgets, { __call = function(_, ...) return widgets.setup(...) end }) return setmetatable(widgets, {
__call = function(_, ...)
return widgets.setup(...)
end,
})