summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bindings.lua4
-rw-r--r--utils.lua14
2 files changed, 16 insertions, 2 deletions
diff --git a/bindings.lua b/bindings.lua
index 999edd5..8aa9d48 100644
--- a/bindings.lua
+++ b/bindings.lua
@@ -12,8 +12,8 @@ function M.create(workspace)
local globalkeys = gears.table.join(
awful.key({ modkey, "Mod1" }, "Delete", awesome.restart),
- awful.key({ modkey }, "Pause", function () awful.spawn("xscreensaver-command -lock") end),
- awful.key({ modkey }, "XF86ScreenSaver", function () awful.spawn("xscreensaver-command -lock") end),
+ awful.key({ modkey }, "Pause", utils.screen_lock),
+ awful.key({ modkey }, "XF86ScreenSaver", utils.screen_lock),
-- something of a hack: diziet is configured to send F13/XF86Tools on lid close
-- this should trigger a screen lock if HDMI cable is not connected
diff --git a/utils.lua b/utils.lua
index 01bd70f..3a02c24 100644
--- a/utils.lua
+++ b/utils.lua
@@ -1,6 +1,7 @@
local M = {}
local awful = require("awful")
+local naughty = require("naughty")
-- mapping from logical screen indices to indices corresponding to their
-- physical layout
@@ -43,4 +44,17 @@ function M.spawn_current(command)
awful.spawn(command, {tag = mouse.screen.selected_tag})
end
+function M.screen_lock()
+ awful.spawn.easy_async("xscreensaver-command -lock",
+ function(stdout, stderr, exitreason, exitcode)
+ if exitcode ~= 0 then
+ naughty.notify({ preset = naughty.config.presets.critical,
+ title = "Error locking the screen",
+ text = table.concat({stdout, stderr}, "\n") })
+
+ end
+ end)
+
+end
+
return M