mirror of
https://github.com/lcpz/awesome-copycats.git
synced 2026-03-23 22:15:11 +00:00
copland: unify widget naming
This commit is contained in:
parent
5ff41cc188
commit
0fd47e47d0
|
|
@ -59,7 +59,7 @@ run_once({ "urxvtd", "unclutter -root" })
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Variable definitions
|
-- {{{ Variable definitions
|
||||||
local chosen_theme = "multicolor"
|
local chosen_theme = "copland"
|
||||||
local modkey = "Mod4"
|
local modkey = "Mod4"
|
||||||
local altkey = "Mod1"
|
local altkey = "Mod1"
|
||||||
local terminal = "urxvtc" or "xterm"
|
local terminal = "urxvtc" or "xterm"
|
||||||
|
|
@ -349,66 +349,66 @@ globalkeys = awful.util.table.join(
|
||||||
|
|
||||||
-- Widgets popups
|
-- Widgets popups
|
||||||
awful.key({ altkey, }, "c", function () lain.widget.calendar.show(7) end),
|
awful.key({ altkey, }, "c", function () lain.widget.calendar.show(7) end),
|
||||||
awful.key({ altkey, }, "h", function () if beautiful.fs then beautiful.fs.show(7) end end),
|
awful.key({ altkey, }, "h", function () if beautiful.widgets.fs then beautiful.widgets.fs.update.show(7) end end),
|
||||||
awful.key({ altkey, }, "w", function () if beautiful.weather then beautiful.weather.show(7) end end),
|
awful.key({ altkey, }, "w", function () if beautiful.widgets.weather then beautiful.widgets.weather.show(7) end end),
|
||||||
|
|
||||||
-- ALSA volume control
|
-- ALSA volume control
|
||||||
awful.key({ altkey }, "Up",
|
awful.key({ altkey }, "Up",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("amixer set %s 1%%+", beautiful.volume.channel))
|
os.execute(string.format("amixer set %s 1%%+", beautiful.widgets.vol.channel))
|
||||||
beautiful.volume.update()
|
beautiful.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey }, "Down",
|
awful.key({ altkey }, "Down",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("amixer set %s 1%%-", beautiful.volume.channel))
|
os.execute(string.format("amixer set %s 1%%-", beautiful.widgets.vol.channel))
|
||||||
beautiful.volume.update()
|
beautiful.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey }, "m",
|
awful.key({ altkey }, "m",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("amixer set %s toggle", beautiful.volume.togglechannel or beautiful.volume.channel))
|
os.execute(string.format("amixer set %s toggle", beautiful.widgets.vol.togglechannel or beautiful.widgets.vol.channel))
|
||||||
beautiful.volume.update()
|
beautiful.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey, "Control" }, "m",
|
awful.key({ altkey, "Control" }, "m",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("amixer set %s 100%%", beautiful.volume.channel))
|
os.execute(string.format("amixer set %s 100%%", beautiful.widgets.vol.channel))
|
||||||
beautiful.volume.update()
|
beautiful.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
|
|
||||||
awful.key({ altkey, "Control" }, "0",
|
awful.key({ altkey, "Control" }, "0",
|
||||||
function ()
|
function ()
|
||||||
os.execute(string.format("amixer -q set %s 0%%", beautiful.volume.channel))
|
os.execute(string.format("amixer -q set %s 0%%", beautiful.widgets.vol.channel))
|
||||||
beautiful.volume.update()
|
beautiful.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
|
|
||||||
-- MPD control
|
-- MPD control
|
||||||
awful.key({ altkey, "Control" }, "Up",
|
awful.key({ altkey, "Control" }, "Up",
|
||||||
function ()
|
function ()
|
||||||
awful.spawn.with_shell("mpc toggle")
|
awful.spawn.with_shell("mpc toggle")
|
||||||
beautiful.mpd.update()
|
beautiful.widgets.mpd.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey, "Control" }, "Down",
|
awful.key({ altkey, "Control" }, "Down",
|
||||||
function ()
|
function ()
|
||||||
awful.spawn.with_shell("mpc stop")
|
awful.spawn.with_shell("mpc stop")
|
||||||
beautiful.mpd.update()
|
beautiful.widgets.mpd.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey, "Control" }, "Left",
|
awful.key({ altkey, "Control" }, "Left",
|
||||||
function ()
|
function ()
|
||||||
awful.spawn.with_shell("mpc prev")
|
awful.spawn.with_shell("mpc prev")
|
||||||
beautiful.mpd.update()
|
beautiful.widgets.mpd.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey, "Control" }, "Right",
|
awful.key({ altkey, "Control" }, "Right",
|
||||||
function ()
|
function ()
|
||||||
awful.spawn.with_shell("mpc next")
|
awful.spawn.with_shell("mpc next")
|
||||||
beautiful.mpd.update()
|
beautiful.widgets.mpd.update()
|
||||||
end),
|
end),
|
||||||
awful.key({ altkey }, "0",
|
awful.key({ altkey }, "0",
|
||||||
function ()
|
function ()
|
||||||
local common = { text = "MPD widget ", position = "top_middle", timeout = 2 }
|
local common = { text = "MPD widget ", position = "top_middle", timeout = 2 }
|
||||||
if beautiful.mpd.timer.started then
|
if beautiful.widgets.mpd.timer.started then
|
||||||
beautiful.mpd.timer:stop()
|
beautiful.widgets.mpd.timer:stop()
|
||||||
common.text = common.text .. lain.util.markup.bold("OFF")
|
common.text = common.text .. lain.util.markup.bold("OFF")
|
||||||
else
|
else
|
||||||
beautiful.mpd.timer:start()
|
beautiful.widgets.mpd.timer:start()
|
||||||
common.text = common.text .. lain.util.markup.bold("ON")
|
common.text = common.text .. lain.util.markup.bold("ON")
|
||||||
end
|
end
|
||||||
naughty.notify(common)
|
naughty.notify(common)
|
||||||
|
|
|
||||||
|
|
@ -92,14 +92,18 @@ local blue = theme.fg_focus
|
||||||
local red = "#EB8F8F"
|
local red = "#EB8F8F"
|
||||||
local green = "#8FEB8F"
|
local green = "#8FEB8F"
|
||||||
|
|
||||||
|
-- global widgets table
|
||||||
|
theme.widgets = {}
|
||||||
|
|
||||||
-- Textclock
|
-- Textclock
|
||||||
--os.setlocale(os.getenv("LANG")) -- to localize the clock
|
--os.setlocale(os.getenv("LANG")) -- to localize the clock
|
||||||
local mytextclock = wibox.widget.textclock("<span font='Tamzen 5'> </span>%H:%M ")
|
theme.widgets.mytextclock = {}
|
||||||
mytextclock.font = theme.font
|
theme.widgets.mytextclock.widget = wibox.widget.textclock("<span font='Tamzen 5'> </span>%H:%M ")
|
||||||
|
theme.widgets.mytextclock.widget.font = theme.font
|
||||||
|
|
||||||
-- Calendar
|
-- Calendar
|
||||||
lain.widget.calendar({
|
lain.widget.calendar({
|
||||||
attach_to = { mytextclock },
|
attach_to = { theme.widgets.mytextclock.widget },
|
||||||
notification_preset = {
|
notification_preset = {
|
||||||
font = "Tamzen 11",
|
font = "Tamzen 11",
|
||||||
fg = theme.fg_normal,
|
fg = theme.fg_normal,
|
||||||
|
|
@ -109,7 +113,7 @@ lain.widget.calendar({
|
||||||
|
|
||||||
--[[ Mail IMAP check
|
--[[ Mail IMAP check
|
||||||
-- commented because it needs to be set before use
|
-- commented because it needs to be set before use
|
||||||
local mail = lain.widget.imap({
|
theme.widgets.mail = lain.widget.imap({
|
||||||
timeout = 180,
|
timeout = 180,
|
||||||
server = "server",
|
server = "server",
|
||||||
mail = "mail",
|
mail = "mail",
|
||||||
|
|
@ -129,32 +133,33 @@ local mail = lain.widget.imap({
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
-- MPD
|
-- MPD
|
||||||
local mpdicon = wibox.widget.imagebox()
|
theme.widgets.mpd = lain.widget.mpd({
|
||||||
theme.mpd = lain.widget.mpd({
|
|
||||||
settings = function()
|
settings = function()
|
||||||
if mpd_now.state == "play" then
|
if mpd_now.state == "play" then
|
||||||
title = mpd_now.title
|
title = mpd_now.title
|
||||||
artist = " " .. mpd_now.artist .. markup("#333333", " <span font='Tamzen 2'> </span>|<span font='Tamzen 5'> </span>")
|
artist = " " .. mpd_now.artist .. markup("#333333", " <span font='Tamzen 2'> </span>|<span font='Tamzen 5'> </span>")
|
||||||
mpdicon:set_image(theme.play)
|
theme.widgets.mpd.icon:set_image(theme.play)
|
||||||
elseif mpd_now.state == "pause" then
|
elseif mpd_now.state == "pause" then
|
||||||
title = "mpd "
|
title = "mpd "
|
||||||
artist = "paused" .. markup("#333333", " |<span font='Tamzen 5'> </span>")
|
artist = "paused" .. markup("#333333", " |<span font='Tamzen 5'> </span>")
|
||||||
mpdicon:set_image(theme.pause)
|
theme.widgets.mpd.icon:set_image(theme.pause)
|
||||||
else
|
else
|
||||||
title = ""
|
title = ""
|
||||||
artist = ""
|
artist = ""
|
||||||
mpdicon._private.image = nil
|
theme.widgets.mpd.icon._private.image = nil
|
||||||
mpdicon:emit_signal("widget::redraw_needed")
|
theme.widgets.mpd.icon:emit_signal("widget::redraw_needed")
|
||||||
mpdicon:emit_signal("widget::layout_changed")
|
theme.widgets.mpd.icon:emit_signal("widget::layout_changed")
|
||||||
end
|
end
|
||||||
|
|
||||||
widget:set_markup(markup.font(theme.font, markup(blue, title) .. artist))
|
widget:set_markup(markup.font(theme.font, markup(blue, title) .. artist))
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
theme.widgets.mpd.icon = wibox.widget.imagebox()
|
||||||
|
|
||||||
-- Battery
|
-- Battery
|
||||||
local baticon = wibox.widget.imagebox(theme.bat)
|
theme.widgets.bat = {}
|
||||||
local batbar = wibox.widget {
|
theme.widgets.bat.icon = wibox.widget.imagebox(theme.bat)
|
||||||
|
theme.widgets.bat.bar = wibox.widget {
|
||||||
forced_height = 1,
|
forced_height = 1,
|
||||||
forced_width = 59,
|
forced_width = 59,
|
||||||
color = theme.fg_normal,
|
color = theme.fg_normal,
|
||||||
|
|
@ -165,44 +170,45 @@ local batbar = wibox.widget {
|
||||||
ticks_size = 6,
|
ticks_size = 6,
|
||||||
widget = wibox.widget.progressbar,
|
widget = wibox.widget.progressbar,
|
||||||
}
|
}
|
||||||
local batupd = lain.widget.bat({
|
theme.widgets.bat.update = lain.widget.bat({
|
||||||
settings = function()
|
settings = function()
|
||||||
if bat_now.status == "N/A" or type(bat_now.perc) ~= "number" then return end
|
if bat_now.status == "N/A" or type(bat_now.perc) ~= "number" then return end
|
||||||
|
|
||||||
if bat_now.status == "Charging" then
|
if bat_now.status == "Charging" then
|
||||||
baticon:set_image(theme.ac)
|
theme.widgets.bat.icon:set_image(theme.ac)
|
||||||
if bat_now.perc >= 98 then
|
if bat_now.perc >= 98 then
|
||||||
batbar:set_color(green)
|
theme.widgets.bat.bar:set_color(green)
|
||||||
elseif bat_now.perc > 50 then
|
elseif bat_now.perc > 50 then
|
||||||
batbar:set_color(theme.fg_normal)
|
theme.widgets.bat.bar:set_color(theme.fg_normal)
|
||||||
elseif bat_now.perc > 15 then
|
elseif bat_now.perc > 15 then
|
||||||
batbar:set_color(theme.fg_normal)
|
theme.widgets.bat.bar:set_color(theme.fg_normal)
|
||||||
else
|
else
|
||||||
batbar:set_color(red)
|
theme.widgets.bat.bar:set_color(red)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if bat_now.perc >= 98 then
|
if bat_now.perc >= 98 then
|
||||||
batbar:set_color(green)
|
theme.widgets.bat.bar:set_color(green)
|
||||||
elseif bat_now.perc > 50 then
|
elseif bat_now.perc > 50 then
|
||||||
batbar:set_color(theme.fg_normal)
|
theme.widgets.bat.bar:set_color(theme.fg_normal)
|
||||||
baticon:set_image(theme.bat)
|
theme.widgets.bat.icon:set_image(theme.bat)
|
||||||
elseif bat_now.perc > 15 then
|
elseif bat_now.perc > 15 then
|
||||||
batbar:set_color(theme.fg_normal)
|
theme.widgets.bat.bar:set_color(theme.fg_normal)
|
||||||
baticon:set_image(theme.bat_low)
|
theme.widgets.bat.icon:set_image(theme.bat_low)
|
||||||
else
|
else
|
||||||
batbar:set_color(red)
|
theme.widgets.bat.bar:set_color(red)
|
||||||
baticon:set_image(theme.bat_no)
|
theme.widgets.bat.icon:set_image(theme.bat_no)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
batbar:set_value(bat_now.perc / 100)
|
theme.widgets.bat.bar:set_value(bat_now.perc / 100)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
local batbg = wibox.container.background(batbar, "#474747", gears.shape.rectangle)
|
theme.widgets.bat.bg = wibox.container.background(theme.widgets.bat.bar, "#474747", gears.shape.rectangle)
|
||||||
local batwidget = wibox.container.margin(batbg, 2, 7, 4, 4)
|
theme.widgets.bat.widget = wibox.container.margin(theme.widgets.bat.bg, 2, 7, 4, 4)
|
||||||
|
|
||||||
-- /home fs
|
-- /home fs
|
||||||
local fsicon = wibox.widget.imagebox(theme.disk)
|
theme.widgets.fs = {}
|
||||||
local fsbar = wibox.widget {
|
theme.widgets.fs.icon = wibox.widget.imagebox(theme.disk)
|
||||||
|
theme.widgets.fs.bar = wibox.widget {
|
||||||
forced_height = 1,
|
forced_height = 1,
|
||||||
forced_width = 59,
|
forced_width = 59,
|
||||||
color = theme.fg_normal,
|
color = theme.fg_normal,
|
||||||
|
|
@ -213,37 +219,36 @@ local fsbar = wibox.widget {
|
||||||
ticks_size = 6,
|
ticks_size = 6,
|
||||||
widget = wibox.widget.progressbar,
|
widget = wibox.widget.progressbar,
|
||||||
}
|
}
|
||||||
theme.fs = lain.widget.fs({
|
theme.widgets.fs.update = lain.widget.fs({
|
||||||
partition = "/home",
|
partition = "/home",
|
||||||
options = "--exclude-type=tmpfs",
|
options = "--exclude-type=tmpfs",
|
||||||
notification_preset = { fg = theme.fg_normal, bg = theme.bg_normal, font = "Tamzen 10.5" },
|
notification_preset = { fg = theme.fg_normal, bg = theme.bg_normal, font = "Tamzen 10.5" },
|
||||||
settings = function()
|
settings = function()
|
||||||
if tonumber(fs_now.used) < 90 then
|
if tonumber(fs_now.used) < 90 then
|
||||||
fsbar:set_color(theme.fg_normal)
|
theme.widgets.fs.bar:set_color(theme.fg_normal)
|
||||||
else
|
else
|
||||||
fsbar:set_color("#EB8F8F")
|
theme.widgets.fs.bar:set_color("#EB8F8F")
|
||||||
end
|
end
|
||||||
fsbar:set_value(fs_now.used / 100)
|
theme.widgets.fs.bar:set_value(fs_now.used / 100)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
local fsbg = wibox.container.background(fsbar, "#474747", gears.shape.rectangle)
|
theme.widgets.fs.bg = wibox.container.background(theme.widgets.fs.bar, "#474747", gears.shape.rectangle)
|
||||||
local fswidget = wibox.container.margin(fsbg, 2, 7, 4, 4)
|
theme.widgets.fs.widget = wibox.container.margin(theme.widgets.fs.bg, 2, 7, 4, 4)
|
||||||
|
|
||||||
-- ALSA volume bar
|
-- ALSA volume bar
|
||||||
local volicon = wibox.widget.imagebox(theme.vol)
|
theme.widgets.vol = lain.widget.alsabar({
|
||||||
theme.volume = lain.widget.alsabar({
|
|
||||||
width = 59, border_width = 0, ticks = true, ticks_size = 6,
|
width = 59, border_width = 0, ticks = true, ticks_size = 6,
|
||||||
notification_preset = { font = theme.font },
|
notification_preset = { font = theme.font },
|
||||||
--togglechannel = "IEC958,3",
|
--togglechannel = "IEC958,3",
|
||||||
settings = function()
|
settings = function()
|
||||||
if volume_now.status == "off" then
|
if volume_now.status == "off" then
|
||||||
volicon:set_image(theme.vol_mute)
|
theme.widgets.vol.icon:set_image(theme.vol_mute)
|
||||||
elseif volume_now.level == 0 then
|
elseif volume_now.level == 0 then
|
||||||
volicon:set_image(theme.vol_no)
|
theme.widgets.vol.icon:set_image(theme.vol_no)
|
||||||
elseif volume_now.level <= 50 then
|
elseif volume_now.level <= 50 then
|
||||||
volicon:set_image(theme.vol_low)
|
theme.widgets.vol.icon:set_image(theme.vol_low)
|
||||||
else
|
else
|
||||||
volicon:set_image(theme.vol)
|
theme.widgets.vol.icon:set_image(theme.vol)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
colors = {
|
colors = {
|
||||||
|
|
@ -252,33 +257,34 @@ theme.volume = lain.widget.alsabar({
|
||||||
unmute = theme.fg_normal
|
unmute = theme.fg_normal
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
theme.volume.tooltip.wibox.fg = theme.fg_focus
|
theme.widgets.vol.icon = wibox.widget.imagebox(theme.vol)
|
||||||
theme.volume.bar:buttons(awful.util.table.join (
|
theme.widgets.vol.tooltip.wibox.fg = theme.fg_focus
|
||||||
|
theme.widgets.vol.bar:buttons(awful.util.table.join (
|
||||||
awful.button({}, 1, function()
|
awful.button({}, 1, function()
|
||||||
awful.spawn.with_shell(string.format("%s -e alsamixer", awful.util.terminal))
|
awful.spawn.with_shell(string.format("%s -e alsamixer", awful.util.terminal))
|
||||||
end),
|
end),
|
||||||
awful.button({}, 2, function()
|
awful.button({}, 2, function()
|
||||||
awful.spawn(string.format("%s set %s 100%%", theme.volume.cmd, theme.volume.channel))
|
awful.spawn(string.format("%s set %s 100%%", theme.widgets.vol.cmd, theme.widgets.vol.channel))
|
||||||
theme.volume.update()
|
theme.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
awful.button({}, 3, function()
|
awful.button({}, 3, function()
|
||||||
awful.spawn(string.format("%s set %s toggle", theme.volume.cmd, theme.volume.togglechannel or theme.volume.channel))
|
awful.spawn(string.format("%s set %s toggle", theme.widgets.vol.cmd, theme.volume.togglechannel or theme.widgets.vol.channel))
|
||||||
theme.volume.update()
|
theme.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
awful.button({}, 4, function()
|
awful.button({}, 4, function()
|
||||||
awful.spawn(string.format("%s set %s 1%%+", theme.volume.cmd, theme.volume.channel))
|
awful.spawn(string.format("%s set %s 1%%+", theme.widgets.vol.cmd, theme.widgets.vol.channel))
|
||||||
theme.volume.update()
|
theme.widgets.vol.update()
|
||||||
end),
|
end),
|
||||||
awful.button({}, 5, function()
|
awful.button({}, 5, function()
|
||||||
awful.spawn(string.format("%s set %s 1%%-", theme.volume.cmd, theme.volume.channel))
|
awful.spawn(string.format("%s set %s 1%%-", theme.widgets.vol.cmd, theme.widgets.vol.channel))
|
||||||
theme.volume.update()
|
theme.widgets.vol.update()
|
||||||
end)
|
end)
|
||||||
))
|
))
|
||||||
local volumebg = wibox.container.background(theme.volume.bar, "#474747", gears.shape.rectangle)
|
theme.widgets.vol.bg = wibox.container.background(theme.widgets.vol.bar, "#474747", gears.shape.rectangle)
|
||||||
local volumewidget = wibox.container.margin(volumebg, 2, 7, 4, 4)
|
theme.widgets.vol.widget = wibox.container.margin(theme.widgets.vol.bg, 2, 7, 4, 4)
|
||||||
|
|
||||||
-- Weather
|
-- Weather
|
||||||
theme.weather = lain.widget.weather({
|
theme.widgets.weather = lain.widget.weather({
|
||||||
city_id = 2643743, -- placeholder (London)
|
city_id = 2643743, -- placeholder (London)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -340,18 +346,18 @@ function theme.at_screen_connect(s)
|
||||||
wibox.widget.systray(),
|
wibox.widget.systray(),
|
||||||
small_spr,
|
small_spr,
|
||||||
--mail.widget,
|
--mail.widget,
|
||||||
mpdicon,
|
theme.widgets.mpd.icon,
|
||||||
theme.mpd.widget,
|
theme.widgets.mpd.widget,
|
||||||
baticon,
|
theme.widgets.bat.icon,
|
||||||
batwidget,
|
theme.widgets.bat.widget,
|
||||||
bar_spr,
|
bar_spr,
|
||||||
fsicon,
|
theme.widgets.fs.icon,
|
||||||
fswidget,
|
theme.widgets.fs.widget,
|
||||||
bar_spr,
|
bar_spr,
|
||||||
volicon,
|
theme.widgets.vol.icon,
|
||||||
volumewidget,
|
theme.widgets.vol.widget,
|
||||||
bar_spr,
|
bar_spr,
|
||||||
mytextclock,
|
theme.widgets.mytextclock.widget,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue