Created "core" module
This commit is contained in:
4
core/init.lua
Executable file
4
core/init.lua
Executable file
@ -0,0 +1,4 @@
|
||||
return {
|
||||
-- When everything is ready, call core.start()
|
||||
start = require("core.start")
|
||||
}
|
84
core/layouts/layoutmanager.lua
Normal file
84
core/layouts/layoutmanager.lua
Normal file
@ -0,0 +1,84 @@
|
||||
local LayoutManager = {
|
||||
layouts = nil, -- Table of groups
|
||||
-- current state is kept in each tag, as tag.layout.
|
||||
}
|
||||
|
||||
-- screen.layouts, awful.layouts, and tag.layouts are all ignored.
|
||||
-- This module replaces the standard layout functions.
|
||||
|
||||
|
||||
|
||||
|
||||
-- Get group from layout
|
||||
-- We assume that this layout is in LayoutManager.layouts
|
||||
function LayoutManager:get_group(layout)
|
||||
for k, v in pairs(self.layouts) do
|
||||
for l, m in pairs(v) do
|
||||
if (layout == m) then
|
||||
return k
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function LayoutManager:get_alt(layout)
|
||||
for k, v in pairs(self.layouts) do
|
||||
for l, m in pairs(v) do
|
||||
if (layout == m) then
|
||||
return l
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function LayoutManager:default_layout()
|
||||
return self.layouts[1][1]
|
||||
end
|
||||
|
||||
-- Change layout group
|
||||
function LayoutManager:group(step)
|
||||
local s = awful.screen.focused()
|
||||
local tag = s.selected_tag -- Multiple selected tags are NOT supported!
|
||||
local layout = tag.layout
|
||||
|
||||
-- Subtract 1, 'cuz lua doesn't start at 0
|
||||
local group = self:get_group(layout) - 1
|
||||
|
||||
|
||||
group = ((group + step) % #self.layouts) + 1
|
||||
|
||||
awful.layout.set(self.layouts[group][1], tag)
|
||||
end
|
||||
|
||||
-- Change layout alternate
|
||||
function LayoutManager:alt(step)
|
||||
local s = awful.screen.focused()
|
||||
local tag = s.selected_tag -- Multiple selected tags are NOT supported!
|
||||
local layout = tag.layout
|
||||
|
||||
-- Subtract 1, 'cuz lua doesn't start at 0
|
||||
local alt = self:get_alt(layout) - 1
|
||||
local group = self:get_group(layout)
|
||||
|
||||
|
||||
alt = ((alt + step) % #self.layouts[group]) + 1
|
||||
|
||||
awful.layout.set(self.layouts[group][alt], tag)
|
||||
end
|
||||
|
||||
function LayoutManager:next()
|
||||
self:group(1)
|
||||
end
|
||||
function LayoutManager:prev()
|
||||
self:group(-1)
|
||||
end
|
||||
function LayoutManager:next_alt()
|
||||
self:alt(1)
|
||||
end
|
||||
function LayoutManager:prev_alt()
|
||||
self:alt(-1)
|
||||
end
|
||||
|
||||
return LayoutManager
|
36
core/layouts/widget.lua
Executable file
36
core/layouts/widget.lua
Executable file
@ -0,0 +1,36 @@
|
||||
local make = function(screen)
|
||||
local widget
|
||||
|
||||
widget = wibox.widget {
|
||||
{
|
||||
awful.widget.layoutbox(screen),
|
||||
margins = beautiful.dpi(3),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
-- Setup buttons
|
||||
widget:buttons(
|
||||
gears.table.join(
|
||||
awful.button({ }, 1, function () layoutmanager:next_alt() end),
|
||||
awful.button({ }, 3, function () layoutmanager:prev_alt() end),
|
||||
awful.button({ }, 4, function () layoutmanager:next() end),
|
||||
awful.button({ }, 5, function () layoutmanager:prev() end)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
-- Change background when mouse is over widget
|
||||
widget:connect_signal("mouse::enter", function(result)
|
||||
widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
widget:connect_signal("mouse::leave", function(result)
|
||||
widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
return widget
|
||||
end
|
||||
|
||||
return make
|
51
core/shortcut.lua
Normal file
51
core/shortcut.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local shortcuts = {}
|
||||
|
||||
function shortcuts:new(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 shortcuts
|
232
core/start.lua
Executable file
232
core/start.lua
Executable file
@ -0,0 +1,232 @@
|
||||
local function start()
|
||||
local desktop = {
|
||||
widgets = {
|
||||
tasklist = require("core.tasklist"),
|
||||
textclock = require("core.textclock"),
|
||||
keymap = modules.ibus.widgets.ibus,
|
||||
volume = modules.volume.widgets.volume,
|
||||
launcher = modules.launcher.widgets.launcher,
|
||||
shortcut = require("core.shortcut"),
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- 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")
|
||||
|
||||
|
||||
-- Load conditional modules
|
||||
if conf.backlight_enabled then
|
||||
desktop.widgets.backlight = modules.backlight.widgets.backlight
|
||||
end
|
||||
if conf.battery_enabled then
|
||||
desktop.widgets.battery = modules.battery.widgets.battery
|
||||
end
|
||||
if conf.mpc_enabled then
|
||||
desktop.widgets.mpc = modules.mpc.widgets.mpc
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 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 conf.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 = conf.bar_position,
|
||||
screen = s,
|
||||
--bg = "#00000000",
|
||||
bg = beautiful.color.bar.color,
|
||||
border_width = 0,
|
||||
height = beautiful.dpi(conf.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 (#conf.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(conf.bar_shortcuts) do
|
||||
s.shortcuts[#s.shortcuts + 1] = desktop.widgets.shortcut:new(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 (conf.mpc_enabled) then
|
||||
rightside = gears.table.join(rightside, {
|
||||
desktop.widgets.mpc,
|
||||
desktop.widgets.space(5),
|
||||
desktop.widgets.separator(2, 5, 3),
|
||||
desktop.widgets.space(15),
|
||||
|
||||
})
|
||||
end
|
||||
|
||||
rightside = gears.table.join(rightside, {
|
||||
desktop.widgets.textclock,
|
||||
desktop.widgets.space(8),
|
||||
|
||||
desktop.widgets.battery,
|
||||
desktop.widgets.backlight,
|
||||
desktop.widgets.volume,
|
||||
desktop.widgets.space(8),
|
||||
|
||||
desktop.widgets.keymap,
|
||||
desktop.widgets.space(8),
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
s.bar:setup {
|
||||
layout = wibox.container.margin,
|
||||
margins = beautiful.dpi(conf.bar_margin),
|
||||
|
||||
{
|
||||
layout = wibox.layout.align.horizontal,
|
||||
{
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
|
||||
desktop.widgets.space(8),
|
||||
|
||||
|
||||
desktop.widgets.launcher,
|
||||
|
||||
desktop.widgets.space(18),
|
||||
s.tagger.widget,
|
||||
make_layoutbox(s),
|
||||
|
||||
s.shortcuts,
|
||||
|
||||
desktop.widgets.space(6),
|
||||
desktop.widgets.separator(2, 5, 3),
|
||||
desktop.widgets.space(18),
|
||||
desktop.widgets.tasklist(s),
|
||||
},
|
||||
|
||||
s.mypromptbox,
|
||||
rightside
|
||||
}
|
||||
}
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
return start
|
145
core/tagger/tagger.lua
Executable file
145
core/tagger/tagger.lua
Executable file
@ -0,0 +1,145 @@
|
||||
-- Tag grid manager
|
||||
|
||||
local widget = require("core.tagger.widget")
|
||||
|
||||
local Tagger = {
|
||||
screen = nil, rows = 2, cols = 4
|
||||
}
|
||||
Tagger.__index = Tagger
|
||||
|
||||
function Tagger:new(screen)
|
||||
local t = {}
|
||||
setmetatable(t, Tagger)
|
||||
t.screen = screen
|
||||
|
||||
-- Create tags on this Tagger's screen
|
||||
for r=1, t.rows do
|
||||
for c=1, t.cols do
|
||||
awful.tag.add("(" .. tostring(r) .. ", " .. tostring(c) .. ")", {
|
||||
layout = layoutmanager:default_layout(),
|
||||
screen = t.screen,
|
||||
|
||||
gap_single_client = false,
|
||||
gap = beautiful.useless_gap,
|
||||
volatile = false,
|
||||
|
||||
-- Only select the first tag
|
||||
selected = ((r == 1) and (c == 1))
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
t.widget = widget(t)
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
function Tagger:get_tag()
|
||||
return self.screen.selected_tag.index
|
||||
end
|
||||
|
||||
-- Return current column
|
||||
function Tagger:get_col()
|
||||
return ( (self:get_tag() - 1) % self.cols ) + 1
|
||||
end
|
||||
|
||||
-- Return current row
|
||||
function Tagger:get_row()
|
||||
return math.floor( (self:get_tag() - self:get_col()) / self.cols ) + 1
|
||||
end
|
||||
|
||||
-- Select a tag by position
|
||||
function Tagger:setpos(row, col)
|
||||
local target_absolute = (self.cols * (row - 1)) + col
|
||||
local target_relative = target_absolute - self.screen.selected_tag.index
|
||||
awful.tag.viewidx(target_relative)
|
||||
|
||||
self:update_widget()
|
||||
end
|
||||
|
||||
-- Update this tagindicator
|
||||
function Tagger:update_widget()
|
||||
local clients
|
||||
local tgs = self.screen.tags
|
||||
|
||||
for i=1, #tgs do
|
||||
clients = tgs[i]:clients()
|
||||
|
||||
-- Each tag indicator is a "checkbox" widget.
|
||||
-- Make that the currently active tag is checked and that all
|
||||
-- others are not.
|
||||
if (tgs[i].index == self.screen.selected_tag.index) then
|
||||
self.widget.tagindicators[i].checked = true
|
||||
else
|
||||
self.widget.tagindicators[i].checked = false
|
||||
end
|
||||
|
||||
-- Highlight tags that are not empty
|
||||
if (#clients == 0) then
|
||||
self.widget.tagindicators[i].border_color = beautiful.color.bar.inactive
|
||||
else
|
||||
self.widget.tagindicators[i].border_color = beautiful.color.bar.active
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
function Tagger:up()
|
||||
local row = self:get_row() - 1
|
||||
local col = self:get_col()
|
||||
|
||||
if (row >= 1) then
|
||||
self:setpos(row, col)
|
||||
end
|
||||
end
|
||||
|
||||
function Tagger:down()
|
||||
local row = self:get_row() + 1
|
||||
local col = self:get_col()
|
||||
|
||||
if (row <= self.rows) then
|
||||
self:setpos(row, col)
|
||||
end
|
||||
end
|
||||
|
||||
function Tagger:right()
|
||||
local row = self:get_row()
|
||||
local col = self:get_col() + 1
|
||||
|
||||
if (col <= self.cols) then
|
||||
self:setpos(row, col)
|
||||
end
|
||||
end
|
||||
|
||||
function Tagger:left()
|
||||
local row = self:get_row()
|
||||
local col = self:get_col() - 1
|
||||
|
||||
if (col >= 1) then
|
||||
self:setpos(row, col)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Moving clients
|
||||
function Tagger:move_client(client, direction)
|
||||
if direction == "up" then
|
||||
self:up()
|
||||
elseif direction == "down" then
|
||||
self:down()
|
||||
elseif direction == "left" then
|
||||
self:left()
|
||||
elseif direction == "right" then
|
||||
self:right()
|
||||
end
|
||||
|
||||
if client.first_tag.layout == awful.layout.suit.floating then
|
||||
client.floating = true
|
||||
end
|
||||
|
||||
client:move_to_tag(self.screen.selected_tag)
|
||||
self:update_widget()
|
||||
end
|
||||
|
||||
return Tagger
|
66
core/tagger/widget.lua
Executable file
66
core/tagger/widget.lua
Executable file
@ -0,0 +1,66 @@
|
||||
local make = function(tagger)
|
||||
local widget = {}
|
||||
|
||||
-- Create tag tagindicators
|
||||
-- We're using flex.vertical and flex.horizontal layouts because the grid
|
||||
-- layout doesn't expand things properly.
|
||||
widget.tagindicators = {}
|
||||
widget.tagindicator = wibox.widget {
|
||||
homogeneous = true,
|
||||
spacing = beautiful.dpi(2),
|
||||
min_cols_size = 10,
|
||||
min_rows_size = 10,
|
||||
layout = wibox.layout.grid
|
||||
}
|
||||
|
||||
local tmp_row
|
||||
for r=1, tagger.rows do
|
||||
for c=1, tagger.cols do
|
||||
widget.tagindicators[(c + (tagger.cols * (r - 1)))] = wibox.widget {
|
||||
checked = false,
|
||||
border_width = beautiful.dpi(2),
|
||||
paddings = beautiful.dpi(3),
|
||||
color = beautiful.color.bar.active,
|
||||
border_color = beautiful.color.bar.inactive,
|
||||
widget = wibox.widget.checkbox
|
||||
}
|
||||
|
||||
-- Calculate checkbox size limit
|
||||
local cbox_maxsize = beautiful.dpi(conf.bar_height)
|
||||
cbox_maxsize = cbox_maxsize - (2 * beautiful.dpi(conf.bar_margin))
|
||||
cbox_maxsize = cbox_maxsize - (tagger.rows - 1)*(beautiful.dpi(widget.tagindicator.spacing))
|
||||
|
||||
if ((conf.bar_position == "bottom") or (conf.bar_position == "top")) then
|
||||
cbox_maxsize = cbox_maxsize / tagger.rows
|
||||
else
|
||||
cbox_maxsize = cbox_maxsize / tagger.cols
|
||||
end
|
||||
|
||||
widget.tagindicator:add_widget_at(
|
||||
-- The constraint container is VERY necessary here!
|
||||
-- Otherwise, the checkboxes will fill all the height that is available to them.
|
||||
wibox.container.constraint(
|
||||
widget.tagindicators[(c + (tagger.cols * (r - 1)))],
|
||||
"exact", cbox_maxsize, cbox_maxsize
|
||||
), r, c)
|
||||
end
|
||||
end
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
widget.tagindicator,
|
||||
layout = wibox.container.background
|
||||
}
|
||||
|
||||
-- Change background when mouse is over widget
|
||||
widget.widget:connect_signal("mouse::enter", function(result)
|
||||
widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("mouse::leave", function(result)
|
||||
widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
return widget
|
||||
end
|
||||
|
||||
return make
|
120
core/tasklist.lua
Executable file
120
core/tasklist.lua
Executable file
@ -0,0 +1,120 @@
|
||||
local tasklist = {}
|
||||
|
||||
--[[ Create a tasklist widget
|
||||
s.mytasklist = awful.widget.tasklist {
|
||||
screen = s,
|
||||
filter = awful.widget.tasklist.filter.currenttags,
|
||||
buttons = tasklist_buttons
|
||||
} ]]--
|
||||
|
||||
local buttons = gears.table.join(
|
||||
awful.button( {}, 1,
|
||||
function (c)
|
||||
if c == client.focus then
|
||||
c.minimized = true
|
||||
else
|
||||
c:emit_signal(
|
||||
"request::activate",
|
||||
"tasklist",
|
||||
{raise = true}
|
||||
)
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
tasklist.make = function(screen)
|
||||
return awful.widget.tasklist({
|
||||
screen = screen,
|
||||
filter = awful.widget.tasklist.filter.currenttags,
|
||||
buttons = buttons,
|
||||
layout = {
|
||||
spacing_widget = {
|
||||
{
|
||||
forced_width = beautiful.dpi(2),
|
||||
forced_height = beautiful.dpi(12),
|
||||
thickness = beautiful.dpi(1),
|
||||
color = "#000000FF", --beautiful.color.bar.spacer,
|
||||
widget = wibox.widget.separator
|
||||
},
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
widget = wibox.container.place,
|
||||
},
|
||||
spacing = 1,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
|
||||
-- Notice that there is *NO* wibox.wibox prefix, it is a template,
|
||||
-- not a widget instance.
|
||||
widget_template = {
|
||||
{
|
||||
wibox.widget.base.make_widget(),
|
||||
forced_height = beautiful.dpi(3),
|
||||
id = "top_tab",
|
||||
widget = wibox.container.background,
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
id = "clienticon",
|
||||
widget = awful.widget.clienticon,
|
||||
forced_width = conf.clienticon_width
|
||||
},
|
||||
margins = beautiful.dpi(3),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "background",
|
||||
widget = wibox.container.background,
|
||||
},
|
||||
nil,
|
||||
|
||||
|
||||
-- The create callback is only called once, when the task indicator
|
||||
-- is created.
|
||||
create_callback = function(self, c, index, objects)
|
||||
-- Set indicator icon
|
||||
self:get_children_by_id("clienticon")[1].client = c
|
||||
|
||||
-- Change background when mouse is over widget
|
||||
self:connect_signal("mouse::enter", function(result)
|
||||
self:get_children_by_id("top_tab")[1].bg = "#2DA0DA"
|
||||
self:get_children_by_id("background")[1].bg = beautiful.color.bar.hover_bg
|
||||
|
||||
end)
|
||||
|
||||
self:connect_signal("mouse::leave", function(result)
|
||||
self:get_children_by_id("background")[1].bg = beautiful.color.transparent
|
||||
|
||||
if c == client.focus then
|
||||
self:get_children_by_id("top_tab")[1].bg = "#2DA0FF"
|
||||
elseif c.minimized then
|
||||
self:get_children_by_id("top_tab")[1].bg = "#2DA0DA77"
|
||||
else
|
||||
self:get_children_by_id("top_tab")[1].bg = beautiful.color.bar.hover_bg --beautiful.color.transparent
|
||||
end
|
||||
end)
|
||||
end,
|
||||
|
||||
-- The update callback is called every time the icon needs updating.
|
||||
update_callback = function(self, c, index, objects)
|
||||
|
||||
-- Update indicator icon
|
||||
self:get_children_by_id("clienticon")[1].client = c
|
||||
|
||||
-- Update top color
|
||||
if c == client.focus then
|
||||
self:get_children_by_id("top_tab")[1].bg = "#2DA0DA"
|
||||
elseif c.minimized then
|
||||
self:get_children_by_id("top_tab")[1].bg = "#2DA0DA77"
|
||||
else
|
||||
self:get_children_by_id("top_tab")[1].bg = beautiful.color.bar.hover_bg --beautiful.color.transparent
|
||||
end
|
||||
end,
|
||||
layout = wibox.layout.align.vertical,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return tasklist.make
|
48
core/textclock.lua
Executable file
48
core/textclock.lua
Executable file
@ -0,0 +1,48 @@
|
||||
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.widget
|
62
core/wallpaper.lua
Executable file
62
core/wallpaper.lua
Executable file
@ -0,0 +1,62 @@
|
||||
local wallpaper = {}
|
||||
|
||||
wallpaper.active = -1
|
||||
|
||||
-- How many minutes have passed since 00:00
|
||||
wallpaper.timenow = function()
|
||||
local time = {}
|
||||
|
||||
local t
|
||||
for t in string.gmatch(os.date("%H:%M"), "[^:]+") do
|
||||
table.insert(time, t)
|
||||
end
|
||||
|
||||
return (tonumber(time[1]) * 60) + tonumber(time[2])
|
||||
end
|
||||
|
||||
|
||||
-- Return wallpaper's start time in minutes since 00:00
|
||||
wallpaper.get_start_time = function(entry)
|
||||
return (entry.start_time[1] * 60) + entry.start_time[2]
|
||||
end
|
||||
|
||||
|
||||
-- Set the ith wallpaper
|
||||
wallpaper.set = function(i)
|
||||
local path = beautiful.wallpaper[i].file
|
||||
wallpaper.active = i
|
||||
|
||||
-- Set wallpaper maximized on each display
|
||||
for s in screen do
|
||||
gears.wallpaper.maximized(path, s)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Which image should be scheduled now?
|
||||
wallpaper.current = function()
|
||||
local i
|
||||
for i = #beautiful.wallpaper, 1, -1 do
|
||||
if wallpaper.get_start_time(beautiful.wallpaper[i]) <= wallpaper.timenow() then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
wallpaper.update = function()
|
||||
local current = wallpaper.current()
|
||||
|
||||
if current ~= wallpaper.active then
|
||||
wallpaper.set(current)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
wallpaper.start = function()
|
||||
window.timer = gears.timer.start_new(10, wallpaper.update)
|
||||
end
|
||||
|
||||
return wallpaper
|
Reference in New Issue
Block a user