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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
-------------------------------------------------
-- Run Shell for Awesome Window Manager
-- More details could be found here:
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/run-shell
-- @author Pavel Makhov
-- @copyright 2018 Pavel Makhov
-- @copyright 2019 Pavel Makhov
-------------------------------------------------
local awful = require("awful")
local gfs = require("gears.filesystem")
local wibox = require("wibox")
local gears = require("gears")
local naughty = require("naughty")
local completion = require("awful.completion")
local run_shell = awful.widget.prompt()
local widget = {}
function widget.new()
local widget_instance = {
_cached_wiboxes = {},
_cmd_pixelate = [[sh -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -vf ]]
.. [[frei0r=pixeliz0r -vframes 1 /tmp/i3lock-%s.png ; echo done']],
_cmd_blur = [[sh -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 ]]
.. [[-filter_complex "boxblur=9" -vframes 1 /tmp/i3lock-%s.png ; echo done']]
}
function widget_instance:_create_wibox()
local w = wibox {
visible = false,
ontop = true,
height = mouse.screen.geometry.height,
width = mouse.screen.geometry.width,
}
w:setup {
{
{
{
{
markup = '<span font="awesomewm-font 14" color="#ffffff">a</span>',
widget = wibox.widget.textbox,
},
id = 'icon',
left = 10,
layout = wibox.container.margin
},
{
run_shell,
left = 10,
layout = wibox.container.margin,
},
id = 'left',
layout = wibox.layout.fixed.horizontal
},
widget = wibox.container.background,
bg = '#333333',
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 3)
end,
shape_border_color = '#74aeab',
shape_border_width = 1,
forced_width = 200,
forced_height = 50
},
layout = wibox.container.place
}
return w
end
function widget_instance:launch()
local s = mouse.screen
if not self._cached_wiboxes[s] then
self._cached_wiboxes[s] = {}
end
if not self._cached_wiboxes[s][1] then
self._cached_wiboxes[s][1] = self:_create_wibox()
end
local w = self._cached_wiboxes[s][1]
local rnd = math.random()
awful.spawn.with_line_callback(
string.format(self._cmd_blur, tostring(awful.screen.focused().geometry.x), rnd), {
stdout = function()
w.visible = true
w.bgimage = '/tmp/i3lock-' .. rnd ..'.png'
awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() })
awful.prompt.run {
prompt = 'Run: ',
bg_cursor = '#74aeab',
textbox = run_shell.widget,
completion_callback = completion.shell,
exe_callback = function(...)
run_shell:spawn_and_handle_error(...)
end,
history_path = gfs.get_cache_dir() .. "/history",
done_callback = function()
w.visible = false
w.bgimage = ''
awful.spawn([[bash -c 'rm -f /tmp/i3lock*']])
end
}
end,
stderr = function(line)
naughty.notify { text = "ERR:" .. line }
end,
})
end
return widget_instance
end
local function get_default_widget()
if not widget.default_widget then
widget.default_widget = widget.new()
end
return widget.default_widget
end
function widget.launch(...)
return get_default_widget():launch(...)
end
return widget
|