1
0
Fork 0
mirror of https://github.com/lcpz/awesome-copycats.git synced 2025-01-10 17:58:09 +00:00
awesome-copycats/rc.lua.copland

412 lines
13 KiB
Plaintext

--[[
Copland Awesome WM config
github.com/copycat-killer
--]]
-- {{{ Required libraries
local gears = require("gears")
local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
local wibox = require("wibox")
local beautiful = require("beautiful")
local naughty = require("naughty")
local lain = require("lain")
local eminent = require("eminent")
-- }}}
-- Error handling
require("myrc.errors")
-- STARTUP apps
require("settings.startup")
-- {{{ Variable definitions
-- beautiful init
beautiful.init(os.getenv("HOME") .. "/.config/awesome/themes/copland/theme.lua")
-- variables
require("settings.variables")
-- lain
lain.layout.termfair.nmaster = 3
lain.layout.termfair.ncol = 1
lain.layout.centerfair.nmaster = 3
lain.layout.centerfair.ncol = 1
-- Tags and layouts
require("settings.tags")
-- }}}
-- {{{ Wallpaper
require("stock.wallpaper")
-- }}}
-- {{{ Menu
require("freedesktop/freedesktop")
-- }}}
-- {{{ Wibox
markup = lain.util.markup
blue = beautiful.fg_focus
-- Textclock
mytextclock = awful.widget.textclock("<span font='Tamsyn 5'> </span>%H:%M ")
-- Calendar
lain.widgets.calendar:attach(mytextclock)
--[[ Mail IMAP check
-- commented because it needs to be set before use
mailwidget = lain.widgets.imap({
timeout = 180,
server = "server",
mail = "mail",
password = "keyring get mail",
settings = function()
mail = ""
count = ""
if mailcount > 0 then
mail = "<span font='Tamsyn 5'> </span>Mail "
count = mailcount .. " "
end
widget:set_markup(markup(blue, mail) .. count)
end
})
]]
-- MPD
mpdicon = wibox.widget.imagebox(beautiful.play)
mpdwidget = lain.widgets.mpd({
settings = function()
if mpd_now.state == "play" then
title = mpd_now.title
artist = " - " .. mpd_now.artist .. markup("#333333", " |<span font='Tamsyn 3'> </span>")
mpdicon:set_image(beautiful.play)
elseif mpd_now.state == "pause" then
title = "mpd "
artist = "paused" .. markup("#333333", " |<span font='Tamsyn 3'> </span>")
mpdicon:set_image(beautiful.pause)
else
title = ""
artist = ""
mpdicon:set_image()
end
widget:set_markup(markup(blue, title) .. artist)
end
})
-- Battery
baticon = wibox.widget.imagebox(beautiful.bat)
batbar = awful.widget.progressbar()
batbar:set_color(beautiful.fg_normal)
batbar:set_width(55)
batbar:set_ticks(true)
batbar:set_ticks_size(6)
batbar:set_background_color(beautiful.bg_normal)
batmargin = wibox.layout.margin(batbar, 2, 7)
batmargin:set_top(6)
batmargin:set_bottom(6)
batupd = lain.widgets.bat({
settings = function()
if bat_now.perc == "N/A" then
bat_perc = 100
baticon:set_image(beautiful.ac)
else
bat_perc = tonumber(bat_now.perc)
if bat_perc > 50 then
batbar:set_color(beautiful.fg_normal)
baticon:set_image(beautiful.bat)
elseif bat_perc > 15 then
batbar:set_color(beautiful.fg_normal)
baticon:set_image(beautiful.bat_low)
else
batbar:set_color("#EB8F8F")
baticon:set_image(beautiful.bat_no)
end
end
batbar:set_value(bat_perc / 100)
end
})
batwidget = wibox.widget.background(batmargin)
batwidget:set_bgimage(beautiful.widget_bg)
-- /home fs
diskicon = wibox.widget.imagebox(beautiful.disk)
diskbar = awful.widget.progressbar()
diskbar:set_color(beautiful.fg_normal)
diskbar:set_width(55)
diskbar:set_ticks(true)
diskbar:set_ticks_size(6)
diskbar:set_background_color(beautiful.bg_normal)
diskmargin = wibox.layout.margin(diskbar, 2, 7)
diskmargin:set_top(6)
diskmargin:set_bottom(6)
fshomeupd = lain.widgets.fs({
partition = "/home",
settings = function()
if fs_now.used < 90 then
diskbar:set_color(beautiful.fg_normal)
else
diskbar:set_color("#EB8F8F")
end
diskbar:set_value(fs_now.used / 100)
end
})
diskwidget = wibox.widget.background(diskmargin)
diskwidget:set_bgimage(beautiful.widget_bg)
-- ALSA volume bar
volicon = wibox.widget.imagebox(beautiful.vol)
volume = lain.widgets.alsabar({width = 55, ticks = true, ticks_size = 6,
settings = function()
if volume_now.status == "off" then
volicon:set_image(beautiful.vol_mute)
elseif volume_now.level == 0 then
volicon:set_image(beautiful.vol_no)
elseif volume_now.level <= 50 then
volicon:set_image(beautiful.vol_low)
else
volicon:set_image(beautiful.vol)
end
end,
colors =
{
background = beautiful.bg_normal,
mute = "#EB8F8F",
unmute = beautiful.fg_normal
}})
volmargin = wibox.layout.margin(volume.bar, 2, 7)
volmargin:set_top(6)
volmargin:set_bottom(6)
volumewidget = wibox.widget.background(volmargin)
volumewidget:set_bgimage(beautiful.widget_bg)
-- Weather
yawn = lain.widgets.yawn(123456)
-- Separators
spr = wibox.widget.textbox(' ')
small_spr = wibox.widget.textbox('<span font="Tamsyn 4"> </span>')
bar_spr = wibox.widget.textbox('<span font="Tamsyn 3"> </span>' .. markup("#333333", "|") .. '<span font="Tamsyn 3"> </span>')
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
require("stock.taglist")
require("stock.tasklist")
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s, height = 18 })
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(small_spr)
left_layout:add(mylayoutbox[s])
left_layout:add(bar_spr)
left_layout:add(mytaglist[s])
left_layout:add(spr)
left_layout:add(mypromptbox[s])
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
right_layout:add(small_spr)
right_layout:add(mpdicon)
right_layout:add(mpdwidget)
--right_layout:add(mailwidget)
right_layout:add(baticon)
right_layout:add(batwidget)
right_layout:add(bar_spr)
right_layout:add(diskicon)
right_layout:add(diskwidget)
right_layout:add(bar_spr)
right_layout:add(volicon)
right_layout:add(volumewidget)
right_layout:add(bar_spr)
right_layout:add(mytextclock)
-- Now bring it all together (with the tasklist in the middle)
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_middle(mytasklist[s])
layout:set_right(right_layout)
mywibox[s]:set_widget(layout)
end
-- }}}
-- Bindings
require("settings.binds")
-- {{{ Key bindings
globalkeys = awful.util.table.join(globalkeys,
-- Show/Hide Wibox
awful.key({ modkey }, "b", function ()
mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible
end),
-- On the fly useless gaps change
awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end),
awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end),
-- Rename tag
awful.key({ altkey, "Shift" }, "r", function () lain.util.rename_tag(mypromptbox) end),
-- Widgets popups
awful.key({ altkey, }, "c", function () lain.widgets.calendar:show(7) end),
awful.key({ altkey, }, "h", function () fshomeupd.show(7) end),
awful.key({ altkey, }, "w", function () yawn.show(7) end),
-- ALSA volume control
awful.key({ altkey }, "Up",
function ()
awful.util.spawn("amixer -q set " .. volume.channel .. " " .. volume.step .. "+")
volume.notify()
end),
awful.key({ altkey }, "Down",
function ()
awful.util.spawn("amixer -q set " .. volume.channel .. " " .. volume.step .. "-")
volume.notify()
end),
awful.key({ altkey }, "m",
function ()
awful.util.spawn("amixer -q set " .. volume.channel .. " playback toggle")
volume.notify()
end),
awful.key({ altkey, "Control" }, "m",
function ()
awful.util.spawn("amixer -q set " .. volume.channel .. " playback 100%")
volume.notify()
end)
)
clientkeys = awful.util.table.join(clientkeys,
awful.key({ altkey, "Shift" }, "m", lain.util.magnify_client )
)
-- Set keys
root.keys(globalkeys)
-- }}}
-- Rules
require("settings.rules")
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
-- Enable sloppy focus
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup and not c.size_hints.user_position
and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
local titlebars_enabled = true
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
-- buttons for the titlebar
local buttons = awful.util.table.join(
awful.button({ }, 1, function()
client.focus = c
c:raise()
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
client.focus = c
c:raise()
awful.mouse.client.resize(c)
end)
)
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
right_layout:add(awful.titlebar.widget.floatingbutton(c))
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
right_layout:add(awful.titlebar.widget.stickybutton(c))
right_layout:add(awful.titlebar.widget.ontopbutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
-- The title goes in the middle
local middle_layout = wibox.layout.flex.horizontal()
local title = awful.titlebar.widget.titlewidget(c)
title:set_align("center")
middle_layout:add(title)
middle_layout:buttons(buttons)
-- Now bring it all together
local layout = wibox.layout.align.horizontal()
layout:set_right(right_layout)
layout:set_middle(middle_layout)
awful.titlebar(c,{size=16}):set_widget(layout)
end
end)
-- No border for maximized clients
client.connect_signal("focus",
function(c)
if c.maximized_horizontal == true and c.maximized_vertical == true then
c.border_width = 0
c.border_color = beautiful.border_normal
else
c.border_width = beautiful.border_width
c.border_color = beautiful.border_focus
end
end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
-- {{{ Arrange signal handler
for s = 1, screen.count() do screen[s]:connect_signal("arrange", function ()
local clients = awful.client.visible(s)
local layout = awful.layout.getname(awful.layout.get(s))
if #clients > 0 then -- Fine grained borders and floaters control
for _, c in pairs(clients) do -- Floaters always have borders
if awful.client.floating.get(c) or layout == "floating" then
c.border_width = beautiful.border_width
-- No borders with only one visible client
elseif #clients == 1 or layout == "max" then
clients[1].border_width = 0
else
c.border_width = beautiful.border_width
end
end
end
end)
end
-- }}}