Reset old config
This commit is contained in:
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