Giant blob of minor changes
[dotfiles/.git] / .config / awesome / themes / multicolor / theme.lua
1 --[[
2
3      Multicolor Awesome WM theme 2.0
4      github.com/lcpz
5
6 --]]
7
8 local gears = require("gears")
9 local lain  = require("lain")
10 local awful = require("awful")
11 local wibox = require("wibox")
12 local dpi   = require("beautiful.xresources").apply_dpi
13
14 local os = os
15 local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
16
17 local theme                                     = {}
18 theme.confdir                                   = os.getenv("HOME") .. "/.config/awesome/themes/multicolor"
19 theme.wallpaper                                 = theme.confdir .. "/wall.png"
20 theme.font                                      = "Terminus 8"
21 theme.menu_bg_normal                            = "#000000"
22 theme.menu_bg_focus                             = "#000000"
23 theme.bg_normal                                 = "#000000"
24 theme.bg_focus                                  = "#000000"
25 theme.bg_urgent                                 = "#000000"
26 theme.fg_normal                                 = "#aaaaaa"
27 theme.fg_focus                                  = "#ff8c00"
28 theme.fg_urgent                                 = "#af1d18"
29 theme.fg_minimize                               = "#ffffff"
30 theme.border_width                              = dpi(1)
31 theme.border_normal                             = "#1c2022"
32 theme.border_focus                              = "#606060"
33 theme.border_marked                             = "#3ca4d8"
34 theme.menu_border_width                         = 0
35 theme.menu_width                                = dpi(130)
36 theme.menu_submenu_icon                         = theme.confdir .. "/icons/submenu.png"
37 theme.menu_fg_normal                            = "#aaaaaa"
38 theme.menu_fg_focus                             = "#ff8c00"
39 theme.menu_bg_normal                            = "#050505dd"
40 theme.menu_bg_focus                             = "#050505dd"
41 theme.widget_temp                               = theme.confdir .. "/icons/temp.png"
42 theme.widget_uptime                             = theme.confdir .. "/icons/ac.png"
43 theme.widget_cpu                                = theme.confdir .. "/icons/cpu.png"
44 theme.widget_weather                            = theme.confdir .. "/icons/dish.png"
45 theme.widget_fs                                 = theme.confdir .. "/icons/fs.png"
46 theme.widget_mem                                = theme.confdir .. "/icons/mem.png"
47 theme.widget_note                               = theme.confdir .. "/icons/note.png"
48 theme.widget_note_on                            = theme.confdir .. "/icons/note_on.png"
49 theme.widget_netdown                            = theme.confdir .. "/icons/net_down.png"
50 theme.widget_netup                              = theme.confdir .. "/icons/net_up.png"
51 theme.widget_mail                               = theme.confdir .. "/icons/mail.png"
52 theme.widget_batt                               = theme.confdir .. "/icons/bat.png"
53 theme.widget_clock                              = theme.confdir .. "/icons/clock.png"
54 theme.widget_vol                                = theme.confdir .. "/icons/spkr.png"
55 theme.taglist_squares_sel                       = theme.confdir .. "/icons/square_a.png"
56 theme.taglist_squares_unsel                     = theme.confdir .. "/icons/square_b.png"
57 theme.tasklist_plain_task_name                  = true
58 theme.tasklist_disable_icon                     = true
59 theme.useless_gap                               = 0
60 theme.layout_tile                               = theme.confdir .. "/icons/tile.png"
61 theme.layout_tilegaps                           = theme.confdir .. "/icons/tilegaps.png"
62 theme.layout_tileleft                           = theme.confdir .. "/icons/tileleft.png"
63 theme.layout_tilebottom                         = theme.confdir .. "/icons/tilebottom.png"
64 theme.layout_tiletop                            = theme.confdir .. "/icons/tiletop.png"
65 theme.layout_fairv                              = theme.confdir .. "/icons/fairv.png"
66 theme.layout_fairh                              = theme.confdir .. "/icons/fairh.png"
67 theme.layout_spiral                             = theme.confdir .. "/icons/spiral.png"
68 theme.layout_dwindle                            = theme.confdir .. "/icons/dwindle.png"
69 theme.layout_max                                = theme.confdir .. "/icons/max.png"
70 theme.layout_fullscreen                         = theme.confdir .. "/icons/fullscreen.png"
71 theme.layout_magnifier                          = theme.confdir .. "/icons/magnifier.png"
72 theme.layout_floating                           = theme.confdir .. "/icons/floating.png"
73 theme.titlebar_close_button_normal              = theme.confdir .. "/icons/titlebar/close_normal.png"
74 theme.titlebar_close_button_focus               = theme.confdir .. "/icons/titlebar/close_focus.png"
75 theme.titlebar_minimize_button_normal           = theme.confdir .. "/icons/titlebar/minimize_normal.png"
76 theme.titlebar_minimize_button_focus            = theme.confdir .. "/icons/titlebar/minimize_focus.png"
77 theme.titlebar_ontop_button_normal_inactive     = theme.confdir .. "/icons/titlebar/ontop_normal_inactive.png"
78 theme.titlebar_ontop_button_focus_inactive      = theme.confdir .. "/icons/titlebar/ontop_focus_inactive.png"
79 theme.titlebar_ontop_button_normal_active       = theme.confdir .. "/icons/titlebar/ontop_normal_active.png"
80 theme.titlebar_ontop_button_focus_active        = theme.confdir .. "/icons/titlebar/ontop_focus_active.png"
81 theme.titlebar_sticky_button_normal_inactive    = theme.confdir .. "/icons/titlebar/sticky_normal_inactive.png"
82 theme.titlebar_sticky_button_focus_inactive     = theme.confdir .. "/icons/titlebar/sticky_focus_inactive.png"
83 theme.titlebar_sticky_button_normal_active      = theme.confdir .. "/icons/titlebar/sticky_normal_active.png"
84 theme.titlebar_sticky_button_focus_active       = theme.confdir .. "/icons/titlebar/sticky_focus_active.png"
85 theme.titlebar_floating_button_normal_inactive  = theme.confdir .. "/icons/titlebar/floating_normal_inactive.png"
86 theme.titlebar_floating_button_focus_inactive   = theme.confdir .. "/icons/titlebar/floating_focus_inactive.png"
87 theme.titlebar_floating_button_normal_active    = theme.confdir .. "/icons/titlebar/floating_normal_active.png"
88 theme.titlebar_floating_button_focus_active     = theme.confdir .. "/icons/titlebar/floating_focus_active.png"
89 theme.titlebar_maximized_button_normal_inactive = theme.confdir .. "/icons/titlebar/maximized_normal_inactive.png"
90 theme.titlebar_maximized_button_focus_inactive  = theme.confdir .. "/icons/titlebar/maximized_focus_inactive.png"
91 theme.titlebar_maximized_button_normal_active   = theme.confdir .. "/icons/titlebar/maximized_normal_active.png"
92 theme.titlebar_maximized_button_focus_active    = theme.confdir .. "/icons/titlebar/maximized_focus_active.png"
93
94 local markup = lain.util.markup
95
96 -- Textclock
97 os.setlocale(os.getenv("LANG")) -- to localize the clock
98 local clockicon = wibox.widget.imagebox(theme.widget_clock)
99 local mytextclock = wibox.widget.textclock(markup("#7788af", "%A %d %B ") .. markup("#ab7367", ">") .. markup("#de5e1e", " %I:%M %p "))
100 mytextclock.font = theme.font
101
102 -- Calendar
103 theme.cal = lain.widget.cal({
104     attach_to = { mytextclock },
105     notification_preset = {
106         font = "Terminus 10",
107         fg   = theme.fg_normal,
108         bg   = theme.bg_normal
109     }
110 })
111
112 -- Weather
113 local weathericon = wibox.widget.imagebox(theme.widget_weather)
114 theme.weather = lain.widget.weather({
115     city_id = 5102466, -- placeholder (London)
116     notification_preset = { font = "Terminus 10", fg = theme.fg_normal },
117     weather_na_markup = markup.fontfg(theme.font, "#eca4c4", "N/A "),
118     settings = function()
119         descr = weather_now["weather"][1]["description"]:lower()
120         units = math.floor(weather_now["main"]["temp"])
121         widget:set_markup(markup.fontfg(theme.font, "#eca4c4", descr .. " @ " .. units .. "°C "))
122     end
123 })
124
125 -- / fs
126 --[[ commented because it needs Gio/Glib >= 2.54
127 local fsicon = wibox.widget.imagebox(theme.widget_fs)
128 theme.fs = lain.widget.fs({
129     notification_preset = { font = "Terminus 10", fg = theme.fg_normal },
130     settings  = function()
131         widget:set_markup(markup.fontfg(theme.font, "#80d9d8", string.format("%.1f", fs_now["/"].used) .. "% "))
132     end
133 })
134 --]]
135
136 -- Mail IMAP check
137 --[[ commented because it needs to be set before use
138 local mailicon = wibox.widget.imagebox()
139 theme.mail = lain.widget.imap({
140     timeout  = 180,
141     server   = "server",
142     mail     = "mail",
143     password = "keyring get mail",
144     settings = function()
145         if mailcount > 0 then
146             mailicon:set_image(theme.widget_mail)
147             widget:set_markup(markup.fontfg(theme.font, "#cccccc", mailcount .. " "))
148         else
149             widget:set_text("")
150             --mailicon:set_image() -- not working in 4.0
151             mailicon._private.image = nil
152             mailicon:emit_signal("widget::redraw_needed")
153             mailicon:emit_signal("widget::layout_changed")
154         end
155     end
156 })
157 --]]
158
159 -- CPU
160 local cpuicon = wibox.widget.imagebox(theme.widget_cpu)
161 local cpu = lain.widget.cpu({
162     settings = function()
163         widget:set_markup(markup.fontfg(theme.font, "#e33a6e", cpu_now.usage .. "% "))
164     end
165 })
166
167 -- Coretemp
168 local tempicon = wibox.widget.imagebox(theme.widget_temp)
169 local temp = lain.widget.temp({
170     settings = function()
171         widget:set_markup(markup.fontfg(theme.font, "#f1af5f", coretemp_now .. "°C "))
172     end
173 })
174
175 -- Battery
176 local baticon = wibox.widget.imagebox(theme.widget_batt)
177 local bat = lain.widget.bat({
178     settings = function()
179         local perc = bat_now.perc ~= "N/A" and bat_now.perc .. "%" or bat_now.perc
180
181         if bat_now.ac_status == 1 then
182             perc = perc .. " plug"
183         end
184
185         widget:set_markup(markup.fontfg(theme.font, theme.fg_normal, perc .. " "))
186     end
187 })
188
189 -- ALSA volume
190 local volicon = wibox.widget.imagebox(theme.widget_vol)
191 theme.volume = lain.widget.alsa({
192     settings = function()
193         if volume_now.status == "off" then
194             volume_now.level = volume_now.level .. "M"
195         end
196
197         widget:set_markup(markup.fontfg(theme.font, "#7493d2", volume_now.level .. "% "))
198     end
199 })
200
201 -- Net
202 local netdownicon = wibox.widget.imagebox(theme.widget_netdown)
203 local netdowninfo = wibox.widget.textbox()
204 local netupicon = wibox.widget.imagebox(theme.widget_netup)
205 local netupinfo = lain.widget.net({
206     settings = function()
207         if iface ~= "network off" and
208            string.match(theme.weather.widget.text, "N/A")
209         then
210             theme.weather.update()
211         end
212
213         widget:set_markup(markup.fontfg(theme.font, "#e54c62", net_now.sent .. " "))
214         netdowninfo:set_markup(markup.fontfg(theme.font, "#87af5f", net_now.received .. " "))
215     end
216 })
217
218 -- MEM
219 local memicon = wibox.widget.imagebox(theme.widget_mem)
220 local memory = lain.widget.mem({
221     settings = function()
222         widget:set_markup(markup.fontfg(theme.font, "#e0da37", mem_now.used .. "M "))
223     end
224 })
225
226 -- MPD
227 local mpdicon = wibox.widget.imagebox()
228 theme.mpd = lain.widget.mpd({
229     settings = function()
230         mpd_notification_preset = {
231             text = string.format("%s [%s] - %s\n%s", mpd_now.artist,
232                    mpd_now.album, mpd_now.date, mpd_now.title)
233         }
234
235         if mpd_now.state == "play" then
236             artist = mpd_now.artist .. " > "
237             title  = mpd_now.title .. " "
238             mpdicon:set_image(theme.widget_note_on)
239         elseif mpd_now.state == "pause" then
240             artist = "mpd "
241             title  = "paused "
242         else
243             artist = ""
244             title  = ""
245             --mpdicon:set_image() -- not working in 4.0
246             mpdicon._private.image = nil
247             mpdicon:emit_signal("widget::redraw_needed")
248             mpdicon:emit_signal("widget::layout_changed")
249         end
250         widget:set_markup(markup.fontfg(theme.font, "#e54c62", artist) .. markup.fontfg(theme.font, "#b2b2b2", title))
251     end
252 })
253
254 function theme.at_screen_connect(s)
255     -- Quake application
256     s.quake = lain.util.quake({ app = awful.util.terminal })
257
258     -- If wallpaper is a function, call it with the screen
259     local wallpaper = theme.wallpaper
260     if type(wallpaper) == "function" then
261         wallpaper = wallpaper(s)
262     end
263     gears.wallpaper.maximized(wallpaper, s, true)
264
265     -- Tags
266     awful.tag(awful.util.tagnames, s, awful.layout.layouts)
267
268     -- Create a promptbox for each screen
269     s.mypromptbox = awful.widget.prompt()
270     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
271     -- We need one layoutbox per screen.
272     s.mylayoutbox = awful.widget.layoutbox(s)
273     s.mylayoutbox:buttons(my_table.join(
274                            awful.button({}, 1, function () awful.layout.inc( 1) end),
275                            awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
276                            awful.button({}, 3, function () awful.layout.inc(-1) end),
277                            awful.button({}, 4, function () awful.layout.inc( 1) end),
278                            awful.button({}, 5, function () awful.layout.inc(-1) end)))
279     -- Create a taglist widget
280     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
281
282     -- Create a tasklist widget
283     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
284
285     -- Create the wibox
286     s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(19), bg = theme.bg_normal, fg = theme.fg_normal })
287
288     -- Add widgets to the wibox
289     s.mywibox:setup {
290         layout = wibox.layout.align.horizontal,
291         { -- Left widgets
292             layout = wibox.layout.fixed.horizontal,
293             --s.mylayoutbox,
294             s.mytaglist,
295             s.mypromptbox,
296             mpdicon,
297             theme.mpd.widget,
298         },
299         --s.mytasklist, -- Middle widget
300         nil,
301         { -- Right widgets
302             layout = wibox.layout.fixed.horizontal,
303             wibox.widget.systray(),
304             --mailicon,
305             --theme.mail.widget,
306             netdownicon,
307             netdowninfo,
308             netupicon,
309             netupinfo.widget,
310             volicon,
311             theme.volume.widget,
312             memicon,
313             memory.widget,
314             cpuicon,
315             cpu.widget,
316             --fsicon,
317             --theme.fs.widget,
318             weathericon,
319             theme.weather.widget,
320             --tempicon,
321             --temp.widget,
322             --baticon,
323             --bat.widget,
324             clockicon,
325             mytextclock,
326         },
327     }
328
329     -- Create the bottom wibox
330     s.mybottomwibox = awful.wibar({ position = "bottom", screen = s, border_width = 0, height = dpi(20), bg = theme.bg_normal, fg = theme.fg_normal })
331
332     -- Add widgets to the bottom wibox
333     s.mybottomwibox:setup {
334         layout = wibox.layout.align.horizontal,
335         { -- Left widgets
336             layout = wibox.layout.fixed.horizontal,
337         },
338         s.mytasklist, -- Middle widget
339         { -- Right widgets
340             layout = wibox.layout.fixed.horizontal,
341             s.mylayoutbox,
342         },
343     }
344 end
345
346 return theme