More cleanup
This commit is contained in:
4
modules/simple_widgets/init.lua
Normal file
4
modules/simple_widgets/init.lua
Normal file
@ -0,0 +1,4 @@
|
||||
return {
|
||||
textclock = require("modules.simple_widgets.textclock").widget,
|
||||
make_shortcut = require("modules.simple_widgets.shortcut")
|
||||
}
|
49
modules/simple_widgets/shortcut.lua
Normal file
49
modules/simple_widgets/shortcut.lua
Normal file
@ -0,0 +1,49 @@
|
||||
local function make_shortcut(command, icon)
|
||||
local widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{
|
||||
wibox.widget {
|
||||
resize = true,
|
||||
image = conf.app_icon_dir .. icon,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
top = beautiful.dpi(3),
|
||||
bottom = beautiful.dpi(3),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
{ -- Left space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background
|
||||
}
|
||||
|
||||
widget:connect_signal("mouse::enter", function(result)
|
||||
result.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
widget:connect_signal("mouse::leave", function(result)
|
||||
result.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
|
||||
widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 1) then
|
||||
awful.spawn(command, false)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return widget
|
||||
end
|
||||
|
||||
return make_shortcut
|
46
modules/simple_widgets/textclock.lua
Executable file
46
modules/simple_widgets/textclock.lua
Executable file
@ -0,0 +1,46 @@
|
||||
local textclock = {}
|
||||
|
||||
textclock.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right spacer
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
wibox.widget {
|
||||
wibox.widget.textclock("%m/%d"),
|
||||
wibox.widget.textclock("%I:%M", 60),
|
||||
|
||||
-- Long format:
|
||||
-- wibox.widget.textclock("%m/%d/%y"),
|
||||
-- wibox.widget.textclock("%I:%M:%S", 1),
|
||||
-- %H - 24-hour time
|
||||
-- %I - 12-hour time
|
||||
|
||||
forced_num_cols = 1,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
expand = true,
|
||||
layout = wibox.layout.grid
|
||||
},
|
||||
{ -- Left spacer
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
-- Change background when mouse is over widget
|
||||
textclock.widget:connect_signal("mouse::enter", function(result)
|
||||
textclock.widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
textclock.widget:connect_signal("mouse::leave", function(result)
|
||||
textclock.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
return textclock
|
Reference in New Issue
Block a user