From 7fab902da6dec418a456eed497353bd34edb6779 Mon Sep 17 00:00:00 2001 From: crater2150 Date: Wed, 13 Sep 2017 19:30:10 +0200 Subject: [PATCH] Migrate talkative to external repo --- .gitmodules | 3 ++ rc.lua | 2 +- rules.lua | 11 +++--- separable/simplelog.lua | 77 ----------------------------------------- talkative | 1 + 5 files changed, 11 insertions(+), 83 deletions(-) delete mode 100644 separable/simplelog.lua create mode 160000 talkative diff --git a/.gitmodules b/.gitmodules index 1103114..2e27c64 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "tapestry"] path = tapestry url = https://github.com/crater2150/awesome-tapestry.git +[submodule "talkative"] + path = talkative + url = https://github.com/crater2150/awesome-talkative.git diff --git a/rc.lua b/rc.lua index f3f2018..ccc5cf9 100644 --- a/rc.lua +++ b/rc.lua @@ -13,7 +13,7 @@ beautiful.init(awful.util.getdir("config") .. "/theme.lua") require("tapestry") -- {{{ Logging -log = require("separable.simplelog") +log = require("talkative") log.add_logger(log.loggers.stdio, log.level.DEBUG) log.add_logger(log.loggers.naughty, log.level.WARNING) -- }}} diff --git a/rules.lua b/rules.lua index 67738f0..3d5f0c4 100644 --- a/rules.lua +++ b/rules.lua @@ -3,6 +3,7 @@ awful.rules = require("awful.rules") local beautiful = require("beautiful") local binder = binder or require("separable.binder") +local log = require("talkative") -- create a notification when given client becomes urgent local function popup_urgent(client, message) @@ -29,17 +30,17 @@ awful.rules.rules = { screen = awful.screen.preferred, placement = awful.placement.no_overlap+awful.placement.no_offscreen }, - -- print name and class of new windows for debugging purposes + -- log name and class of new windows for debugging purposes callback = function(c) - print("-----------\nnew client\n") + log("-----------\nnew client\n") if (c["name"] ~= nil) then - print("name: " .. c["name"]) + log("name: " .. c["name"]) end if (c["class"] ~= nil) then - print("class: " .. c["class"]) + log("class: " .. c["class"]) end if (c["type"] ~= nil) then - print("type: " .. c["type"]) + log("type: " .. c["type"]) end end }, diff --git a/separable/simplelog.lua b/separable/simplelog.lua deleted file mode 100644 index 0a96014..0000000 --- a/separable/simplelog.lua +++ /dev/null @@ -1,77 +0,0 @@ -local naughty = require("naughty") -local awful = require("awful") - -local simplelog = { loggers = {}, mt = {}} - -local defaults = {} -local settings = {} - -defaults.loggers = { } -defaults.defaultlevel = 0 - -for key, value in pairs(defaults) do - settings[key] = value -end - -simplelog.level = { - ERROR = 3, - WARNING = 2, - NORMAL = 1, - DEBUG = 0 -} - -local function loglv(msg, level) - for _,logger in ipairs(settings.loggers) do - logger(msg, level) - end -end - -function simplelog.dbg(msg) - loglv(msg, 0) -end - -function simplelog.log(msg) - loglv(msg, 1) -end - -function simplelog.warn(msg) - loglv(msg, 2) -end - -function simplelog.error(msg) - loglv(msg, 3) -end - -function simplelog.add_logger(logger, level) - if level == nil then - level = settings.defaultlevel - end - table.insert(settings.loggers, function(msg, severity) - if severity >= level then - logger(msg, severity) - end - end) -end - -function simplelog.loggers.naughty(msg, severity) - if severity == simplelog.level.WARNING then - msg = "".. msg .. "" - elseif severity == simplelog.level.ERROR then - msg = "".. msg .. "" - end - naughty.notify({ text = msg }) -end - -function simplelog.spawn(command) - simplelog.dbg("Executing: " .. command) - awful.util.spawn(command) -end - -function simplelog.loggers.stdio(msg, severity) - print(msg) -end - - -simplelog.mt.__call = function(t,message) simplelog.log(message) end - -return setmetatable(simplelog, simplelog.mt) diff --git a/talkative b/talkative new file mode 160000 index 0000000..19f211e --- /dev/null +++ b/talkative @@ -0,0 +1 @@ +Subproject commit 19f211ebec6f34fa921252c0933a9af00a697381