Actualizacion maquina principal
[dotfiles/.git] / .config / awesome / themes / holo / theme.lua
1 --[[
2
3      Holo Awesome WM theme 3.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 string, os = string, os
15 local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
16
17 local theme                                     = {}
18 theme.default_dir                               = require("awful.util").get_themes_dir() .. "default"
19 theme.icon_dir                                  = os.getenv("HOME") .. "/.config/awesome/themes/holo/icons"
20 theme.wallpaper                                 = os.getenv("HOME") .. "/.config/awesome/themes/holo/wall.png"
21 theme.font                                      = "Roboto Bold 10"
22 theme.taglist_font                              = "Roboto Condensed Regular 8"
23 theme.fg_normal                                 = "#FFFFFF"
24 theme.fg_focus                                  = "#0099CC"
25 theme.bg_focus                                  = "#303030"
26 theme.bg_normal                                 = "#242424"
27 theme.fg_urgent                                 = "#CC9393"
28 theme.bg_urgent                                 = "#006B8E"
29 theme.border_width                              = dpi(3)
30 theme.border_normal                             = "#252525"
31 theme.border_focus                              = "#0099CC"
32 theme.taglist_fg_focus                          = "#FFFFFF"
33 theme.tasklist_bg_normal                        = "#222222"
34 theme.tasklist_fg_focus                         = "#4CB7DB"
35 theme.menu_height                               = dpi(20)
36 theme.menu_width                                = dpi(160)
37 theme.menu_icon_size                            = dpi(32)
38 theme.awesome_icon                              = theme.icon_dir .. "/awesome_icon_white.png"
39 theme.awesome_icon_launcher                     = theme.icon_dir .. "/awesome_icon.png"
40 theme.taglist_squares_sel                       = theme.icon_dir .. "/square_sel.png"
41 theme.taglist_squares_unsel                     = theme.icon_dir .. "/square_unsel.png"
42 theme.spr_small                                 = theme.icon_dir .. "/spr_small.png"
43 theme.spr_very_small                            = theme.icon_dir .. "/spr_very_small.png"
44 theme.spr_right                                 = theme.icon_dir .. "/spr_right.png"
45 theme.spr_bottom_right                          = theme.icon_dir .. "/spr_bottom_right.png"
46 theme.spr_left                                  = theme.icon_dir .. "/spr_left.png"
47 theme.bar                                       = theme.icon_dir .. "/bar.png"
48 theme.bottom_bar                                = theme.icon_dir .. "/bottom_bar.png"
49 theme.mpdl                                      = theme.icon_dir .. "/mpd.png"
50 theme.mpd_on                                    = theme.icon_dir .. "/mpd_on.png"
51 theme.prev                                      = theme.icon_dir .. "/prev.png"
52 theme.nex                                       = theme.icon_dir .. "/next.png"
53 theme.stop                                      = theme.icon_dir .. "/stop.png"
54 theme.pause                                     = theme.icon_dir .. "/pause.png"
55 theme.play                                      = theme.icon_dir .. "/play.png"
56 theme.clock                                     = theme.icon_dir .. "/clock.png"
57 theme.calendar                                  = theme.icon_dir .. "/cal.png"
58 theme.cpu                                       = theme.icon_dir .. "/cpu.png"
59 theme.net_up                                    = theme.icon_dir .. "/net_up.png"
60 theme.net_down                                  = theme.icon_dir .. "/net_down.png"
61 theme.layout_tile                               = theme.icon_dir .. "/tile.png"
62 theme.layout_tileleft                           = theme.icon_dir .. "/tileleft.png"
63 theme.layout_tilebottom                         = theme.icon_dir .. "/tilebottom.png"
64 theme.layout_tiletop                            = theme.icon_dir .. "/tiletop.png"
65 theme.layout_fairv                              = theme.icon_dir .. "/fairv.png"
66 theme.layout_fairh                              = theme.icon_dir .. "/fairh.png"
67 theme.layout_spiral                             = theme.icon_dir .. "/spiral.png"
68 theme.layout_dwindle                            = theme.icon_dir .. "/dwindle.png"
69 theme.layout_max                                = theme.icon_dir .. "/max.png"
70 theme.layout_fullscreen                         = theme.icon_dir .. "/fullscreen.png"
71 theme.layout_magnifier                          = theme.icon_dir .. "/magnifier.png"
72 theme.layout_floating                           = theme.icon_dir .. "/floating.png"
73 theme.tasklist_plain_task_name                  = true
74 theme.tasklist_disable_icon                     = true
75 theme.useless_gap                               = dpi(4)
76 theme.titlebar_close_button_normal              = theme.default_dir.."/titlebar/close_normal.png"
77 theme.titlebar_close_button_focus               = theme.default_dir.."/titlebar/close_focus.png"
78 theme.titlebar_minimize_button_normal           = theme.default_dir.."/titlebar/minimize_normal.png"
79 theme.titlebar_minimize_button_focus            = theme.default_dir.."/titlebar/minimize_focus.png"
80 theme.titlebar_ontop_button_normal_inactive     = theme.default_dir.."/titlebar/ontop_normal_inactive.png"
81 theme.titlebar_ontop_button_focus_inactive      = theme.default_dir.."/titlebar/ontop_focus_inactive.png"
82 theme.titlebar_ontop_button_normal_active       = theme.default_dir.."/titlebar/ontop_normal_active.png"
83 theme.titlebar_ontop_button_focus_active        = theme.default_dir.."/titlebar/ontop_focus_active.png"
84 theme.titlebar_sticky_button_normal_inactive    = theme.default_dir.."/titlebar/sticky_normal_inactive.png"
85 theme.titlebar_sticky_button_focus_inactive     = theme.default_dir.."/titlebar/sticky_focus_inactive.png"
86 theme.titlebar_sticky_button_normal_active      = theme.default_dir.."/titlebar/sticky_normal_active.png"
87 theme.titlebar_sticky_button_focus_active       = theme.default_dir.."/titlebar/sticky_focus_active.png"
88 theme.titlebar_floating_button_normal_inactive  = theme.default_dir.."/titlebar/floating_normal_inactive.png"
89 theme.titlebar_floating_button_focus_inactive   = theme.default_dir.."/titlebar/floating_focus_inactive.png"
90 theme.titlebar_floating_button_normal_active    = theme.default_dir.."/titlebar/floating_normal_active.png"
91 theme.titlebar_floating_button_focus_active     = theme.default_dir.."/titlebar/floating_focus_active.png"
92 theme.titlebar_maximized_button_normal_inactive = theme.default_dir.."/titlebar/maximized_normal_inactive.png"
93 theme.titlebar_maximized_button_focus_inactive  = theme.default_dir.."/titlebar/maximized_focus_inactive.png"
94 theme.titlebar_maximized_button_normal_active   = theme.default_dir.."/titlebar/maximized_normal_active.png"
95 theme.titlebar_maximized_button_focus_active    = theme.default_dir.."/titlebar/maximized_focus_active.png"
96
97 theme.musicplr = string.format("%s -e ncmpcpp", awful.util.terminal)
98
99 local markup = lain.util.markup
100 local blue   = "#80CCE6"
101 local space3 = markup.font("Roboto 3", " ")
102
103 -- Clock
104 local mytextclock = wibox.widget.textclock(markup("#FFFFFF", space3 .. "%H:%M   " .. markup.font("Roboto 4", " ")))
105 mytextclock.font = theme.font
106 local clock_icon = wibox.widget.imagebox(theme.clock)
107 local clockbg = wibox.container.background(mytextclock, theme.bg_focus, gears.shape.rectangle)
108 local clockwidget = wibox.container.margin(clockbg, dpi(0), dpi(3), dpi(5), dpi(5))
109
110 -- Calendar
111 local mytextcalendar = wibox.widget.textclock(markup.fontfg(theme.font, "#FFFFFF", space3 .. "%d %b " .. markup.font("Roboto 5", " ")))
112 local calendar_icon = wibox.widget.imagebox(theme.calendar)
113 local calbg = wibox.container.background(mytextcalendar, theme.bg_focus, gears.shape.rectangle)
114 local calendarwidget = wibox.container.margin(calbg, dpi(0), dpi(0), dpi(5), dpi(5))
115 theme.cal = lain.widget.cal({
116     attach_to = { mytextclock, mytextcalendar },
117     notification_preset = {
118         fg = "#FFFFFF",
119         bg = theme.bg_normal,
120         position = "bottom_right",
121         font = "Monospace 10"
122     }
123 })
124
125 -- Mail IMAP check
126 --[[ commented because it needs to be set before use
127 theme.mail = lain.widget.imap({
128     timeout  = 180,
129     server   = "server",
130     mail     = "mail",
131     password = "keyring get mail",
132     settings = function()
133         mail_notification_preset.fg = "#FFFFFF"
134         mail  = ""
135         count = ""
136
137         if mailcount > 0 then
138             mail = "Mail "
139             count = mailcount .. " "
140         end
141
142         widget:set_markup(markup.font(theme.font, markup(blue, mail) .. markup("#FFFFFF", count)))
143     end
144 })
145 --]]
146
147 -- MPD
148 local mpd_icon = awful.widget.launcher({ image = theme.mpdl, command = theme.musicplr })
149 local prev_icon = wibox.widget.imagebox(theme.prev)
150 local next_icon = wibox.widget.imagebox(theme.nex)
151 local stop_icon = wibox.widget.imagebox(theme.stop)
152 local pause_icon = wibox.widget.imagebox(theme.pause)
153 local play_pause_icon = wibox.widget.imagebox(theme.play)
154 theme.mpd = lain.widget.mpd({
155     settings = function ()
156         if mpd_now.state == "play" then
157             mpd_now.artist = mpd_now.artist:upper():gsub("&.-;", string.lower)
158             mpd_now.title = mpd_now.title:upper():gsub("&.-;", string.lower)
159             widget:set_markup(markup.font("Roboto 4", " ")
160                               .. markup.font(theme.taglist_font,
161                               " " .. mpd_now.artist
162                               .. " - " ..
163                               mpd_now.title .. "  ") .. markup.font("Roboto 5", " "))
164             play_pause_icon:set_image(theme.pause)
165         elseif mpd_now.state == "pause" then
166             widget:set_markup(markup.font("Roboto 4", " ") ..
167                               markup.font(theme.taglist_font, " MPD PAUSED  ") ..
168                               markup.font("Roboto 5", " "))
169             play_pause_icon:set_image(theme.play)
170         else
171             widget:set_markup("")
172             play_pause_icon:set_image(theme.play)
173         end
174     end
175 })
176 local musicbg = wibox.container.background(theme.mpd.widget, theme.bg_focus, gears.shape.rectangle)
177 local musicwidget = wibox.container.margin(musicbg, dpi(0), dpi(0), dpi(5), dpi(5))
178
179 musicwidget:buttons(my_table.join(awful.button({ }, 1,
180 function () awful.spawn(theme.musicplr) end)))
181 prev_icon:buttons(my_table.join(awful.button({}, 1,
182 function ()
183     os.execute("mpc prev")
184     theme.mpd.update()
185 end)))
186 next_icon:buttons(my_table.join(awful.button({}, 1,
187 function ()
188     os.execute("mpc next")
189     theme.mpd.update()
190 end)))
191 stop_icon:buttons(my_table.join(awful.button({}, 1,
192 function ()
193     play_pause_icon:set_image(theme.play)
194     os.execute("mpc stop")
195     theme.mpd.update()
196 end)))
197 play_pause_icon:buttons(my_table.join(awful.button({}, 1,
198 function ()
199     os.execute("mpc toggle")
200     theme.mpd.update()
201 end)))
202
203 -- Battery
204 local bat = lain.widget.bat({
205     settings = function()
206         bat_header = " Bat "
207         bat_p      = bat_now.perc .. " "
208         if bat_now.ac_status == 1 then
209             bat_p = bat_p .. "Plugged "
210         end
211         widget:set_markup(markup.font(theme.font, markup(blue, bat_header) .. bat_p))
212     end
213 })
214
215 -- / fs
216 --[[ commented because it needs Gio/Glib >= 2.54
217 theme.fs = lain.widget.fs({
218     notification_preset = { bg = theme.bg_normal, font = "Monospace 9" },
219 })
220 --]]
221
222 -- ALSA volume bar
223 theme.volume = lain.widget.alsabar({
224     notification_preset = { font = "Monospace 9"},
225     --togglechannel = "IEC958,3",
226     width = dpi(80), height = dpi(10), border_width = dpi(0),
227     colors = {
228         background = "#383838",
229         unmute     = "#80CCE6",
230         mute       = "#FF9F9F"
231     },
232 })
233 theme.volume.bar.paddings = dpi(0)
234 theme.volume.bar.margins = dpi(5)
235 local volumewidget = wibox.container.background(theme.volume.bar, theme.bg_focus, gears.shape.rectangle)
236 volumewidget = wibox.container.margin(volumewidget, dpi(0), dpi(0), dpi(5), dpi(5))
237
238 -- CPU
239 local cpu_icon = wibox.widget.imagebox(theme.cpu)
240 local cpu = lain.widget.cpu({
241     settings = function()
242         widget:set_markup(space3 .. markup.font(theme.font, "CPU " .. cpu_now.usage
243                           .. "% ") .. markup.font("Roboto 5", " "))
244     end
245 })
246 local cpubg = wibox.container.background(cpu.widget, theme.bg_focus, gears.shape.rectangle)
247 local cpuwidget = wibox.container.margin(cpubg, dpi(0), dpi(0), dpi(5), dpi(5))
248
249 -- Net
250 local netdown_icon = wibox.widget.imagebox(theme.net_down)
251 local netup_icon = wibox.widget.imagebox(theme.net_up)
252 local net = lain.widget.net({
253     settings = function()
254         widget:set_markup(markup.font("Roboto 1", " ") .. markup.font(theme.font, net_now.received .. " - "
255                           .. net_now.sent) .. markup.font("Roboto 2", " "))
256     end
257 })
258 local netbg = wibox.container.background(net.widget, theme.bg_focus, gears.shape.rectangle)
259 local networkwidget = wibox.container.margin(netbg, dpi(0), dpi(0), dpi(5), dpi(5))
260
261 -- Weather
262 theme.weather = lain.widget.weather({
263     city_id = 2643743, -- placeholder (London)
264     notification_preset = { font = "Monospace 9", position = "bottom_right" },
265 })
266
267 -- Launcher
268 local mylauncher = awful.widget.button({ image = theme.awesome_icon_launcher })
269 mylauncher:connect_signal("button::press", function() awful.util.mymainmenu:toggle() end)
270
271 -- Separators
272 local first = wibox.widget.textbox('<span font="Roboto 7"> </span>')
273 local spr_small = wibox.widget.imagebox(theme.spr_small)
274 local spr_very_small = wibox.widget.imagebox(theme.spr_very_small)
275 local spr_right = wibox.widget.imagebox(theme.spr_right)
276 local spr_bottom_right = wibox.widget.imagebox(theme.spr_bottom_right)
277 local spr_left = wibox.widget.imagebox(theme.spr_left)
278 local bar = wibox.widget.imagebox(theme.bar)
279 local bottom_bar = wibox.widget.imagebox(theme.bottom_bar)
280
281 local barcolor  = gears.color({
282     type  = "linear",
283     from  = { dpi(32), 0 },
284     to    = { dpi(32), dpi(32) },
285     stops = { {0, theme.bg_focus}, {0.25, "#505050"}, {1, theme.bg_focus} }
286 })
287
288 function theme.at_screen_connect(s)
289     -- Quake application
290     s.quake = lain.util.quake({ app = awful.util.terminal })
291
292     -- If wallpaper is a function, call it with the screen
293     local wallpaper = theme.wallpaper
294     if type(wallpaper) == "function" then
295         wallpaper = wallpaper(s)
296     end
297     gears.wallpaper.maximized(wallpaper, s, true)
298
299     -- Tags
300     awful.tag(awful.util.tagnames, s, awful.layout.layouts)
301
302     -- Create a promptbox for each screen
303     s.mypromptbox = awful.widget.prompt()
304     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
305     -- We need one layoutbox per screen.
306     s.mylayoutbox = awful.widget.layoutbox(s)
307     s.mylayoutbox:buttons(my_table.join(
308                            awful.button({}, 1, function () awful.layout.inc( 1) end),
309                            awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
310                            awful.button({}, 3, function () awful.layout.inc(-1) end),
311                            awful.button({}, 4, function () awful.layout.inc( 1) end),
312                            awful.button({}, 5, function () awful.layout.inc(-1) end)))
313     -- Create a taglist widget
314     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons, { bg_focus = barcolor })
315
316     mytaglistcont = wibox.container.background(s.mytaglist, theme.bg_focus, gears.shape.rectangle)
317     s.mytag = wibox.container.margin(mytaglistcont, dpi(0), dpi(0), dpi(5), dpi(5))
318
319     -- Create a tasklist widget
320     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons, { bg_focus = theme.bg_focus, shape = gears.shape.rectangle, shape_border_width = 5, shape_border_color = theme.tasklist_bg_normal, align = "center" })
321
322     -- Create the wibox
323     s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(32) })
324
325     -- Add widgets to the wibox
326     s.mywibox:setup {
327         layout = wibox.layout.align.horizontal,
328         { -- Left widgets
329             layout = wibox.layout.fixed.horizontal,
330             first,
331             s.mytag,
332             spr_small,
333             s.mylayoutbox,
334             spr_small,
335             s.mypromptbox,
336         },
337         nil, -- Middle widget
338         { -- Right widgets
339             layout = wibox.layout.fixed.horizontal,
340             wibox.widget.systray(),
341             --theme.mail.widget,
342             --bat.widget,
343             spr_right,
344             musicwidget,
345             bar,
346             prev_icon,
347             next_icon,
348             stop_icon,
349             play_pause_icon,
350             bar,
351             mpd_icon,
352             bar,
353             spr_very_small,
354             volumewidget,
355             spr_left,
356         },
357     }
358
359     -- Create the bottom wibox
360     s.mybottomwibox = awful.wibar({ position = "bottom", screen = s, border_width = dpi(0), height = dpi(32) })
361     s.borderwibox = awful.wibar({ position = "bottom", screen = s, height = dpi(1), bg = theme.fg_focus, x = dpi(0), y = dpi(33)})
362
363     -- Add widgets to the bottom wibox
364     s.mybottomwibox:setup {
365         layout = wibox.layout.align.horizontal,
366         { -- Left widgets
367             layout = wibox.layout.fixed.horizontal,
368             mylauncher,
369         },
370         s.mytasklist, -- Middle widget
371         { -- Right widgets
372             layout = wibox.layout.fixed.horizontal,
373             spr_bottom_right,
374             netdown_icon,
375             networkwidget,
376             netup_icon,
377             bottom_bar,
378             cpu_icon,
379             cpuwidget,
380             bottom_bar,
381             calendar_icon,
382             calendarwidget,
383             bottom_bar,
384             clock_icon,
385             clockwidget,
386         },
387     }
388 end
389
390 return theme