This commit is contained in:
Trial97 2022-07-11 19:19:49 +03:00
commit d771aa6dfa
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
10 changed files with 96 additions and 41 deletions

17
.github/workflows/main.yml vendored Normal file
View File

@ -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

27
.luacheckrc Normal file
View File

@ -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"
}

View File

@ -1,6 +1,8 @@
Lain
====
.. image:: https://github.com/lcpz/lain/actions/workflows/main.yml/badge.svg
-------------------------------------------------
Layouts, widgets and utilities for Awesome WM 4.x
-------------------------------------------------

View File

@ -5,15 +5,15 @@
--]]
local spawn = require("awful.spawn")
local timer = require("gears.timer")
local debug = require("debug")
local io = { lines = io.lines,
open = io.open }
local pairs = pairs
local rawget = rawget
local table = { sort = table.sort, unpack = table.unpack }
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
local spawn = require("awful.spawn")
local timer = require("gears.timer")
local debug = require("debug")
local io = { lines = io.lines,
open = io.open }
local pairs = pairs
local rawget = rawget
local tsort = table.sort
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
-- Lain helper functions for internal use
-- lain.helpers
@ -164,7 +164,7 @@ function helpers.spairs(t)
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
table.sort(keys)
tsort(keys)
-- return the iterator function
local i = 0

View File

@ -6,16 +6,12 @@ source = {
}
description = {
summary = "Layout, widgets and utilities for Awesome WM",
detailed = [[
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).
]],
detailed = "Alternative layouts, asynchronous widgets and utility functions for Awesome WM. Non-Lua dependency: curl (for IMAP, MPD and weather widgets).",
homepage = "https://github.com/lcpz/lain",
license = "GPL-2.0"
license = "GPL2"
}
dependencies = {
"lua >= 5.1",
"lua >= 5.3",
"dkjson >= 2.6-1"
}
supported_platforms = { "linux" }

View File

@ -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 = {
name = "centerwork",
@ -138,7 +142,7 @@ local function mouse_resize_handler(c, _, _, _, orientation)
if g.height + 15 >= wa.height then
offset = g.height * .5
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
end
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
offset = g.width * .5
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
end
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 = {}
mousegrabber.run(function(_mouse)
mousegrabber.run(function(m)
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
prev_coords = { x = _mouse.x, y = _mouse.y }
prev_coords = { x = m.x, y = m.y }
local new_mwfact
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
new_mwfact = 1 - (_mouse.y - wa.y) / wa.height * 2
new_mwfact = 1 - (m.y - wa.y) / wa.height * 2
end
c.screen.selected_tag.master_width_factor = math.min(math.max(new_mwfact, 0.01), 0.99)
return true
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
@ -191,11 +195,14 @@ function centerwork.horizontal.mouse_resize_handler(c, corner, x, y)
return mouse_resize_handler(c, corner, x, y, 'horizontal')
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 gears = require("gears")
local client = client
local function compare_position(a, b)
if a.x == b.x then
@ -208,7 +215,10 @@ end
local function clients_by_position()
local this = client.focus
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)
local idx = 0
@ -234,10 +244,9 @@ centerwork.focus = {}
--[[
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)
if in_centerwork() then
local cls = clients_by_position()

View File

@ -42,8 +42,8 @@ SOFTWARE.
--]==]
-- global dependencies:
local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset =
pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset
local pairs, type, tostring, tonumber, getmetatable, setmetatable =
pairs, type, tostring, tonumber, getmetatable, setmetatable
local error, require, pcall, select = error, require, pcall, select
local floor, huge = math.floor, math.huge
local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
@ -64,7 +64,7 @@ if register_global_module_table then
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()
-- Enable access to blocked metatables.
@ -252,7 +252,7 @@ local function exception(reason, value, state, buffer, buflen, defaultmessage)
end
end
function json.encodeexception(reason, value, state, defaultmessage)
function json.encodeexception(_reason, _value, _state, defaultmessage)
return quotestring("<" .. defaultmessage .. ">")
end
@ -327,7 +327,7 @@ encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, s
local v = value[k]
if v ~= nil then
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
end
end
@ -510,7 +510,6 @@ end
local scanvalue -- forward declaration
local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
local len = strlen (str)
local tbl, n = {}, 0
local pos = startpos + 1
if what == 'object' then
@ -640,7 +639,7 @@ function json.use_lpeg ()
local PlainChar = 1 - S"\"\\\n\r"
local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars
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)
if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then
return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000)

View File

@ -8,10 +8,11 @@
local wibox = require("wibox")
local gears = require("gears")
local beautiful = require("beautiful")
-- Lain Cairo separators util submodule
-- lain.util.separators
local separators = { height = 0, width = 9 }
local separators = { height = beautiful.separators_height or 0, width = beautiful.separators_width or 9 }
-- [[ Arrow

View File

@ -32,7 +32,11 @@ local function factory(args)
temp_now[t] = temp_value and temp_value/1e3 or temp_fl
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
settings()
end)

2
wiki

@ -1 +1 @@
Subproject commit 74a423dac2c8ea2f0f6827b209aa6de9b741a3a1
Subproject commit ad8081cb3e3cb336323d1f72d34c7c8304490b14