This repository has been archived on 2021-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/home/.config/awesome/utils.lua

22 lines
619 B
Lua
Raw Normal View History

local helpers = require("lain.helpers")
local markup = require("lain.util.markup")
2018-10-28 14:14:27 +01:00
local utils = {}
2019-02-16 17:37:01 +01:00
function utils.home()
return os.getenv("HOME") .. "/"
end
function utils.handle_pid(command, callback)
helpers.async_with_shell(string.format("ps x -o pid=,command=|grep -E '^\\s*[0-9]* %s$'|sed 's/\\s*\\([0-9]*\\) .*/\\1/'", command), callback)
end
function utils.ansi2markup(ansi, colors)
return ansi
:gsub("\x1b%[1m([^\x1b]*)", markup.bold("%1"))
:gsub("\x1b%[7m([^\x1b]*)", markup.color(colors.base1, colors.base02, "%1"))
:gsub("\x1b%[0m([^\x1b]*)", "%1")
end
2018-10-28 14:14:27 +01:00
return utils