Started migrating to module architecture
This commit is contained in:
@ -1,15 +1,11 @@
|
||||
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"),
|
||||
keymap = modules.ibus.widgets.ibus,
|
||||
volume = require("desktop.widgets.volume"),
|
||||
tagindicator = require("desktop.widgets.tagindicator"),
|
||||
launcher = require("desktop.widgets.launcher"),
|
||||
@ -56,7 +52,7 @@ 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")
|
||||
desktop.widgets.mpc = modules.mpc.widgets.mpc
|
||||
end
|
||||
|
||||
|
||||
|
@ -1,129 +0,0 @@
|
||||
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,
|
||||
}
|
||||
|
||||
l["widget_text"] = wibox.widget {
|
||||
{
|
||||
markup = "<b>" .. l["title"] .. "</b>",
|
||||
align = "left",
|
||||
valign = "center",
|
||||
font = "Comfortaa 16",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
l["widget_text"].bg = "#00000000"
|
||||
|
||||
language.widget:add_widget_at(l["widget_text"], k, 1, 1, 1)
|
||||
--language.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1)
|
||||
--language.widget:add_widget_at(l["widget_text"], 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.set = function(idx)
|
||||
wrapper.ibus.set(idx, function()
|
||||
language.update_checks()
|
||||
end)
|
||||
language.show_popup()
|
||||
end
|
||||
|
||||
language.update_checks = function()
|
||||
for _, l in pairs(language.language_list) do
|
||||
if (wrapper.ibus.current_engine == l["ibus_engine"]) then
|
||||
l["widget_text"].bg = "#FF0000"
|
||||
else
|
||||
l["widget_text"].bg = "#00000000"
|
||||
end
|
||||
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.rectangle,
|
||||
placement = function(d)
|
||||
return awful.placement.bottom_right(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
|
@ -1,41 +0,0 @@
|
||||
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
|
@ -1,193 +0,0 @@
|
||||
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.playing,
|
||||
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.playing
|
||||
elseif (pause) then
|
||||
mpc_widget.icon_play.image = beautiful.icons.music.blue.paused
|
||||
elseif (stop) then
|
||||
mpc_widget.icon_play.image = beautiful.icons.music.blue.stopped
|
||||
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
|
Reference in New Issue
Block a user