Started migrating to module architecture
parent
d68efc5713
commit
840f084db8
10
bin/init.lua
10
bin/init.lua
|
@ -72,15 +72,5 @@ return {
|
||||||
--awful.spawn("flameshot gui -p \"" .. conf.screenshot_dir .. "\"", false)
|
--awful.spawn("flameshot gui -p \"" .. conf.screenshot_dir .. "\"", false)
|
||||||
awful.spawn("flameshot gui", false)
|
awful.spawn("flameshot gui", false)
|
||||||
end
|
end
|
||||||
},
|
|
||||||
|
|
||||||
mpc = {
|
|
||||||
watch = function(command, timeout, callback, widget)
|
|
||||||
awful.widget.watch("mpc --host " .. conf.mpd_host .. " " .. command, timeout, callback, widget)
|
|
||||||
end,
|
|
||||||
|
|
||||||
command = function(command, callback)
|
|
||||||
awful.spawn.easy_async("mpc --host " .. conf.mpd_host .. " " .. command, callback)
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
return {
|
return {
|
||||||
keys = gears.table.join(
|
keys = gears.table.join(
|
||||||
require("binds.system.backlight"),
|
require("binds.system.backlight"),
|
||||||
require("binds.system.mpd"),
|
|
||||||
require("binds.system.volume"),
|
require("binds.system.volume"),
|
||||||
require("binds.system.system"),
|
require("binds.system.system"),
|
||||||
require("binds.system.input"),
|
|
||||||
|
|
||||||
require("binds.window.client"),
|
require("binds.window.client"),
|
||||||
require("binds.window.layout"),
|
require("binds.window.layout"),
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
local desktop = {
|
local desktop = {
|
||||||
Tagger = require("desktop.tagger"),
|
Tagger = require("desktop.tagger"),
|
||||||
|
|
||||||
popup = {
|
|
||||||
language = require("desktop.popups.language")
|
|
||||||
},
|
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
tasklist = require("desktop.widgets.tasklist"),
|
tasklist = require("desktop.widgets.tasklist"),
|
||||||
textclock = require("desktop.widgets.textclock"),
|
textclock = require("desktop.widgets.textclock"),
|
||||||
layoutbox = require("desktop.widgets.layoutbox"),
|
layoutbox = require("desktop.widgets.layoutbox"),
|
||||||
keymap = require("desktop.widgets.keymap"),
|
keymap = modules.ibus.widgets.ibus,
|
||||||
volume = require("desktop.widgets.volume"),
|
volume = require("desktop.widgets.volume"),
|
||||||
tagindicator = require("desktop.widgets.tagindicator"),
|
tagindicator = require("desktop.widgets.tagindicator"),
|
||||||
launcher = require("desktop.widgets.launcher"),
|
launcher = require("desktop.widgets.launcher"),
|
||||||
|
@ -56,7 +52,7 @@ if conf.battery_enabled then
|
||||||
desktop.widgets.battery = require("desktop.widgets.battery")
|
desktop.widgets.battery = require("desktop.widgets.battery")
|
||||||
end
|
end
|
||||||
if conf.mpc_enabled then
|
if conf.mpc_enabled then
|
||||||
desktop.widgets.mpc = require("desktop.widgets.mpc")
|
desktop.widgets.mpc = modules.mpc.widgets.mpc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
local util = require("modules.ibus.util")
|
||||||
|
|
||||||
|
return {
|
||||||
|
widgets = {
|
||||||
|
ibus = require("modules.ibus.widget").widget
|
||||||
|
},
|
||||||
|
keybinds = require("modules.ibus.keybinds"),
|
||||||
|
|
||||||
|
init = function()
|
||||||
|
util.set(1)
|
||||||
|
end
|
||||||
|
}
|
|
@ -1,25 +1,42 @@
|
||||||
|
local util = req_rel(..., "util")
|
||||||
|
local popup = req_rel(..., "popup")
|
||||||
|
local widget = req_rel(..., "widget")
|
||||||
|
|
||||||
return gears.table.join(
|
return gears.table.join(
|
||||||
awful.key( {"Mod4"}, "space",
|
awful.key( {"Mod4"}, "space",
|
||||||
function()
|
function()
|
||||||
desktop.popup.language.next()
|
util.next(function()
|
||||||
|
popup.update()
|
||||||
|
widget.update()
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Change input language",
|
description = "Change input language",
|
||||||
group = "System"
|
group = "System"
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
awful.key( {"Mod4", "Shift", "Control"}, "9",
|
awful.key( {"Mod4", "Shift", "Control"}, "9",
|
||||||
function()
|
function()
|
||||||
desktop.popup.language.set(2)
|
util.set(2, function()
|
||||||
|
popup.update()
|
||||||
|
widget.update()
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Set input language to RU",
|
description = "Set input language to RU",
|
||||||
group = "System"
|
group = "System"
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
||||||
awful.key( {"Mod4", "Shift", "Control"}, "0",
|
awful.key( {"Mod4", "Shift", "Control"}, "0",
|
||||||
function()
|
function()
|
||||||
desktop.popup.language.set(1)
|
util.set(1, function()
|
||||||
|
popup.update()
|
||||||
|
widget.update()
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Set input language to EN",
|
description = "Set input language to EN",
|
|
@ -1,10 +1,8 @@
|
||||||
local language = {}
|
local popup = {}
|
||||||
|
local util = req_rel(..., "util")
|
||||||
|
|
||||||
|
|
||||||
language.language_list = conf.ibus_language_list
|
popup.widget = wibox.widget {
|
||||||
|
|
||||||
|
|
||||||
language.widget = wibox.widget {
|
|
||||||
homogeneous = false,
|
homogeneous = false,
|
||||||
vertical_homogeneous = true,
|
vertical_homogeneous = true,
|
||||||
horizontal_homogeneous = false,
|
horizontal_homogeneous = false,
|
||||||
|
@ -16,7 +14,7 @@ language.widget = wibox.widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for k, l in pairs(language.language_list) do
|
for k, l in pairs(conf.ibus_language_list) do
|
||||||
|
|
||||||
l["widget_checkbox"] = wibox.widget {
|
l["widget_checkbox"] = wibox.widget {
|
||||||
checked = false,
|
checked = false,
|
||||||
|
@ -44,52 +42,33 @@ for k, l in pairs(language.language_list) do
|
||||||
|
|
||||||
l["widget_text"].bg = "#00000000"
|
l["widget_text"].bg = "#00000000"
|
||||||
|
|
||||||
language.widget:add_widget_at(l["widget_text"], k, 1, 1, 1)
|
popup.widget:add_widget_at(l["widget_text"], k, 1, 1, 1)
|
||||||
--language.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1)
|
--popup.widget:add_widget_at(l["widget_checkbox"], k, 1, 1, 1)
|
||||||
--language.widget:add_widget_at(l["widget_text"], k, 2, 0, 1)
|
--popup.widget:add_widget_at(l["widget_text"], k, 2, 0, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
language.next = function()
|
popup.update = function()
|
||||||
if (language.popup.visible) then
|
-- Update checkmarks
|
||||||
wrapper.ibus.next(function()
|
for _, l in pairs(conf.ibus_language_list) do
|
||||||
language.update_checks()
|
if (util.current_engine == l["ibus_engine"]) then
|
||||||
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"
|
l["widget_text"].bg = "#FF0000"
|
||||||
else
|
else
|
||||||
l["widget_text"].bg = "#00000000"
|
l["widget_text"].bg = "#00000000"
|
||||||
end
|
end
|
||||||
l["widget_checkbox"].checked = (wrapper.ibus.current_engine == l["ibus_engine"])
|
l["widget_checkbox"].checked = (util.current_engine == l["ibus_engine"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Show popup
|
||||||
|
popup.popup.screen = awful.screen.focused()
|
||||||
|
popup.popup.visible = true
|
||||||
|
popup.popup_timer:again()
|
||||||
end
|
end
|
||||||
|
|
||||||
language.show_popup = function()
|
|
||||||
language.popup.screen = awful.screen.focused()
|
|
||||||
language.popup.visible = true
|
|
||||||
|
|
||||||
language.popup_timer:again()
|
popup.popup = awful.popup {
|
||||||
end
|
|
||||||
|
|
||||||
language.popup = awful.popup {
|
|
||||||
widget = {
|
widget = {
|
||||||
{
|
{
|
||||||
language.widget,
|
popup.widget,
|
||||||
margins = 10,
|
margins = 10,
|
||||||
widget = wibox.container.margin
|
widget = wibox.container.margin
|
||||||
},
|
},
|
||||||
|
@ -108,22 +87,25 @@ language.popup = awful.popup {
|
||||||
|
|
||||||
shape = gears.shape.rectangle,
|
shape = gears.shape.rectangle,
|
||||||
placement = function(d)
|
placement = function(d)
|
||||||
return awful.placement.bottom_right(d, {
|
return awful.placement.bottom_right(
|
||||||
honor_workarea = true
|
d,
|
||||||
})
|
{
|
||||||
|
honor_workarea = true
|
||||||
|
}
|
||||||
|
)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
language.popup_timer = gears.timer {
|
popup.popup_timer = gears.timer {
|
||||||
timeout = 1,
|
timeout = 1,
|
||||||
autostart = false,
|
autostart = false,
|
||||||
call_now = false,
|
call_now = false,
|
||||||
single_shot = true,
|
single_shot = true,
|
||||||
|
|
||||||
callback = function()
|
callback = function()
|
||||||
language.popup.visible = false
|
popup.popup.visible = false
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return language
|
return popup
|
|
@ -0,0 +1,94 @@
|
||||||
|
local util = {}
|
||||||
|
|
||||||
|
util.current_engine = ""
|
||||||
|
util.current_engine_index = nil
|
||||||
|
util.current_xkbmap = ""
|
||||||
|
|
||||||
|
|
||||||
|
-- Update current_engine and current_engine index,
|
||||||
|
-- call callback() when done.
|
||||||
|
util.get = function(callback)
|
||||||
|
-- Get current ibus engine
|
||||||
|
awful.spawn.easy_async(
|
||||||
|
"ibus engine",
|
||||||
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
|
util.current_engine = string.gsub(stdout, "\n", "")
|
||||||
|
util.current_engine_index = nil
|
||||||
|
|
||||||
|
-- Find the current engine's index in conf.ibus_language_list.
|
||||||
|
-- If it is not there, util.current_engine_index will be nil.
|
||||||
|
for k, v in pairs(conf.ibus_language_list) do
|
||||||
|
if (v["ibus_engine"] == util.current_engine) then
|
||||||
|
util.current_engine_index = k
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get current xkbmap
|
||||||
|
awful.spawn.easy_async(
|
||||||
|
"setxkbmap -query",
|
||||||
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
|
util.current_xkbmap = string.match(stdout, "layout:%s+(%w+)")
|
||||||
|
|
||||||
|
-- When everything is done, run callback if it is given.
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Set engine to language_index.
|
||||||
|
-- calls util.get(callback) when done.
|
||||||
|
util.set = function(language_index, callback)
|
||||||
|
-- engine is an index of the language list above
|
||||||
|
|
||||||
|
local engine = conf.ibus_language_list[language_index]["ibus_engine"]
|
||||||
|
|
||||||
|
-- Get required engine, if one is given
|
||||||
|
local requires_engine
|
||||||
|
for k, v in pairs(conf.ibus_language_list) do
|
||||||
|
if (v["ibus_engine"] == engine) then
|
||||||
|
requires_engine = v["requires_engine"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If a required xkb engine is given, but it is not active, switch to it before switching to the target
|
||||||
|
if (requires_engine ~= util.current_engine) and (requires_engine ~= nil) then
|
||||||
|
awful.spawn.easy_async(
|
||||||
|
"ibus engine " .. requires_engine,
|
||||||
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
|
awful.spawn.easy_async(
|
||||||
|
"ibus engine " .. engine,
|
||||||
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
|
util.get(callback)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
else
|
||||||
|
awful.spawn.easy_async(
|
||||||
|
"ibus engine " .. engine,
|
||||||
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
|
util.get(callback)
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Calls util.set(callback) with next language in list.
|
||||||
|
util.next = function(callback)
|
||||||
|
if (util.current_engine_index == nil) or (util.current_engine_index == #conf.ibus_language_list) then
|
||||||
|
util.current_engine_index = 1
|
||||||
|
else
|
||||||
|
util.current_engine_index = util.current_engine_index + 1
|
||||||
|
end
|
||||||
|
util.set(util.current_engine_index, callback)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return util
|
|
@ -0,0 +1,72 @@
|
||||||
|
local util = req_rel(..., "util")
|
||||||
|
local widget = {}
|
||||||
|
|
||||||
|
widget.ibus_indicator_text = wibox.widget.textbox("??")
|
||||||
|
widget.ibus_indicator_text.valign = "center"
|
||||||
|
widget.ibus_indicator_text.align = "center"
|
||||||
|
widget.ibus_indicator_text.font = "Hack NF 14"
|
||||||
|
|
||||||
|
widget.xkb_indicator_text = wibox.widget.textbox("??")
|
||||||
|
widget.xkb_indicator_text.valign = "center"
|
||||||
|
widget.xkb_indicator_text.align = "center"
|
||||||
|
widget.xkb_indicator_text.font = "Hack NF 10"
|
||||||
|
|
||||||
|
|
||||||
|
widget.widget = wibox.widget {
|
||||||
|
{
|
||||||
|
{ -- Right spacer
|
||||||
|
widget = wibox.widget.separator,
|
||||||
|
color = beautiful.color.transparent,
|
||||||
|
forced_width = beautiful.dpi(3)
|
||||||
|
},
|
||||||
|
|
||||||
|
wibox.widget {
|
||||||
|
widget.ibus_indicator_text,
|
||||||
|
widget.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
|
||||||
|
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.update = function()
|
||||||
|
widget.ibus_indicator_text.markup = conf.ibus_language_list[util.current_engine_index]["indicator_code"]
|
||||||
|
widget.xkb_indicator_text.markup = util.current_xkbmap
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Update every 2 seconds, just in case.
|
||||||
|
widget.update_timer = gears.timer {
|
||||||
|
timeout = 2,
|
||||||
|
call_now = false,
|
||||||
|
autostart = true,
|
||||||
|
single_shot = false,
|
||||||
|
callback = function ()
|
||||||
|
util.get(widget.update)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget
|
|
@ -0,0 +1,6 @@
|
||||||
|
return {
|
||||||
|
widgets = {
|
||||||
|
mpc = require("modules.mpc.widget").widget
|
||||||
|
},
|
||||||
|
keybinds = require("modules.mpc.keybinds")
|
||||||
|
}
|
|
@ -1,51 +1,53 @@
|
||||||
|
local mpc = req_rel(..., "util")
|
||||||
|
|
||||||
return gears.table.join(
|
return gears.table.join(
|
||||||
awful.key( {}, "XF86AudioPrev",
|
awful.key( {}, "XF86AudioPrev",
|
||||||
function ()
|
function ()
|
||||||
bin.mpc.command("prev")
|
mpc.mpc_command("prev")
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Previous track",
|
description = "Previous track",
|
||||||
group = "MPD"
|
group = "MPC"
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
awful.key( {}, "XF86AudioPlay",
|
awful.key( {}, "XF86AudioPlay",
|
||||||
function ()
|
function ()
|
||||||
bin.mpc.command("toggle")
|
mpc.mpc_command("toggle")
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Play/Pause",
|
description = "Play/Pause",
|
||||||
group = "MPD"
|
group = "MPC"
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
awful.key( {}, "XF86AudioNext",
|
awful.key( {}, "XF86AudioNext",
|
||||||
function ()
|
function ()
|
||||||
bin.mpc.command("next")
|
mpc.mpc_command("next")
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Next track",
|
description = "Next track",
|
||||||
group = "MPD"
|
group = "MPC"
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
awful.key( {"Mod4"}, "XF86AudioRaiseVolume",
|
awful.key( {"Mod4"}, "XF86AudioRaiseVolume",
|
||||||
function ()
|
function ()
|
||||||
bin.mpc.command("vol +5")
|
mpc.mpc_command("vol +5")
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Volume up",
|
description = "Volume up",
|
||||||
group = "MPD"
|
group = "MPC"
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
awful.key( {"Mod4"}, "XF86AudioLowerVolume",
|
awful.key( {"Mod4"}, "XF86AudioLowerVolume",
|
||||||
function ()
|
function ()
|
||||||
bin.mpc.command("vol -5")
|
mpc.mpc_command("vol -5")
|
||||||
end,
|
end,
|
||||||
{
|
{
|
||||||
description = "Volume down",
|
description = "Volume down",
|
||||||
group = "MPD"
|
group = "MPC"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
|
@ -0,0 +1,19 @@
|
||||||
|
local util = {}
|
||||||
|
|
||||||
|
util.mpc_command = function(command, callback)
|
||||||
|
awful.spawn.easy_async(
|
||||||
|
"mpc --host " .. conf.mpd_host .. " " .. command,
|
||||||
|
callback
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
util.mpc_watch = function(command, timeout, callback, widget)
|
||||||
|
awful.widget.watch(
|
||||||
|
"mpc --host " .. conf.mpd_host .. " " .. command,
|
||||||
|
timeout,
|
||||||
|
callback,
|
||||||
|
widget
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return util
|
|
@ -1,3 +1,4 @@
|
||||||
|
local mpc = req_rel(..., "util")
|
||||||
local mpc_widget = {}
|
local mpc_widget = {}
|
||||||
|
|
||||||
mpc_widget.title = wibox.widget.textbox("MPD is not")
|
mpc_widget.title = wibox.widget.textbox("MPD is not")
|
||||||
|
@ -64,7 +65,6 @@ mpc_widget.right = wibox.widget {
|
||||||
layout = wibox.container.background,
|
layout = wibox.container.background,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mpc_widget.widget = wibox.widget {
|
mpc_widget.widget = wibox.widget {
|
||||||
{
|
{
|
||||||
{ -- Right spacer
|
{ -- Right spacer
|
||||||
|
@ -87,7 +87,7 @@ mpc_widget.widget = wibox.widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mpc_widget.widget:connect_signal("mouse::enter", function(result)
|
mpc_widget.widget:connect_signal("mouse::enter",function(result)
|
||||||
mpc_widget.widget.bg = beautiful.color.bar.hover_bg
|
mpc_widget.widget.bg = beautiful.color.bar.hover_bg
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ end)
|
||||||
mpc_widget.widget:connect_signal("button::press",
|
mpc_widget.widget:connect_signal("button::press",
|
||||||
function(_, _, _, button, mods)
|
function(_, _, _, button, mods)
|
||||||
if (button == 3) or (button == 1)then
|
if (button == 3) or (button == 1)then
|
||||||
bin.mpc.command("toggle")
|
mpc.mpc_command("toggle")
|
||||||
end
|
end
|
||||||
mpc_widget.readupdate()
|
mpc_widget.readupdate()
|
||||||
end
|
end
|
||||||
|
@ -109,9 +109,9 @@ mpc_widget.widget:connect_signal("button::press",
|
||||||
mpc_widget.right:connect_signal("button::press",
|
mpc_widget.right:connect_signal("button::press",
|
||||||
function(_, _, _, button, mods)
|
function(_, _, _, button, mods)
|
||||||
if (button == 4) then -- Scroll up
|
if (button == 4) then -- Scroll up
|
||||||
bin.mpc.command("prev")
|
mpc.mpc_command("prev")
|
||||||
elseif (button == 5) then -- Scroll down
|
elseif (button == 5) then -- Scroll down
|
||||||
bin.mpc.command("next")
|
mpc.mpc_command("next")
|
||||||
end
|
end
|
||||||
|
|
||||||
mpc_widget.readupdate()
|
mpc_widget.readupdate()
|
||||||
|
@ -122,72 +122,77 @@ mpc_widget.right:connect_signal("button::press",
|
||||||
mpc_widget.left:connect_signal("button::press",
|
mpc_widget.left:connect_signal("button::press",
|
||||||
function(_, _, _, button, mods)
|
function(_, _, _, button, mods)
|
||||||
if (button == 4) then -- Scroll up
|
if (button == 4) then -- Scroll up
|
||||||
bin.mpc.command("volume +5")
|
mpc.mpc_command("volume +5")
|
||||||
elseif (button == 5) then -- Scroll down
|
elseif (button == 5) then -- Scroll down
|
||||||
bin.mpc.command("volume -5")
|
mpc.mpc_command("volume -5")
|
||||||
end
|
end
|
||||||
mpc_widget.readupdate()
|
mpc_widget.readupdate()
|
||||||
end
|
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()
|
mpc_widget.readupdate = function()
|
||||||
bin.mpc.command("current --format \"title=%title% artist=%artist%\"",
|
-- Update title and artist
|
||||||
|
mpc.mpc_command("current --format \"title=%title% artist=%artist%\"",
|
||||||
function(stdout, stderr, exitreason, exitcode)
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
mpc_widget.update(stdout)
|
if (stdout == "") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mpc_widget.title.markup = string.match(stdout, "title=(.*)artist=")
|
||||||
|
mpc_widget.artist.markup = string.match(stdout, "artist=(.*)")
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
bin.mpc.command("status",
|
-- Update status
|
||||||
|
mpc.mpc_command("status",
|
||||||
function(stdout, stderr, exitreason, exitcode)
|
function(stdout, stderr, exitreason, exitcode)
|
||||||
mpc_widget.update_status(stdout)
|
local play = string.match(stdout, "(%[playing)") or false
|
||||||
|
local pause = string.match(stdout, "(%[paused)") or false
|
||||||
|
local 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
|
||||||
|
|
||||||
|
local volume = string.match(stdout, "volume: (%d?%d?%d)%%")
|
||||||
|
if (volume) then
|
||||||
|
mpc_widget.volume.markup = volume .. "%"
|
||||||
|
else
|
||||||
|
mpc_widget.volume.markup = ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- The time here is super short because the --wait option is used in mpc.
|
-- Short delay here, the --wait option makes mpc block until
|
||||||
-- It will not return a response until changes are seen.
|
-- a change is detected.
|
||||||
bin.mpc.watch("current --wait", 0.01, function(_, stdout) mpc_widget.readupdate() end, mpc_widget.widget)
|
mpc.mpc_watch(
|
||||||
bin.mpc.watch("current", 1, function(_, stdout) mpc_widget.readupdate() end, mpc_widget.widget)
|
"current --wait",
|
||||||
|
0.01,
|
||||||
|
function(_, stdout)
|
||||||
|
mpc_widget.readupdate()
|
||||||
|
end,
|
||||||
|
mpc_widget.widget
|
||||||
|
)
|
||||||
|
|
||||||
|
mpc.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
|
-- Make sure you do an initial read, otherwise the widget will
|
||||||
-- not update until a change occurs.
|
-- not update until a change occurs.
|
||||||
mpc_widget.readupdate()
|
mpc_widget.readupdate()
|
||||||
|
|
||||||
|
|
||||||
return mpc_widget.widget
|
return mpc_widget
|
63
rc.lua
63
rc.lua
|
@ -1,6 +1,4 @@
|
||||||
-- Load libaries.
|
-- AwesomeWM core
|
||||||
-- We only need to load these once.
|
|
||||||
-- These are global variables, all scripts can access them
|
|
||||||
gears = require("gears")
|
gears = require("gears")
|
||||||
awful = require("awful")
|
awful = require("awful")
|
||||||
naughty = require("naughty")
|
naughty = require("naughty")
|
||||||
|
@ -11,31 +9,73 @@ configuration_dir = gears.filesystem.get_configuration_dir()
|
||||||
require("awful.autofocus")
|
require("awful.autofocus")
|
||||||
|
|
||||||
|
|
||||||
|
-- A "relative require" hack. Does the same thing as `require,`
|
||||||
|
-- But takes a relative path.
|
||||||
|
-- Called with req_rel(..., "module")
|
||||||
|
function req_rel(ddd, modname)
|
||||||
|
local parent_folder = (ddd):match("(.-)[^%.]+$")
|
||||||
|
return require(parent_folder .. modname)
|
||||||
|
end
|
||||||
|
|
||||||
-- Quick debug function
|
-- Quick debug function
|
||||||
debug_message = function(msg)
|
debug_message = function(msg)
|
||||||
naughty.notify({title = "Debug message:", text = tostring(msg)})
|
naughty.notify({title = "Debug message:", text = tostring(msg)})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- These must be loaded in order.
|
-- These must be loaded in order.
|
||||||
-- Make sure you've created conf.lua!
|
-- Make sure you've created conf.lua!
|
||||||
conf = require("conf")
|
conf = require("conf")
|
||||||
conf.sound_dir = configuration_dir .. "theme/resources/sounds/"
|
|
||||||
conf.icon_dir = configuration_dir .. "theme/resources/icons/"
|
|
||||||
|
|
||||||
layoutmanager = require("desktop.layoutmanager")
|
layoutmanager = require("desktop.layoutmanager")
|
||||||
layoutmanager.layouts = conf.layouts
|
layoutmanager.layouts = conf.layouts
|
||||||
|
|
||||||
bin = require("bin")
|
bin = require("bin")
|
||||||
wrapper = require("wrapper")
|
wrapper = require("wrapper")
|
||||||
wrapper.ibus.set(1)
|
|
||||||
|
|
||||||
beautiful.init(require("theme"))
|
beautiful.init(require("theme"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Load key bindings
|
||||||
|
local binds = require("binds")
|
||||||
|
local keys = binds.keys
|
||||||
|
local buttons = binds.buttons
|
||||||
|
|
||||||
|
-- Load modules
|
||||||
|
modules = {}
|
||||||
|
for k, v in ipairs({
|
||||||
|
"mpc",
|
||||||
|
"ibus"
|
||||||
|
}) do
|
||||||
|
modules[v] = require("modules." .. v)
|
||||||
|
|
||||||
|
-- If module defines keybinds, load keybinds.
|
||||||
|
if (modules[v]["keybinds"] ~= nil) then
|
||||||
|
keys = gears.table.join(
|
||||||
|
keys,
|
||||||
|
modules[v]["keybinds"]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Run all module init methods
|
||||||
|
for _, mod in ipairs(modules) do
|
||||||
|
if (mod["init"] ~= nil) then
|
||||||
|
mod["init"]()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- Finalize keys
|
||||||
|
root.keys(keys)
|
||||||
|
root.buttons(buttons)
|
||||||
|
|
||||||
desktop = require("desktop")
|
desktop = require("desktop")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Autostart
|
-- Autostart
|
||||||
for i, v in ipairs(conf.startup_commands) do
|
for i, v in ipairs(conf.startup_commands) do
|
||||||
awful.spawn(v)
|
awful.spawn(v)
|
||||||
|
@ -55,15 +95,6 @@ terminal = conf.terminal
|
||||||
menubar.utils.terminal = terminal
|
menubar.utils.terminal = terminal
|
||||||
|
|
||||||
|
|
||||||
------------------
|
|
||||||
-- Load Modules --
|
|
||||||
------------------
|
|
||||||
-- Load key bindings
|
|
||||||
local binds = require("binds")
|
|
||||||
root.keys(binds.keys)
|
|
||||||
root.buttons(binds.buttons)
|
|
||||||
|
|
||||||
|
|
||||||
-- Load client methods
|
-- Load client methods
|
||||||
awful.rules.rules = require("clients.rules")
|
awful.rules.rules = require("clients.rules")
|
||||||
dofile(configuration_dir .. "clients/signals.lua")
|
dofile(configuration_dir .. "clients/signals.lua")
|
||||||
|
|
102
wrapper/ibus.lua
102
wrapper/ibus.lua
|
@ -1,102 +0,0 @@
|
||||||
local ibus = {}
|
|
||||||
|
|
||||||
|
|
||||||
ibus.current_engine = ""
|
|
||||||
ibus.current_engine_index = nil
|
|
||||||
|
|
||||||
ibus.ibus_indicator_text = wibox.widget.textbox("??")
|
|
||||||
ibus.ibus_indicator_text.valign = "center"
|
|
||||||
ibus.ibus_indicator_text.align = "center"
|
|
||||||
ibus.ibus_indicator_text.font = "Hack NF 14"
|
|
||||||
|
|
||||||
ibus.xkb_indicator_text = wibox.widget.textbox("??")
|
|
||||||
ibus.xkb_indicator_text.valign = "center"
|
|
||||||
ibus.xkb_indicator_text.align = "center"
|
|
||||||
ibus.xkb_indicator_text.font = "Hack NF 10"
|
|
||||||
|
|
||||||
|
|
||||||
ibus.get = function(callback)
|
|
||||||
awful.spawn.easy_async("ibus engine", function(stdout, stderr, exitreason, exitcode)
|
|
||||||
-- Get current ibus engine, remove newlines from output.
|
|
||||||
ibus.current_engine = string.gsub(stdout, "\n", "")
|
|
||||||
ibus.current_engine_index = nil
|
|
||||||
|
|
||||||
-- Find the current engine's index in conf.ibus_language_list.
|
|
||||||
-- If it is not there, ibus.current_engine_index will be nil.
|
|
||||||
for k, v in pairs(conf.ibus_language_list) do
|
|
||||||
if (v["ibus_engine"] == ibus.current_engine) then
|
|
||||||
ibus.current_engine_index = k
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if callback then
|
|
||||||
callback()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
ibus.update_indicator = function()
|
|
||||||
-- Update indicators
|
|
||||||
awful.spawn.easy_async("setxkbmap -query" , function(stdout, stderr, exitreason, exitcode)
|
|
||||||
ibus.ibus_indicator_text.markup = conf.ibus_language_list[ibus.current_engine_index]["indicator_code"]
|
|
||||||
ibus.xkb_indicator_text.markup = string.match(stdout, "layout:%s+(%w+)")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
ibus.set = function(language_index, callback)
|
|
||||||
-- engine is an index of the language list above
|
|
||||||
|
|
||||||
engine = conf.ibus_language_list[language_index]["ibus_engine"]
|
|
||||||
|
|
||||||
-- Get required engine, if one is given
|
|
||||||
local requires_engine
|
|
||||||
for k, v in pairs(conf.ibus_language_list) do
|
|
||||||
if (v["ibus_engine"] == engine) then
|
|
||||||
requires_engine = v["requires_engine"]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- If a required xkb engine is given, but it is not active, switch to it before switching to the target
|
|
||||||
if (requires_engine ~= ibus.current_engine) and (requires_engine ~= nil) then
|
|
||||||
awful.spawn.easy_async("ibus engine " .. requires_engine, function(stdout, stderr, exitreason, exitcode)
|
|
||||||
awful.spawn.easy_async("ibus engine " .. engine, function(stdout, stderr, exitreason, exitcode)
|
|
||||||
ibus.update_indicator()
|
|
||||||
ibus.get(callback)
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
else
|
|
||||||
awful.spawn.easy_async("ibus engine " .. engine, function(stdout, stderr, exitreason, exitcode)
|
|
||||||
ibus.update_indicator()
|
|
||||||
ibus.get(callback)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
ibus.next = function(callback)
|
|
||||||
if (ibus.current_engine_index == nil) or (ibus.current_engine_index == #conf.ibus_language_list) then
|
|
||||||
ibus.current_engine_index = 1
|
|
||||||
else
|
|
||||||
ibus.current_engine_index = ibus.current_engine_index + 1
|
|
||||||
end
|
|
||||||
ibus.set(ibus.current_engine_index, callback)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update the language indicator
|
|
||||||
ibus.update_timer = gears.timer {
|
|
||||||
timeout = 2,
|
|
||||||
call_now = false,
|
|
||||||
autostart = true,
|
|
||||||
single_shot = false,
|
|
||||||
|
|
||||||
callback = function()
|
|
||||||
ibus.get(
|
|
||||||
function()
|
|
||||||
ibus.update_indicator()
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
return ibus
|
|
|
@ -2,6 +2,5 @@ return {
|
||||||
backlight = require("wrapper.backlight"),
|
backlight = require("wrapper.backlight"),
|
||||||
volume = require("wrapper.volume"),
|
volume = require("wrapper.volume"),
|
||||||
sound = require("wrapper.sound"),
|
sound = require("wrapper.sound"),
|
||||||
ibus = require("wrapper.ibus"),
|
|
||||||
mdadm = require("wrapper.mdadm")
|
mdadm = require("wrapper.mdadm")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue