From 09a5ea3bf9d0483874dfc6695626955b7e162a4e Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 29 Jan 2017 14:05:35 +0100 Subject: [PATCH] rainbow modular; closes #148 --- themes/rainbow/theme.lua | 202 +++++++++++++++++++++++++++++++++++---- 1 file changed, 183 insertions(+), 19 deletions(-) diff --git a/themes/rainbow/theme.lua b/themes/rainbow/theme.lua index 668aa73..ac86774 100644 --- a/themes/rainbow/theme.lua +++ b/themes/rainbow/theme.lua @@ -1,18 +1,22 @@ --[[ - - Rainbow Awesome WM config 2.0 - github.com/copycat-killer - + + Rainbow Awesome WM theme 2.0 + github.com/copycat-killer + --]] -local theme = {} +local gears = require("gears") +local lain = require("lain") +local awful = require("awful") +local wibox = require("wibox") +local os = { getenv = os.getenv, setlocale = os.setlocale } +local theme = {} theme.default_dir = require("awful.util").get_themes_dir() .. "default" theme.dir = os.getenv("HOME") .. "/.config/awesome/themes/rainbow" theme.wallpaper = theme.dir .. "/wall.png" - -theme.font = "Tamsyn 10.5" +theme.font = "Misc Tamsyn 10.5" theme.fg_normal = "#9E9E9E" theme.fg_focus = "#EBEBFF" theme.bg_normal = "#242424" @@ -24,10 +28,8 @@ theme.border_normal = "#242424" theme.border_focus = "#EBEBFF" theme.taglist_fg_focus = "#EDEFFF" theme.taglist_bg_focus = "#242424" - theme.menu_height = 16 theme.menu_width = 140 - theme.ocol = "" theme.tasklist_sticky = theme.ocol .. "[S]" theme.tasklist_ontop = theme.ocol .. "[T]" @@ -39,9 +41,7 @@ theme.menu_awesome_icon = theme.dir .."/icons/awesome.pn theme.menu_submenu_icon = theme.dir .."/icons/submenu.png" theme.taglist_squares_sel = theme.dir .. "/icons/square_sel.png" theme.taglist_squares_unsel = theme.dir .. "/icons/square_unsel.png" - theme.useless_gap = 8 - theme.layout_txt_tile = "[t]" theme.layout_txt_tileleft = "[l]" theme.layout_txt_tilebottom = "[b]" @@ -54,14 +54,6 @@ theme.layout_txt_max = "[m]" theme.layout_txt_fullscreen = "[F]" theme.layout_txt_magnifier = "[M]" theme.layout_txt_floating = "[*]" - --- lain related -theme.layout_txt_cascade = "[cascade]" -theme.layout_txt_cascadetile = "[cascadetile]" -theme.layout_txt_centerwork = "[centerwork]" -theme.layout_txt_termfair = "[termfair]" -theme.layout_txt_centerfair = "[centerfair]" - theme.titlebar_close_button_normal = theme.default_dir.."/titlebar/close_normal.png" theme.titlebar_close_button_focus = theme.default_dir.."/titlebar/close_focus.png" theme.titlebar_minimize_button_normal = theme.default_dir.."/titlebar/minimize_normal.png" @@ -83,4 +75,176 @@ theme.titlebar_maximized_button_focus_inactive = theme.default_dir.."/titlebar/ theme.titlebar_maximized_button_normal_active = theme.default_dir.."/titlebar/maximized_normal_active.png" theme.titlebar_maximized_button_focus_active = theme.default_dir.."/titlebar/maximized_focus_active.png" +-- lain related +theme.layout_txt_cascade = "[cascade]" +theme.layout_txt_cascadetile = "[cascadetile]" +theme.layout_txt_centerwork = "[centerwork]" +theme.layout_txt_termfair = "[termfair]" +theme.layout_txt_centerfair = "[centerfair]" + +local markup = lain.util.markup +local white = theme.fg_focus +local gray = theme.fg_normal + +-- Textclock +local mytextclock = wibox.widget.textclock(markup(white, " %H:%M ")) +mytextclock.font = theme.font + +-- Calendar +lain.widgets.calendar({ + attach_to = { mytextclock }, + notification_preset = { + font = "Misc Tamsyn 11", + fg = white, + bg = theme.bg_normal + } +}) + +--[[ Mail IMAP check +-- commented because it needs to be set before use +local mail = lain.widgets.imap({ + timeout = 180, + server = "server", + mail = "mail", + password = "keyring get mail", + settings = function() + mail_notification_preset.fg = white + + mail = "" + count = "" + + if mailcount > 0 then + mail = "Mail " + count = mailcount .. " " + end + + widget:set_markup(markup.font(theme.font, markup(gray, mail) .. markup(white, count))) + end +}) +]] + +-- MPD +theme.mpd = lain.widgets.mpd({ + settings = function() + mpd_notification_preset.fg = white + + artist = mpd_now.artist .. " " + title = mpd_now.title .. " " + + if mpd_now.state == "pause" then + artist = "mpd " + title = "paused " + elseif mpd_now.state == "stop" then + artist = "" + title = "" + end + + widget:set_markup(markup.font(theme.font, markup(gray, artist) .. markup(white, title))) + end +}) + +-- /home fs +theme.fs = lain.widgets.fs({ + partition = "/home", + options = "--exclude-type=tmpfs", + notification_preset = { fg = white, bg = theme.bg_normal, font = "Misc Tamsyn 10.5" }, + settings = function() + hdd = "" + p = "" + + if tonumber(fs_now.used) >= 90 then + hdd = " Hdd " + p = fs_now.used .. " " + end + + widget:set_markup(markup.font(theme.font, markup(gray, hdd) .. markup(white, p))) + end +}) + +-- ALSA volume bar +theme.volume = lain.widgets.alsabar({ + ticks = true, width = 67, + notification_preset = { font = theme.font } +}) +local volumebg = wibox.container.background(theme.volume.bar, "#585858", gears.shape.rectangle) +local volumewidget = wibox.container.margin(volumebg, 7, 7, 5, 5) + +-- Weather +theme.weather = lain.widgets.weather({ + city_id = 2643743, -- placeholder (London) + notification_preset = { font = theme.font, fg = white } +}) + +-- Separators +local first = wibox.widget.textbox(markup.font("Misc Tamsyn 4", " ")) +local spr = wibox.widget.textbox(' ') + +local function update_txt_layoutbox(s) + -- Writes a string representation of the current layout in a textbox widget + local txt_l = theme["layout_txt_" .. awful.layout.getname(awful.layout.get(s))] or "" + s.mytxtlayoutbox:set_text(txt_l) +end + +function theme.at_screen_connect(s) + -- Quake application + s.quake = lain.util.quake({ app = awful.util.terminal }) + + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + theme.wallpaper = theme.wallpaper(s) + end + gears.wallpaper.maximized(theme.wallpaper, s, true) + + -- Tags + awful.tag(awful.util.tagnames, s, awful.layout.layouts) + + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + + -- Textual layoutbox + s.mytxtlayoutbox = wibox.widget.textbox(theme["layout_txt_" .. awful.layout.getname(awful.layout.get(s))]) + awful.tag.attached_connect_signal(s, "property::selected", function () update_txt_layoutbox(s) end) + awful.tag.attached_connect_signal(s, "property::layout", function () update_txt_layoutbox(s) end) + s.mytxtlayoutbox: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 + s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons) + + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons) + + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s, height = 18, bg = theme.bg_normal, fg = theme.fg_normal }) + + -- Add widgets to the wibox + s.mywibox:setup { + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + small_spr, + s.mytaglist, + spr, + s.mytxtlayoutbox, + --spr, + s.mypromptbox, + spr, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + wibox.widget.systray(), + spr, + theme.mpd.widget, + --mail.widget, + theme.fs.widget, + volumewidget, + mytextclock, + }, + } +end + return theme