--- a/awesome/my.lua Sun Jun 14 22:18:07 2015 -0400
+++ b/awesome/my.lua Sat Jun 20 16:21:25 2015 -0400
@@ -1,6 +1,9 @@
+local os = require("os")
+local io = require("io")
+local debug = require("debug")
+local awesome = require("awesome")
local naughty = require("naughty")
local awful = require("awful")
-local debug = require("debug")
local vicious = require("vicious")
local wicked = require("wicked")
local beautiful = require("beautiful")
@@ -11,28 +14,55 @@
local pairs = pairs
local capi = {
- keygrabber = keygrabber,
- client = client,
- string = string,
- widget = widget,
+ keygrabber = require("keygrabber"),
+ client = require("client"),
+ string = require("string"),
}
module("my")
-local function get_gradient_colors(c1, c2, c3)
- return { type = "linear", from = { 0, 0 }, to = { 0, 20 }, stops = { { 0, c1 }, { 0.5, c2 }, { 1, c3 } }}
+--- Stolen from shifty: Shows a popup and logs to a file
+-- @param message The text message.
+-- @param log_level 1 = INFO, 2 = WARN, 3 = ERROR, if nothting is provided 1 is used.
+function log(message, log_level)
+ if log_level == nil then
+ log_level = 1
+ end
+
+ local log_table = {
+ { level = "INFO", bg_colour = "#18F92C", fg_colour = "#0E0E0E" },
+ { level = "WARN", bg_colour = "#9E731F", fg_colour = "#0E0E0E" },
+ { level = "ERROR", bg_colour = "#FF0015", fg_colour = "#000000" }
+ }
+ -- %c eg: Wed Jan 30 14:25:13 2013
+ local time = os.date("%c")
+ message = time .. " - " .. log_table[log_level].level .. " - " .. message .. "\n" .. debug.traceback()
+
+ local home = os.getenv("HOME")
+ local log_file = io.open(home .. "/.awesome.log", "a+")
+ log_file:write(message .."\n")
+ log_file:close()
+
+ naughty.notify({ preset = naughty.config.presets.critical, text = message, bg = log_table[log_level].bg_colour, fg = log_table[log_level].fg_colour})
end
local in_error = false
-function notify_error(err)
- -- Make sure we don't go into an endless error loop
- if in_error then return end
- in_error = true
+function mk_notify_error_dialog(level)
+ return function(msg)
+ -- Make sure we don't go into an endless error loop
+ if in_error then return end
+ in_error = true
- naughty.notify({ preset = naughty.config.presets.critical,
- title = "Oops, an error happened!",
- text = err })
- in_error = false
+ log(msg, level)
+
+ in_error = false
+ end
+end
+
+notify_error = mk_notify_error_dialog(3)
+
+local function get_gradient_colors(c1, c2, c3)
+ return { type = "linear", from = { 0, 0 }, to = { 0, 20 }, stops = { { 0, c1 }, { 0.5, c2 }, { 1, c3 } }}
end
function mkspawn(p)
@@ -55,7 +85,7 @@
end
function quit()
- kill_all(awful.rules.any)
+ kill_all(function (c) return true end)
awesome.quit()
end
@@ -119,9 +149,12 @@
end
local function widgets_mode()
+ local bg = wibox.widget.background()
local w = wibox.widget.textbox()
+ bg:set_widget(w)
widgets.mode_widget = w
- return w
+ widgets.mode_widget_bg = bg
+ return bg
end
local function widgets_keyboard()
@@ -191,7 +224,7 @@
return true
end
local theme = beautiful.get()
- widgets.mode_widget.bg = theme.bg_focus
+ widgets.mode_widget_bg:set_bg(theme.bg_focus)
if key == "Escape" then
return false
end
@@ -206,13 +239,13 @@
end
end
-- notify_error("Nothing for " .. skey)
- widgets.mode_widget.bg = theme.bg_urgent
+ widgets.mode_widget_bg:set_bg(theme.bg_urgent)
return true
end
local function stop_kt()
capi.keygrabber.stop()
- widgets.mode_widget.visible = false
+ widgets.mode_widget:set_text("")
end
function mkinteractive(f)
@@ -225,9 +258,9 @@
-- local is_in_run_kt = false
function run_kt(c, keytable, title)
- widgets.mode_widget.text = "Mode: " .. title
- widgets.mode_widget.visible = true
- widgets.mode_widget.bg = "LightBlue"
+ widgets.mode_widget:set_text("Mode: " .. title)
+ -- widgets.mode_widget:show()
+ widgets.mode_widget_bg:set_bg("LightBlue")
widgets.mode_widget:buttons(
awful.util.table.join(
awful.button({}, 1, function () show_kt(keytable, "Binding") end),
@@ -314,5 +347,9 @@
capi.client.connect_signal("manage", function (c)
c:connect_signal("mouse::enter", sloppy_mouse_enter)
end)
- capi.client.connect_signal("focus", function () sloppy_timer:stop() end)
+ capi.client.connect_signal("focus", function ()
+ if sloppy_timer.started then
+ sloppy_timer:stop()
+ end
+ end)
end
--- a/awesome/rc.lua Sun Jun 14 22:18:07 2015 -0400
+++ b/awesome/rc.lua Sat Jun 20 16:21:25 2015 -0400
@@ -34,6 +34,15 @@
-- Handle runtime errors after startup
do
awesome.connect_signal("debug::error", my.notify_error)
+ awesome.connect_signal("debug::deprecation", my.notify_error)
+ awesome.connect_signal("debug::index::miss",
+ function (obj, key)
+ my.notify_error("Invalid key " .. key .. " on object")
+ end)
+ awesome.connect_signal("debug::newindex::miss",
+ function (obj, key, value)
+ my.notify_error("Trying to set key " .. key .. " on object")
+ end)
end
-- }}}
@@ -362,18 +371,16 @@
left_layout:add(mypromptbox[s])
local right_layout = wibox.layout.fixed.horizontal()
+ if (s == 1) then right_layout:add(mynetwidget) end
+ if (s == 1) then right_layout:add(mysystray) end
+ right_layout:add(mytextclock)
right_layout:add(mylayoutbox[s])
- if (s == 1) then right_layout:add(mynetwidget) end
- right_layout:add(mytextclock)
- if (s == 1) then right_layout:add(mysystray) end
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_middle(mytasklist[s])
layout:set_right(right_layout)
mywibox[s]:set_widget(layout)
-
- mywibox[s].screen = s
end
-- SHIFTY: initialize shifty
@@ -646,7 +653,6 @@
-- Hook function to execute when focusing a client.
client.connect_signal("focus",
function(c)
- -- my.notify_error("Client focus:\n" .. debug.traceback())
if not awful.client.ismarked(c) then
c.border_color = beautiful.border_focus
c.opacity = 1.0