forked from Kuroneer/awm_config
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_systray.lua
More file actions
45 lines (40 loc) · 1.28 KB
/
Copy pathmove_systray.lua
File metadata and controls
45 lines (40 loc) · 1.28 KB
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
--[[
Snippet (and module) for AwesomeWM 4 that sets the systray in
the preferred primary screen (higher resolution or bigger)
Author: Jose Maria Perez Ramos <jose.m.perez.ramos+git gmail>
Date: 2018.06.05
Version: 1.0.0
This micro code snippet is public-domain
]]
local wibox = require("wibox")
local callback = nil
local function set_systray_screen(best_screen)
if not best_screen then
local max_resolution = 0;
local max_size = 0;
for s in screen do
local resolution = s.geometry.width * s.geometry.height
local _name, values = next(s.outputs)
local size = values.mm_width * values.mm_height
if resolution > max_resolution or (resolution == max_resolution and size > max_size) then
max_resolution = resolution
max_size = size
best_screen = s
end
end
end
local systray = wibox.widget.systray()
systray:set_screen(best_screen)
systray:emit_signal("widget::redraw_needed")
if callback then
callback(best_screen)
end
end
screen.connect_signal("list", set_systray_screen)
set_systray_screen()
return function(c)
if type(c) == "function" then
callback = c
set_systray_screen()
end
end