summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-05 16:14:52 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-05 16:14:52 +0100
commitd2fbf3c11fb10c2b76455df2a718a8c8d88bf16d (patch)
treeddac900d5c993625d2d7ecffbb37635f39a64609
parent8a99126930b902171204fd7e1c5871014ebffa33 (diff)
utils: add logging functions
-rw-r--r--bindings.lua1
-rw-r--r--rc.lua4
-rw-r--r--urgent_wgt.lua2
-rw-r--r--utils.lua16
-rw-r--r--workspace.lua2
5 files changed, 20 insertions, 5 deletions
diff --git a/bindings.lua b/bindings.lua
index 8e08aee..6cce4de 100644
--- a/bindings.lua
+++ b/bindings.lua
@@ -18,7 +18,6 @@ function M.create(workspace)
function ()
local s = mouse.screen
for o, _ in pairs(s.outputs) do
- print('toggling ' .. o)
awful.spawn('randr_output_toggle ' .. o)
end
end),
diff --git a/rc.lua b/rc.lua
index 47e6cb2..43d5fe3 100644
--- a/rc.lua
+++ b/rc.lua
@@ -86,9 +86,9 @@ mypromptbox = {}
local wsp = workspace.Workspace:new(layouts)
awful.screen.connect_for_each_screen(function(s)
- print('Setting up screen:')
+ utils.log('screen', 'Setting up screen %d:', s.index)
for k, v in pairs(s.outputs) do
- print(k)
+ utils.log('screen', ' %s', k)
end
local panel_width = beautiful.xresources.apply_dpi(128, s)
diff --git a/urgent_wgt.lua b/urgent_wgt.lua
index cce4675..270d836 100644
--- a/urgent_wgt.lua
+++ b/urgent_wgt.lua
@@ -12,7 +12,7 @@ local function client_get_desk_idx(c)
if desk_idx ~= nil and desk_idx >= 0 then
return desk_idx
else
- print('cannot get desk idx: ' .. c.first_tag.name)
+ utils.warn('UrgentWgt', 'cannot get desk idx: ' .. c.first_tag.name)
end
end
return false
diff --git a/utils.lua b/utils.lua
index eb698dc..0a8d54f 100644
--- a/utils.lua
+++ b/utils.lua
@@ -146,4 +146,20 @@ function M.notify_singleton(wsp, id, args)
wsp.notify_tbl[id] = naughty.notify(args)
end
+function M.log(component, msg, ...)
+ local prefix = string.format('[awesome/%s] ', component)
+ local str = string.format(msg, ...)
+
+ print(prefix .. str)
+
+ return prefix, str
+end
+
+function M.warn(component, msg, ...)
+ local prefix, str = M.log(component, msg, ...)
+ naughty.notify({ preset = naughty.config.presets.critical,
+ title = prefix,
+ text = str })
+end
+
return M
diff --git a/workspace.lua b/workspace.lua
index 9da5e4a..26e2e47 100644
--- a/workspace.lua
+++ b/workspace.lua
@@ -113,7 +113,7 @@ function Workspace:view(screen, desktop_idx, page_idx)
-- take the topmost free one
page_idx = desktop.indices_free:pop()
if page_idx == nil then
- print("No free pages on desktop")
+ utils.warn('Workspace', 'No free pages on desktop %d', desktop_idx)
return
end
else