mirror of https://github.com/lcpz/lain.git
Merge branch 'master' of https://github.com/lcpz/lain
This commit is contained in:
commit
d771aa6dfa
|
@ -0,0 +1,17 @@
|
||||||
|
name: Lain
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linting:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "Running tests triggered by a ${{ github.event_name }} event."
|
||||||
|
- run: echo "Testing ${{ github.ref }} from ${{ github.repository }} on ${{ runner.os }}"
|
||||||
|
- name: Check out code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Run tests
|
||||||
|
uses: lunarmodules/luacheck@v0
|
|
@ -0,0 +1,27 @@
|
||||||
|
-- Only allow symbols available in all Lua versions
|
||||||
|
std = "min"
|
||||||
|
|
||||||
|
allow_defined = true
|
||||||
|
max_line_length = false
|
||||||
|
cache = true
|
||||||
|
|
||||||
|
-- Global objects defined by the C code
|
||||||
|
read_globals = {
|
||||||
|
"awesome",
|
||||||
|
"mousegrabber",
|
||||||
|
"table.unpack",
|
||||||
|
"unpack",
|
||||||
|
"utf8"
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"client",
|
||||||
|
"mouse",
|
||||||
|
"root",
|
||||||
|
"screen"
|
||||||
|
}
|
||||||
|
|
||||||
|
-- https://luacheck.readthedocs.io/en/stable/warnings.html
|
||||||
|
ignore = {
|
||||||
|
"131"
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
Lain
|
Lain
|
||||||
====
|
====
|
||||||
|
|
||||||
|
.. image:: https://github.com/lcpz/lain/actions/workflows/main.yml/badge.svg
|
||||||
|
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
Layouts, widgets and utilities for Awesome WM 4.x
|
Layouts, widgets and utilities for Awesome WM 4.x
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
20
helpers.lua
20
helpers.lua
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local spawn = require("awful.spawn")
|
local spawn = require("awful.spawn")
|
||||||
local timer = require("gears.timer")
|
local timer = require("gears.timer")
|
||||||
local debug = require("debug")
|
local debug = require("debug")
|
||||||
local io = { lines = io.lines,
|
local io = { lines = io.lines,
|
||||||
open = io.open }
|
open = io.open }
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local rawget = rawget
|
local rawget = rawget
|
||||||
local table = { sort = table.sort, unpack = table.unpack }
|
local tsort = table.sort
|
||||||
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
|
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
|
||||||
|
|
||||||
-- Lain helper functions for internal use
|
-- Lain helper functions for internal use
|
||||||
-- lain.helpers
|
-- lain.helpers
|
||||||
|
@ -164,7 +164,7 @@ function helpers.spairs(t)
|
||||||
local keys = {}
|
local keys = {}
|
||||||
for k in pairs(t) do keys[#keys+1] = k end
|
for k in pairs(t) do keys[#keys+1] = k end
|
||||||
|
|
||||||
table.sort(keys)
|
tsort(keys)
|
||||||
|
|
||||||
-- return the iterator function
|
-- return the iterator function
|
||||||
local i = 0
|
local i = 0
|
||||||
|
|
|
@ -6,16 +6,12 @@ source = {
|
||||||
}
|
}
|
||||||
description = {
|
description = {
|
||||||
summary = "Layout, widgets and utilities for Awesome WM",
|
summary = "Layout, widgets and utilities for Awesome WM",
|
||||||
detailed = [[
|
detailed = "Alternative layouts, asynchronous widgets and utility functions for Awesome WM. Non-Lua dependency: curl (for IMAP, MPD and weather widgets).",
|
||||||
Successor of awesome-vain, this module provides alternative layouts, asynchronous widgets and utility functions for Awesome WM.
|
|
||||||
|
|
||||||
Dependencies: curl (for IMAP, MPD and weather widgets); Glib >= 2.54 (for filesystems widget).
|
|
||||||
]],
|
|
||||||
homepage = "https://github.com/lcpz/lain",
|
homepage = "https://github.com/lcpz/lain",
|
||||||
license = "GPL-2.0"
|
license = "GPL2"
|
||||||
}
|
}
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"lua >= 5.1",
|
"lua >= 5.3",
|
||||||
"dkjson >= 2.6-1"
|
"dkjson >= 2.6-1"
|
||||||
}
|
}
|
||||||
supported_platforms = { "linux" }
|
supported_platforms = { "linux" }
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local floor, max, mouse, mousegrabber, screen = math.floor, math.max, mouse, mousegrabber, screen
|
local floor = math.floor
|
||||||
|
local max = math.max
|
||||||
|
local mouse = mouse
|
||||||
|
local mousegrabber = mousegrabber
|
||||||
|
local screen = screen
|
||||||
|
|
||||||
local centerwork = {
|
local centerwork = {
|
||||||
name = "centerwork",
|
name = "centerwork",
|
||||||
|
@ -138,7 +142,7 @@ local function mouse_resize_handler(c, _, _, _, orientation)
|
||||||
if g.height + 15 >= wa.height then
|
if g.height + 15 >= wa.height then
|
||||||
offset = g.height * .5
|
offset = g.height * .5
|
||||||
cursor = "sb_h_double_arrow"
|
cursor = "sb_h_double_arrow"
|
||||||
elseif not (g.y + g.height + 15 > wa.y + wa.height) then
|
elseif g.y + g.height + 15 <= wa.y + wa.height then
|
||||||
offset = g.height
|
offset = g.height
|
||||||
end
|
end
|
||||||
corner_coords = { x = wa.x + wa.width * (1 - mwfact) / 2, y = g.y + offset }
|
corner_coords = { x = wa.x + wa.width * (1 - mwfact) / 2, y = g.y + offset }
|
||||||
|
@ -146,7 +150,7 @@ local function mouse_resize_handler(c, _, _, _, orientation)
|
||||||
if g.width + 15 >= wa.width then
|
if g.width + 15 >= wa.width then
|
||||||
offset = g.width * .5
|
offset = g.width * .5
|
||||||
cursor = "sb_v_double_arrow"
|
cursor = "sb_v_double_arrow"
|
||||||
elseif not (g.x + g.width + 15 > wa.x + wa.width) then
|
elseif g.x + g.width + 15 <= wa.x + wa.width then
|
||||||
offset = g.width
|
offset = g.width
|
||||||
end
|
end
|
||||||
corner_coords = { y = wa.y + wa.height * (1 - mwfact) / 2, x = g.x + offset }
|
corner_coords = { y = wa.y + wa.height * (1 - mwfact) / 2, x = g.x + offset }
|
||||||
|
@ -156,22 +160,22 @@ local function mouse_resize_handler(c, _, _, _, orientation)
|
||||||
|
|
||||||
local prev_coords = {}
|
local prev_coords = {}
|
||||||
|
|
||||||
mousegrabber.run(function(_mouse)
|
mousegrabber.run(function(m)
|
||||||
if not c.valid then return false end
|
if not c.valid then return false end
|
||||||
for _, v in ipairs(_mouse.buttons) do
|
for _, v in ipairs(m.buttons) do
|
||||||
if v then
|
if v then
|
||||||
prev_coords = { x = _mouse.x, y = _mouse.y }
|
prev_coords = { x = m.x, y = m.y }
|
||||||
local new_mwfact
|
local new_mwfact
|
||||||
if orientation == 'vertical' then
|
if orientation == 'vertical' then
|
||||||
new_mwfact = 1 - (_mouse.x - wa.x) / wa.width * 2
|
new_mwfact = 1 - (m.x - wa.x) / wa.width * 2
|
||||||
else
|
else
|
||||||
new_mwfact = 1 - (_mouse.y - wa.y) / wa.height * 2
|
new_mwfact = 1 - (m.y - wa.y) / wa.height * 2
|
||||||
end
|
end
|
||||||
c.screen.selected_tag.master_width_factor = math.min(math.max(new_mwfact, 0.01), 0.99)
|
c.screen.selected_tag.master_width_factor = math.min(math.max(new_mwfact, 0.01), 0.99)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return prev_coords.x == _mouse.x and prev_coords.y == _mouse.y
|
return prev_coords.x == m.x and prev_coords.y == m.y
|
||||||
end, cursor)
|
end, cursor)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,11 +195,14 @@ function centerwork.horizontal.mouse_resize_handler(c, corner, x, y)
|
||||||
return mouse_resize_handler(c, corner, x, y, 'horizontal')
|
return mouse_resize_handler(c, corner, x, y, 'horizontal')
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-- make focus.byidx and swap.byidx behave more consistently with other layouts
|
--[[
|
||||||
|
Make focus.byidx and swap.byidx behave more consistently with other layouts.
|
||||||
|
--]]
|
||||||
|
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
|
local client = client
|
||||||
|
|
||||||
local function compare_position(a, b)
|
local function compare_position(a, b)
|
||||||
if a.x == b.x then
|
if a.x == b.x then
|
||||||
|
@ -208,7 +215,10 @@ end
|
||||||
local function clients_by_position()
|
local function clients_by_position()
|
||||||
local this = client.focus
|
local this = client.focus
|
||||||
if this then
|
if this then
|
||||||
local sorted = client.focus.first_tag:clients()
|
local sorted = {}
|
||||||
|
for _, c in ipairs(client.focus.first_tag:clients()) do
|
||||||
|
if not c.minimized then sorted[#sorted+1] = c end
|
||||||
|
end
|
||||||
table.sort(sorted, compare_position)
|
table.sort(sorted, compare_position)
|
||||||
|
|
||||||
local idx = 0
|
local idx = 0
|
||||||
|
@ -234,10 +244,9 @@ centerwork.focus = {}
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Drop in replacements for awful.client.focus.byidx and awful.client.swap.byidx
|
Drop in replacements for awful.client.focus.byidx and awful.client.swap.byidx
|
||||||
that behaves consistently with other layouts
|
that behaves consistently with other layouts.
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
|
|
||||||
function centerwork.focus.byidx(i)
|
function centerwork.focus.byidx(i)
|
||||||
if in_centerwork() then
|
if in_centerwork() then
|
||||||
local cls = clients_by_position()
|
local cls = clients_by_position()
|
||||||
|
|
|
@ -42,8 +42,8 @@ SOFTWARE.
|
||||||
--]==]
|
--]==]
|
||||||
|
|
||||||
-- global dependencies:
|
-- global dependencies:
|
||||||
local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset =
|
local pairs, type, tostring, tonumber, getmetatable, setmetatable =
|
||||||
pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset
|
pairs, type, tostring, tonumber, getmetatable, setmetatable
|
||||||
local error, require, pcall, select = error, require, pcall, select
|
local error, require, pcall, select = error, require, pcall, select
|
||||||
local floor, huge = math.floor, math.huge
|
local floor, huge = math.floor, math.huge
|
||||||
local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
|
local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
|
||||||
|
@ -64,7 +64,7 @@ if register_global_module_table then
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local _ENV = nil -- blocking globals in Lua 5.2 and later
|
_ENV = nil -- blocking globals in Lua 5.2 and later
|
||||||
|
|
||||||
pcall (function()
|
pcall (function()
|
||||||
-- Enable access to blocked metatables.
|
-- Enable access to blocked metatables.
|
||||||
|
@ -252,7 +252,7 @@ local function exception(reason, value, state, buffer, buflen, defaultmessage)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function json.encodeexception(reason, value, state, defaultmessage)
|
function json.encodeexception(_reason, _value, _state, defaultmessage)
|
||||||
return quotestring("<" .. defaultmessage .. ">")
|
return quotestring("<" .. defaultmessage .. ">")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, s
|
||||||
local v = value[k]
|
local v = value[k]
|
||||||
if v ~= nil then
|
if v ~= nil then
|
||||||
used[k] = true
|
used[k] = true
|
||||||
buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
|
buflen, _msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state)
|
||||||
prev = true -- add a seperator before the next element
|
prev = true -- add a seperator before the next element
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -510,7 +510,6 @@ end
|
||||||
local scanvalue -- forward declaration
|
local scanvalue -- forward declaration
|
||||||
|
|
||||||
local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
|
local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
|
||||||
local len = strlen (str)
|
|
||||||
local tbl, n = {}, 0
|
local tbl, n = {}, 0
|
||||||
local pos = startpos + 1
|
local pos = startpos + 1
|
||||||
if what == 'object' then
|
if what == 'object' then
|
||||||
|
@ -640,7 +639,7 @@ function json.use_lpeg ()
|
||||||
local PlainChar = 1 - S"\"\\\n\r"
|
local PlainChar = 1 - S"\"\\\n\r"
|
||||||
local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
|
local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
|
||||||
local HexDigit = R("09", "af", "AF")
|
local HexDigit = R("09", "af", "AF")
|
||||||
local function UTF16Surrogate (match, pos, high, low)
|
local function UTF16Surrogate (_match, _pos, high, low)
|
||||||
high, low = tonumber (high, 16), tonumber (low, 16)
|
high, low = tonumber (high, 16), tonumber (low, 16)
|
||||||
if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
|
if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
|
||||||
return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)
|
return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)
|
||||||
|
|
|
@ -8,10 +8,11 @@
|
||||||
|
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
local gears = require("gears")
|
local gears = require("gears")
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
|
||||||
-- Lain Cairo separators util submodule
|
-- Lain Cairo separators util submodule
|
||||||
-- lain.util.separators
|
-- lain.util.separators
|
||||||
local separators = { height = 0, width = 9 }
|
local separators = { height = beautiful.separators_height or 0, width = beautiful.separators_width or 9 }
|
||||||
|
|
||||||
-- [[ Arrow
|
-- [[ Arrow
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,11 @@ local function factory(args)
|
||||||
temp_now[t] = temp_value and temp_value/1e3 or temp_fl
|
temp_now[t] = temp_value and temp_value/1e3 or temp_fl
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
coretemp_now = string.format(format, temp_now[tempfile]) or "N/A"
|
if temp_now[tempfile] then
|
||||||
|
coretemp_now = string.format(format, temp_now[tempfile])
|
||||||
|
else
|
||||||
|
coretemp_now = "N/A"
|
||||||
|
end
|
||||||
widget = temp.widget
|
widget = temp.widget
|
||||||
settings()
|
settings()
|
||||||
end)
|
end)
|
||||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit 74a423dac2c8ea2f0f6827b209aa6de9b741a3a1
|
Subproject commit ad8081cb3e3cb336323d1f72d34c7c8304490b14
|
Loading…
Reference in New Issue