awesomewm/core/start.lua

213 lines
5.0 KiB
Lua
Executable File

local function start()
local desktop = {
widgets = {
space = function(size)
return wibox.widget {
{
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(size)
},
layout = wibox.container.background,
}
end,
separator = function(size, margin_h, margin_v)
return wibox.widget {
{
widget = wibox.widget.separator,
color = "#FFFFFF55",
forced_width = beautiful.dpi(size),
thickness = beautiful.dpi(size)
},
layout = wibox.container.margin,
top = beautiful.dpi(margin_v),
bottom = beautiful.dpi(margin_v),
left = beautiful.dpi(margin_h),
right = beautiful.dpi(margin_h)
}
end
}
}
local tasklist = require("core.tasklist")
-- Manages tag grid and widget
local tagger = require("core.tagger.tagger")
-- Makes a layout indicator.
-- make_layoutbox(screen) will return a widget for the given screen.
local make_layoutbox = require("core.layouts.widget")
-- If timed wallpaper is enabled, load timed manager
if (type(beautiful.wallpaper) == "table") then
desktop.wallpaper = require("desktop.wallpaper")
screen.connect_signal("property::geometry", desktop.wallpaper.update)
desktop.wallpaper.update()
desktop.wallpaper.start()
else
-- Otherwise, set static wallpaper on each screen
-- We loop over screens to prevent the wallpaper from being stretched over
-- all displays. If, for some reason, you want that to happen, use a single
-- call of "gears.wallpaper.maximized(beautiful.wallpaper)" instead of
-- this loop.
for s in screen do
gears.wallpaper.maximized(beautiful.wallpaper, s)
end
end
-- Set a timer that will update the tag indicators of all screens.
-- Even if we do not want continuous updates, we still need a timer:
-- there must be a significant delay (1ish second) before awesome prepares
-- all clients
desktop.screen_timer = gears.timer {
timeout = 2,
call_now = false,
autostart = true,
single_shot = not config.core.continuous_tag_updates,
callback = function()
for s in screen do
s.tagger:update_widget()
end
end
}
-- Prepare screens
awful.screen.connect_for_each_screen(
function(s)
-- s: the screen this function is being called for
-- Create tag table
s.tagger = tagger:new(s)
-- Create a promptbox for each s
s.mypromptbox = awful.widget.prompt()
-- Create the bar
s.bar = awful.wibar({
position = config.core.bar_position,
screen = s,
--bg = "#00000000",
bg = beautiful.color.bar.color,
border_width = 0,
height = beautiful.dpi(config.core.bar_height),
type = "desktop"
})
s.systray = wibox.widget.systray()
s.systraysep = desktop.widgets.separator(2, 5, 3)
s.bar:connect_signal("button::press",
function(_, _, _, button, mods)
-- Middle-click
if (button == 2) then
s.systray.visible = not s.systray.visible
s.systraysep.visible = s.systray.visible
end
end)
-- Create shortcut list from config value
if (#config.core.bar_shortcuts > 0) then
s.shortcuts = {
layout = wibox.layout.fixed.horizontal,
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(6)
}
for k, v in pairs(config.core.bar_shortcuts) do
s.shortcuts[#s.shortcuts + 1] = modules.simple_widgets.make_shortcut(v[1], v[2])
end
end
-- Assemble left bar widgets
local rightside = {
layout = wibox.layout.fixed.horizontal,
spacing = 0
}
rightside = gears.table.join(rightside, {
desktop.widgets.space(10),
s.systraysep,
desktop.widgets.space(10),
{
s.systray,
top = beautiful.dpi(3),
bottom = beautiful.dpi(3),
left = 0, right = 0,
layout = wibox.container.margin,
},
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(10),
})
if (modules.mpc ~= nil) then
rightside = gears.table.join(rightside, {
modules.mpc.widgets.mpc,
desktop.widgets.space(5),
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(15),
})
end
rightside = gears.table.join(rightside, {
modules.simple_widgets.textclock,
desktop.widgets.space(8),
--modules.battery.widgets.battery,
--modules.backlight.widgets.backlight,
modules.volume.widgets.volume,
desktop.widgets.space(8),
modules.ibus.widgets.keymap,
desktop.widgets.space(8),
})
s.bar:setup {
layout = wibox.container.margin,
margins = beautiful.dpi(config.core.bar_margin),
{
layout = wibox.layout.align.horizontal,
{
layout = wibox.layout.fixed.horizontal,
desktop.widgets.space(8),
modules.launcher.widgets.launcher,
desktop.widgets.space(18),
s.tagger.widget.widget,
make_layoutbox(s),
s.shortcuts,
desktop.widgets.space(6),
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(18),
tasklist(s),
},
s.mypromptbox,
rightside
}
}
end
)
end
return start