blob: 3a02c24ce83bd1d036b1beeb0cf36c3e73658bfa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
local M = {}
local awful = require("awful")
local naughty = require("naughty")
-- mapping from logical screen indices to indices corresponding to their
-- physical layout
function M.screen_physical(n)
local function screen_cmp(s1, s2)
return s1.geometry.x < s2.geometry.x
end
local screens = {}
for s in screen do
screens[s.index] = s
end
table.sort(screens, screen_cmp)
if screens[n] ~= nil then
return screens[n]
end
return nil
end
function M.screen_focus_physical(n)
local s = M.screen_physical(n)
if s then
awful.screen.focus(s)
end
end
-- audio control functions
function M.vol_control(n)
local cmd = string.format("amixer -q set Master %d%%", math.abs(n)) .. (n < 0 and "-" or "+")
awful.spawn(cmd)
end
function M.vol_mute_toggle()
awful.spawn("amixer -q set Master toggle")
end
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
|