Reset old config
This commit is contained in:
232
desktop/init.lua
Executable file
232
desktop/init.lua
Executable file
@ -0,0 +1,232 @@
|
||||
local desktop = {
|
||||
Tagger = require("desktop.tagger"),
|
||||
|
||||
popup = {
|
||||
language = require("desktop.popups.language")
|
||||
},
|
||||
|
||||
widgets = {
|
||||
tasklist = require("desktop.widgets.tasklist"),
|
||||
textclock = require("desktop.widgets.textclock"),
|
||||
layoutbox = require("desktop.widgets.layoutbox"),
|
||||
keymap = require("desktop.widgets.keymap"),
|
||||
volume = require("desktop.widgets.volume"),
|
||||
tagindicator = require("desktop.widgets.tagindicator"),
|
||||
launcher = require("desktop.widgets.launcher"),
|
||||
shortcut = require("desktop.widgets.shortcut"),
|
||||
mdadm = require("desktop.widgets.mdadm"),
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- Load conditional modules
|
||||
if conf.backlight_enabled then
|
||||
desktop.widgets.backlight = require("desktop.widgets.backlight")
|
||||
end
|
||||
if conf.battery_enabled then
|
||||
desktop.widgets.battery = require("desktop.widgets.battery")
|
||||
end
|
||||
if conf.mpc_enabled then
|
||||
desktop.widgets.mpc = require("desktop.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 each screen
|
||||
awful.screen.connect_for_each_screen(
|
||||
function(s)
|
||||
-- s: the screen this function is being called for
|
||||
-- Create tag table
|
||||
|
||||
s.tagger = desktop.Tagger:new(s)
|
||||
desktop.widgets.tagindicator(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
|
||||
|
||||
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),
|
||||
desktop.widgets.mdadm,
|
||||
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.tagindicator,
|
||||
desktop.widgets.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
|
||||
)
|
||||
|
||||
return desktop
|
110
desktop/popups/language.lua
Normal file
110
desktop/popups/language.lua
Normal file
@ -0,0 +1,110 @@
|
||||
local language = {}
|
||||
|
||||
|
||||
language.language_list = conf.ibus_language_list
|
||||
|
||||
|
||||
language.widget = wibox.widget {
|
||||
homogeneous = false,
|
||||
vertical_homogeneous = true,
|
||||
horizontal_homogeneous = false,
|
||||
vertical_spacing = beautiful.dpi(10),
|
||||
horizontal_spacing = beautiful.dpi(0),
|
||||
min_cols_size = beautiful.dpi(20),
|
||||
min_rows_size = beautiful.dpi(20),
|
||||
layout = wibox.layout.grid
|
||||
}
|
||||
|
||||
|
||||
for k, l in pairs(language.language_list) do
|
||||
|
||||
l["widget_checkbox"] = wibox.widget {
|
||||
checked = false,
|
||||
border_width = beautiful.dpi(3),
|
||||
paddings = beautiful.dpi(4),
|
||||
margins = beautiful.dpi(5),
|
||||
color = beautiful.color.bar.active,
|
||||
border_color = beautiful.color.bar.inactive,
|
||||
widget = wibox.widget.checkbox,
|
||||
forced_height = beautiful.dpi(30),
|
||||
forced_width = beautiful.dpi(30),
|
||||
shape = gears.shape.circle,
|
||||
}
|
||||
|
||||
language.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1)
|
||||
|
||||
language.widget:add_widget_at(wibox.widget {
|
||||
markup = "<b>" .. l["title"] .. "</b>",
|
||||
align = "left",
|
||||
valign = "center",
|
||||
font = "Comfortaa 23",
|
||||
widget = wibox.widget.textbox
|
||||
}, k, 2, 0, 1)
|
||||
end
|
||||
|
||||
language.next = function()
|
||||
if (language.popup.visible) then
|
||||
wrapper.ibus.next(function()
|
||||
language.update_checks()
|
||||
end)
|
||||
else
|
||||
language.update_checks()
|
||||
end
|
||||
|
||||
language.show_popup()
|
||||
end
|
||||
|
||||
language.update_checks = function()
|
||||
for _, l in pairs(language.language_list) do
|
||||
l["widget_checkbox"].checked = (wrapper.ibus.current_engine == l["ibus_engine"])
|
||||
end
|
||||
end
|
||||
|
||||
language.show_popup = function()
|
||||
language.popup.screen = awful.screen.focused()
|
||||
language.popup.visible = true
|
||||
|
||||
language.popup_timer:again()
|
||||
end
|
||||
|
||||
language.popup = awful.popup {
|
||||
widget = {
|
||||
{
|
||||
language.widget,
|
||||
margins = 10,
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = "#000000",
|
||||
opacity = 1,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
border_color = "#000000",
|
||||
border_width = 0,
|
||||
opacity = 1,
|
||||
|
||||
type = "menu",
|
||||
ontop = true,
|
||||
visible = false,
|
||||
hide_on_right_click = true,
|
||||
|
||||
shape = gears.shape.rounded_rect,
|
||||
placement = function(d)
|
||||
return awful.placement.centered(d, {
|
||||
honor_workarea = true
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
||||
language.popup_timer = gears.timer {
|
||||
timeout = 1,
|
||||
autostart = false,
|
||||
call_now = false,
|
||||
single_shot = true,
|
||||
|
||||
callback = function()
|
||||
language.popup.visible = false
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
return language
|
141
desktop/tagger.lua
Executable file
141
desktop/tagger.lua
Executable file
@ -0,0 +1,141 @@
|
||||
-- Tag grid manager
|
||||
|
||||
local Tagger = {
|
||||
screen = nil, rows = 2, cols = 3
|
||||
}
|
||||
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
|
||||
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 tagger's screen's 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.screen.tagindicators[i].checked = true
|
||||
else
|
||||
self.screen.tagindicators[i].checked = false
|
||||
end
|
||||
|
||||
-- Highlight tags that are not empty
|
||||
if (#clients == 0) then
|
||||
self.screen.tagindicators[i].border_color = beautiful.color.bar.inactive
|
||||
else
|
||||
self.screen.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
|
62
desktop/wallpaper.lua
Executable file
62
desktop/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
|
101
desktop/widgets/backlight.lua
Executable file
101
desktop/widgets/backlight.lua
Executable file
@ -0,0 +1,101 @@
|
||||
local backlight = {}
|
||||
|
||||
|
||||
backlight.icon = wibox.widget {
|
||||
id = "icon",
|
||||
image = beautiful.icons.brightness.i,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
}
|
||||
|
||||
backlight.arc = wibox.widget {
|
||||
{
|
||||
backlight.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
|
||||
backlight.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{ -- Main indicator. Can be replaced with backlight.arc
|
||||
backlight.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
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,
|
||||
}
|
||||
|
||||
backlight.widget:connect_signal("mouse::enter", function(result)
|
||||
backlight.widget.bg = beautiful.color.bar.hover_bg
|
||||
|
||||
end)
|
||||
|
||||
backlight.widget:connect_signal("mouse::leave", function(result)
|
||||
backlight.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
backlight.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
-- Scroll up
|
||||
if (button == 4) then
|
||||
wrapper.backlight.up()
|
||||
-- Scroll down
|
||||
elseif (button == 5) then
|
||||
wrapper.backlight.down()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
backlight.update = function(value)
|
||||
backlight.arc.value = value
|
||||
|
||||
--[[if value > 90 then backlight.icon.image = beautiful.icons.brightness.i
|
||||
elseif value > 80 then backlight.icon.image = beautiful.icons.brightness.h
|
||||
elseif value > 70 then backlight.icon.image = beautiful.icons.brightness.g
|
||||
elseif value > 60 then backlight.icon.image = beautiful.icons.brightness.f
|
||||
elseif value > 50 then backlight.icon.image = beautiful.icons.brightness.e
|
||||
elseif value > 40 then backlight.icon.image = beautiful.icons.brightness.d
|
||||
elseif value > 30 then backlight.icon.image = beautiful.icons.brightness.c
|
||||
elseif value > 20 then backlight.icon.image = beautiful.icons.brightness.b
|
||||
elseif value <= 10 then backlight.icon.image = beautiful.icons.brightness.a end
|
||||
--]]
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Add various hooks
|
||||
wrapper.backlight.add_hook(backlight.update)
|
||||
bin.backlight.watch(
|
||||
5,
|
||||
function()
|
||||
wrapper.backlight.read(backlight.update)
|
||||
end,
|
||||
backlight.widget
|
||||
)
|
||||
|
||||
return backlight.widget
|
214
desktop/widgets/battery.lua
Executable file
214
desktop/widgets/battery.lua
Executable file
@ -0,0 +1,214 @@
|
||||
local battery = {}
|
||||
|
||||
-- Percentages to warn at
|
||||
-- (must be in order least -> greatest)
|
||||
battery.warnings = {
|
||||
5, 10, 25, 50
|
||||
}
|
||||
|
||||
battery.warninglog = {}
|
||||
|
||||
for i=1, #battery.warnings do
|
||||
battery.warninglog[i] = false
|
||||
end
|
||||
|
||||
battery.image_path = beautiful.icons.battery.missing
|
||||
battery.icon = wibox.widget {
|
||||
image = beautiful.icons.battery.missing,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
}
|
||||
|
||||
|
||||
battery.progressbar = wibox.widget {
|
||||
max_value = 100,
|
||||
widget = wibox.widget.progressbar,
|
||||
paddings = beautiful.dpi(2),
|
||||
color = beautiful.color.bar.active,
|
||||
background_color = beautiful.color.transparent,
|
||||
border_color = beautiful.color.bar.active,
|
||||
border_width = beautiful.dpi(1),
|
||||
margins = beautiful.dpi(3)
|
||||
}
|
||||
|
||||
battery.arc = wibox.widget {
|
||||
{
|
||||
battery.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
|
||||
battery.rotator = wibox.widget {
|
||||
battery.progressbar,
|
||||
forced_width = beautiful.dpi(15),
|
||||
direction = "east",
|
||||
layout = wibox.container.rotate,
|
||||
}
|
||||
|
||||
|
||||
battery.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{
|
||||
battery.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
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,
|
||||
}
|
||||
|
||||
battery.widget:connect_signal("mouse::enter", function(result)
|
||||
battery.widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
battery.widget:connect_signal("mouse::leave", function(result)
|
||||
battery.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
battery.update = function(stdout)
|
||||
local batpec = string.match(stdout, "(%d?%d?%d)%%")
|
||||
batpec = tonumber(string.format("% 3d", batpec))
|
||||
|
||||
local discharging = string.match(stdout, "discharging") or false
|
||||
|
||||
-- Handle low power notifications
|
||||
if discharging then
|
||||
for i=1, #battery.warnings do
|
||||
v = battery.warnings[i]
|
||||
if (batpec <= v) and (not battery.warninglog[i]) then
|
||||
battery.warninglog[i] = true
|
||||
|
||||
naughty.notify({
|
||||
title = "Low power",
|
||||
text = "Battery is at " .. tostring(batpec) .. "%",
|
||||
icon = beautiful.icons.battery.caution,
|
||||
|
||||
timeout = 5,
|
||||
ignore_suspend = true,
|
||||
|
||||
border_color = beautiful.color.battery.danger,
|
||||
preset = beautiful.notification_templates.bottom_right
|
||||
})
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
for i=1, #battery.warnings do
|
||||
if (batpec >= battery.warnings[i]) then
|
||||
battery.warninglog[i] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
battery.progressbar.value = batpec
|
||||
battery.arc.value = batpec
|
||||
|
||||
if batpec > 60 then
|
||||
battery.progressbar.color = beautiful.color.battery.good
|
||||
elseif batpec > 40 then
|
||||
battery.progressbar.color = beautiful.color.battery.low
|
||||
elseif batpec <= 40 then
|
||||
battery.progressbar.color = beautiful.color.battery.danger
|
||||
end
|
||||
|
||||
|
||||
battery.image_path = beautiful.icons.battery.missing
|
||||
-- Set current battery icon
|
||||
if (not discharging) then
|
||||
if batpec > 80 then battery.image_path = beautiful.icons.battery.charging.full
|
||||
elseif batpec > 60 then battery.image_path = beautiful.icons.battery.charging.good
|
||||
elseif batpec > 40 then battery.image_path = beautiful.icons.battery.charging.low
|
||||
elseif batpec > 20 then battery.image_path = beautiful.icons.battery.charging.caution
|
||||
elseif batpec <= 20 then battery.image_path = beautiful.icons.battery.charging.empty end
|
||||
else
|
||||
if batpec > 80 then battery.image_path = beautiful.icons.battery.full
|
||||
elseif batpec > 60 then battery.image_path = beautiful.icons.battery.good
|
||||
elseif batpec > 40 then battery.image_path = beautiful.icons.battery.low
|
||||
elseif batpec > 20 then battery.image_path = beautiful.icons.battery.caution
|
||||
elseif batpec <= 20 then battery.image_path = beautiful.icons.battery.empty end
|
||||
end
|
||||
battery.icon.image = battery.image_path
|
||||
|
||||
if (not discharging) and (batpec > 90) then
|
||||
battery.progressbar.border_color = beautiful.color.battery.good
|
||||
elseif (discharging) and (batpec <= 25) then
|
||||
battery.progressbar.border_color = beautiful.color.battery.danger
|
||||
else
|
||||
battery.progressbar.border_color = beautiful.color.bar.active
|
||||
end
|
||||
|
||||
if discharging then
|
||||
battery.rotator.direction = "east"
|
||||
else
|
||||
battery.rotator.direction = "west"
|
||||
end
|
||||
end
|
||||
|
||||
battery.readupdate = function()
|
||||
bin.battery.status(
|
||||
function(stdout, stderr, exitreason, exitcode)
|
||||
battery.update(stdout)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
battery.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 1) then
|
||||
bin.battery.status(
|
||||
function(stdout, stderr, exitreason, exitcode)
|
||||
local batpec = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%)
|
||||
local batstat = string.match(stdout, "discharging") or false
|
||||
|
||||
if batstat then
|
||||
batstat = "Discharging, "
|
||||
else
|
||||
batstat = "Charging, "
|
||||
end
|
||||
|
||||
local out = naughty.notify({
|
||||
title = "Battery:",
|
||||
text = batstat .. batpec .. "%",
|
||||
icon = battery.image_path,
|
||||
replaces_id = battery.notid,
|
||||
ignore_suspend = true,
|
||||
|
||||
preset = beautiful.notification_templates.bottom_right
|
||||
})
|
||||
battery.notid = out.id
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
bin.battery.watch(10, function(_, stdout) battery.update(stdout) end, battery.widget)
|
||||
|
||||
return battery.widget
|
41
desktop/widgets/keymap.lua
Executable file
41
desktop/widgets/keymap.lua
Executable file
@ -0,0 +1,41 @@
|
||||
local keymap = {}
|
||||
|
||||
|
||||
keymap.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right spacer
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
wibox.widget {
|
||||
wrapper.ibus.ibus_indicator_text,
|
||||
wrapper.ibus.xkb_indicator_text,
|
||||
|
||||
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
|
||||
keymap.widget:connect_signal("mouse::enter", function(result)
|
||||
keymap.widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
keymap.widget:connect_signal("mouse::leave", function(result)
|
||||
keymap.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
return keymap.widget
|
52
desktop/widgets/launcher.lua
Normal file
52
desktop/widgets/launcher.lua
Normal file
@ -0,0 +1,52 @@
|
||||
local widget = {}
|
||||
|
||||
|
||||
widget.icon = wibox.widget {
|
||||
resize = true,
|
||||
image = beautiful.icons.launcher,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{
|
||||
widget.icon,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
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.widget:connect_signal("mouse::enter", function(result)
|
||||
widget.widget.bg = beautiful.color.bar.hover_bg
|
||||
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("mouse::leave", function(result)
|
||||
widget.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 1) then
|
||||
bin.rofi.launcher()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
wrapper.volume.commands:get(widget.update)
|
||||
|
||||
return widget.widget
|
38
desktop/widgets/layoutbox.lua
Executable file
38
desktop/widgets/layoutbox.lua
Executable file
@ -0,0 +1,38 @@
|
||||
local layoutbox = {}
|
||||
|
||||
layoutbox.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 layoutbox.make
|
49
desktop/widgets/mdadm.lua
Normal file
49
desktop/widgets/mdadm.lua
Normal file
@ -0,0 +1,49 @@
|
||||
local raidw = {}
|
||||
|
||||
|
||||
raidw.title_text = wibox.widget.textbox("Raid")
|
||||
raidw.title_text.valign = "center"
|
||||
raidw.title_text.align = "center"
|
||||
raidw.title_text.font = "Hack NF 10"
|
||||
|
||||
raidw.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right spacer
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
|
||||
wibox.widget {
|
||||
raidw.title_text,
|
||||
wrapper.mdadm.indicator_text,
|
||||
|
||||
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
|
||||
raidw.widget:connect_signal("mouse::enter", function(result)
|
||||
raidw.widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
raidw.widget:connect_signal("mouse::leave", function(result)
|
||||
raidw.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
return raidw.widget
|
193
desktop/widgets/mpc.lua
Normal file
193
desktop/widgets/mpc.lua
Normal file
@ -0,0 +1,193 @@
|
||||
local mpc_widget = {}
|
||||
|
||||
mpc_widget.title = wibox.widget.textbox("MPD is not")
|
||||
mpc_widget.title.valign = "center"
|
||||
mpc_widget.title.align = "left"
|
||||
mpc_widget.title.font = "Hack NF 12"
|
||||
mpc_widget.title.ellipsize = "end"
|
||||
mpc_widget.title.forced_width = beautiful.dpi(conf.mpc_width)
|
||||
|
||||
mpc_widget.artist = wibox.widget.textbox("connected")
|
||||
mpc_widget.artist.valign = "center"
|
||||
mpc_widget.artist.align = "left"
|
||||
mpc_widget.artist.font = "Hack NF 12"
|
||||
mpc_widget.artist.ellipsize = "end"
|
||||
mpc_widget.artist.forced_width = beautiful.dpi(conf.mpc_width)
|
||||
|
||||
mpc_widget.volume = wibox.widget.textbox("??")
|
||||
mpc_widget.volume.valign = "center"
|
||||
mpc_widget.volume.align = "left"
|
||||
mpc_widget.volume.font = "Hack NF 10"
|
||||
mpc_widget.volume.ellipsize = "end"
|
||||
mpc_widget.volume.forced_width = beautiful.dpi(10)
|
||||
|
||||
|
||||
mpc_widget.icon_play = wibox.widget {
|
||||
resize = true,
|
||||
image = beautiful.icons.music.blue.play,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
|
||||
|
||||
mpc_widget.left = wibox.widget {
|
||||
wibox.widget {
|
||||
{
|
||||
mpc_widget.icon_play,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
left = 0, right = 0,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
mpc_widget.volume,
|
||||
|
||||
forced_num_cols = 1,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
expand = true,
|
||||
layout = wibox.layout.grid
|
||||
},
|
||||
layout = wibox.container.background
|
||||
}
|
||||
|
||||
mpc_widget.right = wibox.widget {
|
||||
wibox.widget {
|
||||
mpc_widget.title,
|
||||
mpc_widget.artist,
|
||||
|
||||
forced_num_cols = 1,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
expand = true,
|
||||
layout = wibox.layout.grid
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
|
||||
mpc_widget.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right spacer
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
|
||||
mpc_widget.left,
|
||||
mpc_widget.right,
|
||||
|
||||
{ -- Left spacer
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
|
||||
mpc_widget.widget:connect_signal("mouse::enter", function(result)
|
||||
mpc_widget.widget.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
mpc_widget.widget:connect_signal("mouse::leave", function(result)
|
||||
mpc_widget.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
|
||||
mpc_widget.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 3) or (button == 1)then
|
||||
bin.mpc.command("toggle")
|
||||
end
|
||||
mpc_widget.readupdate()
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
mpc_widget.right:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 4) then -- Scroll up
|
||||
bin.mpc.command("prev")
|
||||
elseif (button == 5) then -- Scroll down
|
||||
bin.mpc.command("next")
|
||||
end
|
||||
|
||||
mpc_widget.readupdate()
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
mpc_widget.left:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 4) then -- Scroll up
|
||||
bin.mpc.command("volume +5")
|
||||
elseif (button == 5) then -- Scroll down
|
||||
bin.mpc.command("volume -5")
|
||||
end
|
||||
mpc_widget.readupdate()
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
mpc_widget.update = function(stdout)
|
||||
if (stdout == "") then
|
||||
return
|
||||
end
|
||||
|
||||
mpc_widget.title.markup = string.match(stdout, "title=(.*)artist=")
|
||||
mpc_widget.artist.markup = string.match(stdout, "artist=(.*)")
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
mpc_widget.update_status = function(stdout)
|
||||
play = string.match(stdout, "(%[playing)") or false
|
||||
pause = string.match(stdout, "(%[paused)") or false
|
||||
stop = not (play or pause)
|
||||
|
||||
if (play) then
|
||||
mpc_widget.icon_play.image = beautiful.icons.music.blue.play
|
||||
elseif (pause) then
|
||||
mpc_widget.icon_play.image = beautiful.icons.music.blue.pause
|
||||
elseif (stop) then
|
||||
mpc_widget.icon_play.image = beautiful.icons.music.blue.stop
|
||||
end
|
||||
|
||||
volume = string.match(stdout, "volume: (%d?%d?%d)%%")
|
||||
if (volume) then
|
||||
mpc_widget.volume.markup = volume .. "%"
|
||||
else
|
||||
mpc_widget.volume.markup = ""
|
||||
end
|
||||
end
|
||||
|
||||
mpc_widget.readupdate = function()
|
||||
bin.mpc.command("current --format \"title=%title% artist=%artist%\"",
|
||||
function(stdout, stderr, exitreason, exitcode)
|
||||
mpc_widget.update(stdout)
|
||||
end
|
||||
)
|
||||
|
||||
bin.mpc.command("status",
|
||||
function(stdout, stderr, exitreason, exitcode)
|
||||
mpc_widget.update_status(stdout)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
-- The time here is super short because the --wait option is used in mpc.
|
||||
-- It will not return a response until changes are seen.
|
||||
bin.mpc.watch("current --wait", 0.01, function(_, stdout) mpc_widget.readupdate() end, mpc_widget.widget)
|
||||
bin.mpc.watch("current", 1, function(_, stdout) mpc_widget.readupdate() end, mpc_widget.widget)
|
||||
|
||||
|
||||
-- Make sure you do an initial read, though, otherwise the widget will
|
||||
-- not update until a change occurs.
|
||||
mpc_widget.readupdate()
|
||||
|
||||
|
||||
return mpc_widget.widget
|
51
desktop/widgets/shortcut.lua
Normal file
51
desktop/widgets/shortcut.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local shortcuts = {}
|
||||
|
||||
function shortcuts:new(command, icon)
|
||||
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
|
68
desktop/widgets/tagindicator.lua
Executable file
68
desktop/widgets/tagindicator.lua
Executable file
@ -0,0 +1,68 @@
|
||||
local tagindicator = {}
|
||||
|
||||
tagindicator.make = function(screen)
|
||||
local widget
|
||||
|
||||
-- Create tag tagindicators
|
||||
-- We're using flex.vertical and flex.horizontal layouts because the grid
|
||||
-- layout doesn't expand things properly.
|
||||
screen.tagindicators = {}
|
||||
screen.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, screen.tagger.rows do
|
||||
for c=1, screen.tagger.cols do
|
||||
screen.tagindicators[(c + (screen.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 - (screen.tagger.rows - 1)*(beautiful.dpi(screen.tagindicator.spacing))
|
||||
|
||||
if ((conf.bar_position == "bottom") or (conf.bar_position == "top")) then
|
||||
cbox_maxsize = cbox_maxsize / screen.tagger.rows
|
||||
else
|
||||
cbox_maxsize = cbox_maxsize / screen.tagger.cols
|
||||
end
|
||||
|
||||
screen.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(
|
||||
screen.tagindicators[(c + (screen.tagger.cols * (r - 1)))],
|
||||
"exact", cbox_maxsize, cbox_maxsize
|
||||
), r, c)
|
||||
end
|
||||
end
|
||||
|
||||
widget = wibox.widget {
|
||||
screen.tagindicator,
|
||||
layout = wibox.container.background
|
||||
}
|
||||
|
||||
-- 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 tagindicator.make
|
119
desktop/widgets/tasklist.lua
Executable file
119
desktop/widgets/tasklist.lua
Executable file
@ -0,0 +1,119 @@
|
||||
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,
|
||||
},
|
||||
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.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.transparent
|
||||
end
|
||||
end,
|
||||
layout = wibox.layout.align.vertical,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return tasklist.make
|
49
desktop/widgets/textclock.lua
Executable file
49
desktop/widgets/textclock.lua
Executable file
@ -0,0 +1,49 @@
|
||||
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
|
142
desktop/widgets/volume.lua
Executable file
142
desktop/widgets/volume.lua
Executable file
@ -0,0 +1,142 @@
|
||||
local widget = {}
|
||||
|
||||
|
||||
widget.icon = wibox.widget {
|
||||
resize = true,
|
||||
image = beautiful.icons.volume.mute,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
widget.arc = wibox.widget {
|
||||
{
|
||||
widget.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 1,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
widget.bar = wibox.widget {
|
||||
max_value = 100,
|
||||
value = 0,
|
||||
--forced_height = 20,
|
||||
forced_width = beautiful.dpi(50),
|
||||
paddings = 0,
|
||||
border_width = 0,
|
||||
color = {
|
||||
type = "linear",
|
||||
from = {0, 0}, to = {beautiful.dpi(50), 0},
|
||||
stops = { { 0, "#27D4CC" }, { 1, "#00446B" }}
|
||||
},
|
||||
background_color = "#FFFFFF30",
|
||||
widget = wibox.widget.progressbar,
|
||||
shape = gears.shape.rounded_bar,
|
||||
}
|
||||
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{
|
||||
widget.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
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.widget:connect_signal("mouse::enter", function(result)
|
||||
widget.widget.bg = beautiful.color.bar.hover_bg
|
||||
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("mouse::leave", function(result)
|
||||
widget.widget.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
|
||||
-- Right-click
|
||||
if (button == 3) then
|
||||
wrapper.volume.togglemute()
|
||||
|
||||
-- Scroll up
|
||||
elseif (button == 4) then
|
||||
wrapper.volume.up()
|
||||
|
||||
-- Scroll down
|
||||
elseif (button == 5) then
|
||||
wrapper.volume.down()
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
widget.update = function(status)
|
||||
|
||||
if (status.value == false) then
|
||||
widget.icon.image = beautiful.icons.volume.error
|
||||
widget.arc.value = 100;
|
||||
widget.bar.value = 100;
|
||||
return
|
||||
end
|
||||
|
||||
widget.arc.value = status.value / 100;
|
||||
widget.bar.value = status.value;
|
||||
|
||||
|
||||
if (status.mute) then
|
||||
-- Set muted icon
|
||||
widget.icon.image = beautiful.icons.volume.mute
|
||||
else
|
||||
-- Set icon by value
|
||||
if status.value > 70 then
|
||||
widget.icon.image = beautiful.icons.volume.high
|
||||
elseif status.value > 40 then
|
||||
widget.icon.image = beautiful.icons.volume.medium
|
||||
elseif status.value > 0 then
|
||||
widget.icon.image = beautiful.icons.volume.low
|
||||
elseif status.value == 0 then
|
||||
widget.icon.image = beautiful.icons.volume.off
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Add various hooks
|
||||
|
||||
wrapper.volume.add_hook(widget.update)
|
||||
wrapper.volume.commands:watch(
|
||||
5,
|
||||
function()
|
||||
wrapper.volume.commands:get(widget.update)
|
||||
end,
|
||||
widget.widget
|
||||
)
|
||||
|
||||
-- Update volume widget at start
|
||||
wrapper.volume.commands:get(widget.update)
|
||||
|
||||
return widget.widget
|
Reference in New Issue
Block a user