Actualizacion maquina principal
[dotfiles/.git] / .config / awesome / themes / powerarrow / theme.lua
1 --[[
2
3      Powerarrow Awesome WM theme
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 math, string, os = math, string, os
15 local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
16
17 local theme                                     = {}
18 theme.dir                                       = os.getenv("HOME") .. "/.config/awesome/themes/powerarrow"
19 theme.wallpaper                                 = theme.dir .. "/wall.png"
20 theme.font                                      = "Terminus 9"
21 theme.fg_normal                                 = "#FEFEFE"
22 theme.fg_focus                                  = "#32D6FF"
23 theme.fg_urgent                                 = "#C83F11"
24 theme.bg_normal                                 = "#222222"
25 theme.bg_focus                                  = "#1E2320"
26 theme.bg_urgent                                 = "#3F3F3F"
27 theme.taglist_fg_focus                          = "#00CCFF"
28 theme.tasklist_bg_focus                         = "#222222"
29 theme.tasklist_fg_focus                         = "#00CCFF"
30 theme.border_width                              = dpi(2)
31 theme.border_normal                             = "#3F3F3F"
32 theme.border_focus                              = "#6F6F6F"
33 theme.border_marked                             = "#CC9393"
34 theme.titlebar_bg_focus                         = "#3F3F3F"
35 theme.titlebar_bg_normal                        = "#3F3F3F"
36 theme.titlebar_bg_focus                         = theme.bg_focus
37 theme.titlebar_bg_normal                        = theme.bg_normal
38 theme.titlebar_fg_focus                         = theme.fg_focus
39 theme.menu_height                               = dpi(16)
40 theme.menu_width                                = dpi(140)
41 theme.menu_submenu_icon                         = theme.dir .. "/icons/submenu.png"
42 theme.awesome_icon                              = theme.dir .. "/icons/awesome.png"
43 theme.taglist_squares_sel                       = theme.dir .. "/icons/square_sel.png"
44 theme.taglist_squares_unsel                     = theme.dir .. "/icons/square_unsel.png"
45 theme.layout_tile                               = theme.dir .. "/icons/tile.png"
46 theme.layout_tileleft                           = theme.dir .. "/icons/tileleft.png"
47 theme.layout_tilebottom                         = theme.dir .. "/icons/tilebottom.png"
48 theme.layout_tiletop                            = theme.dir .. "/icons/tiletop.png"
49 theme.layout_fairv                              = theme.dir .. "/icons/fairv.png"
50 theme.layout_fairh                              = theme.dir .. "/icons/fairh.png"
51 theme.layout_spiral                             = theme.dir .. "/icons/spiral.png"
52 theme.layout_dwindle                            = theme.dir .. "/icons/dwindle.png"
53 theme.layout_max                                = theme.dir .. "/icons/max.png"
54 theme.layout_fullscreen                         = theme.dir .. "/icons/fullscreen.png"
55 theme.layout_magnifier                          = theme.dir .. "/icons/magnifier.png"
56 theme.layout_floating                           = theme.dir .. "/icons/floating.png"
57 theme.widget_ac                                 = theme.dir .. "/icons/ac.png"
58 theme.widget_battery                            = theme.dir .. "/icons/battery.png"
59 theme.widget_battery_low                        = theme.dir .. "/icons/battery_low.png"
60 theme.widget_battery_empty                      = theme.dir .. "/icons/battery_empty.png"
61 theme.widget_brightness                         = theme.dir .. "/icons/brightness.png"
62 theme.widget_mem                                = theme.dir .. "/icons/mem.png"
63 theme.widget_cpu                                = theme.dir .. "/icons/cpu.png"
64 theme.widget_temp                               = theme.dir .. "/icons/temp.png"
65 theme.widget_net                                = theme.dir .. "/icons/net.png"
66 theme.widget_hdd                                = theme.dir .. "/icons/hdd.png"
67 theme.widget_music                              = theme.dir .. "/icons/note.png"
68 theme.widget_music_on                           = theme.dir .. "/icons/note_on.png"
69 theme.widget_music_pause                        = theme.dir .. "/icons/pause.png"
70 theme.widget_music_stop                         = theme.dir .. "/icons/stop.png"
71 theme.widget_vol                                = theme.dir .. "/icons/vol.png"
72 theme.widget_vol_low                            = theme.dir .. "/icons/vol_low.png"
73 theme.widget_vol_no                             = theme.dir .. "/icons/vol_no.png"
74 theme.widget_vol_mute                           = theme.dir .. "/icons/vol_mute.png"
75 theme.widget_mail                               = theme.dir .. "/icons/mail.png"
76 theme.widget_mail_on                            = theme.dir .. "/icons/mail_on.png"
77 theme.widget_task                               = theme.dir .. "/icons/task.png"
78 theme.widget_scissors                           = theme.dir .. "/icons/scissors.png"
79 theme.tasklist_plain_task_name                  = true
80 theme.tasklist_disable_icon                     = true
81 theme.useless_gap                               = 0
82 theme.titlebar_close_button_focus               = theme.dir .. "/icons/titlebar/close_focus.png"
83 theme.titlebar_close_button_normal              = theme.dir .. "/icons/titlebar/close_normal.png"
84 theme.titlebar_ontop_button_focus_active        = theme.dir .. "/icons/titlebar/ontop_focus_active.png"
85 theme.titlebar_ontop_button_normal_active       = theme.dir .. "/icons/titlebar/ontop_normal_active.png"
86 theme.titlebar_ontop_button_focus_inactive      = theme.dir .. "/icons/titlebar/ontop_focus_inactive.png"
87 theme.titlebar_ontop_button_normal_inactive     = theme.dir .. "/icons/titlebar/ontop_normal_inactive.png"
88 theme.titlebar_sticky_button_focus_active       = theme.dir .. "/icons/titlebar/sticky_focus_active.png"
89 theme.titlebar_sticky_button_normal_active      = theme.dir .. "/icons/titlebar/sticky_normal_active.png"
90 theme.titlebar_sticky_button_focus_inactive     = theme.dir .. "/icons/titlebar/sticky_focus_inactive.png"
91 theme.titlebar_sticky_button_normal_inactive    = theme.dir .. "/icons/titlebar/sticky_normal_inactive.png"
92 theme.titlebar_floating_button_focus_active     = theme.dir .. "/icons/titlebar/floating_focus_active.png"
93 theme.titlebar_floating_button_normal_active    = theme.dir .. "/icons/titlebar/floating_normal_active.png"
94 theme.titlebar_floating_button_focus_inactive   = theme.dir .. "/icons/titlebar/floating_focus_inactive.png"
95 theme.titlebar_floating_button_normal_inactive  = theme.dir .. "/icons/titlebar/floating_normal_inactive.png"
96 theme.titlebar_maximized_button_focus_active    = theme.dir .. "/icons/titlebar/maximized_focus_active.png"
97 theme.titlebar_maximized_button_normal_active   = theme.dir .. "/icons/titlebar/maximized_normal_active.png"
98 theme.titlebar_maximized_button_focus_inactive  = theme.dir .. "/icons/titlebar/maximized_focus_inactive.png"
99 theme.titlebar_maximized_button_normal_inactive = theme.dir .. "/icons/titlebar/maximized_normal_inactive.png"
100
101 local markup = lain.util.markup
102 local separators = lain.util.separators
103
104 -- Binary clock
105 local binclock = require("themes.powerarrow.binclock"){
106     height = dpi(32),
107     show_seconds = true,
108     color_active = theme.fg_normal,
109     color_inactive = theme.bg_focus
110 }
111
112 -- Calendar
113 theme.cal = lain.widget.cal({
114     --cal = "cal --color=always",
115     attach_to = { binclock.widget },
116     notification_preset = {
117         font = "Terminus 10",
118         fg   = theme.fg_normal,
119         bg   = theme.bg_normal
120     }
121 })
122
123 -- Taskwarrior
124 local task = wibox.widget.imagebox(theme.widget_task)
125 lain.widget.contrib.task.attach(task, {
126     -- do not colorize output
127     show_cmd = "task | sed -r 's/\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g'"
128 })
129 task:buttons(my_table.join(awful.button({}, 1, lain.widget.contrib.task.prompt)))
130
131 -- Scissors (xsel copy and paste)
132 local scissors = wibox.widget.imagebox(theme.widget_scissors)
133 scissors:buttons(my_table.join(awful.button({}, 1, function() awful.spawn.with_shell("xsel | xsel -i -b") end)))
134
135 -- Mail IMAP check
136 --[[ commented because it needs to be set before use
137 local mailicon = wibox.widget.imagebox(theme.widget_mail)
138 mailicon:buttons(my_table.join(awful.button({ }, 1, function () awful.spawn(mail) end)))
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             widget:set_text(" " .. mailcount .. " ")
147             mailicon:set_image(theme.widget_mail_on)
148         else
149             widget:set_text("")
150             mailicon:set_image(theme.widget_mail)
151         end
152     end
153 })
154 --]]
155
156 -- ALSA volume
157 theme.volume = lain.widget.alsabar({
158     --togglechannel = "IEC958,3",
159     notification_preset = { font = "Terminus 10", fg = theme.fg_normal },
160 })
161
162 -- MPD
163 local musicplr = awful.util.terminal .. " -title Music -g 130x34-320+16 -e ncmpcpp"
164 local mpdicon = wibox.widget.imagebox(theme.widget_music)
165 mpdicon:buttons(my_table.join(
166     awful.button({ modkey }, 1, function () awful.spawn.with_shell(musicplr) end),
167     awful.button({ }, 1, function ()
168         os.execute("mpc prev")
169         theme.mpd.update()
170     end),
171     awful.button({ }, 2, function ()
172         os.execute("mpc toggle")
173         theme.mpd.update()
174     end),
175     awful.button({ }, 3, function ()
176         os.execute("mpc next")
177         theme.mpd.update()
178     end)))
179 theme.mpd = lain.widget.mpd({
180     settings = function()
181         if mpd_now.state == "play" then
182             artist = " " .. mpd_now.artist .. " "
183             title  = mpd_now.title  .. " "
184             mpdicon:set_image(theme.widget_music_on)
185             widget:set_markup(markup.font(theme.font, markup("#FF8466", artist) .. " " .. title))
186         elseif mpd_now.state == "pause" then
187             widget:set_markup(markup.font(theme.font, " mpd paused "))
188             mpdicon:set_image(theme.widget_music_pause)
189         else
190             widget:set_text("")
191             mpdicon:set_image(theme.widget_music)
192         end
193     end
194 })
195
196 -- MEM
197 local memicon = wibox.widget.imagebox(theme.widget_mem)
198 local mem = lain.widget.mem({
199     settings = function()
200         widget:set_markup(markup.font(theme.font, " " .. mem_now.used .. "MB "))
201     end
202 })
203
204 -- CPU
205 local cpuicon = wibox.widget.imagebox(theme.widget_cpu)
206 local cpu = lain.widget.cpu({
207     settings = function()
208         widget:set_markup(markup.font(theme.font, " " .. cpu_now.usage .. "% "))
209     end
210 })
211
212 --[[ Coretemp (lm_sensors, per core)
213 local tempwidget = awful.widget.watch({awful.util.shell, '-c', 'sensors | grep Core'}, 30,
214 function(widget, stdout)
215     local temps = ""
216     for line in stdout:gmatch("[^\r\n]+") do
217         temps = temps .. line:match("+(%d+).*°C")  .. "° " -- in Celsius
218     end
219     widget:set_markup(markup.font(theme.font, " " .. temps))
220 end)
221 --]]
222 -- Coretemp (lain, average)
223 local temp = lain.widget.temp({
224     settings = function()
225         widget:set_markup(markup.font(theme.font, " " .. coretemp_now .. "°C "))
226     end
227 })
228 --]]
229 local tempicon = wibox.widget.imagebox(theme.widget_temp)
230
231 -- / fs
232 local fsicon = wibox.widget.imagebox(theme.widget_hdd)
233 --[[ commented because it needs Gio/Glib >= 2.54
234 theme.fs = lain.widget.fs({
235     notification_preset = { fg = theme.fg_normal, bg = theme.bg_normal, font = "Terminus 10" },
236     settings = function()
237         local fsp = string.format(" %3.2f %s ", fs_now["/"].free, fs_now["/"].units)
238         widget:set_markup(markup.font(theme.font, fsp))
239     end
240 })
241 --]]
242
243 -- Battery
244 local baticon = wibox.widget.imagebox(theme.widget_battery)
245 local bat = lain.widget.bat({
246     settings = function()
247         if bat_now.status and bat_now.status ~= "N/A" then
248             if bat_now.ac_status == 1 then
249                 widget:set_markup(markup.font(theme.font, " AC "))
250                 baticon:set_image(theme.widget_ac)
251                 return
252             elseif not bat_now.perc and tonumber(bat_now.perc) <= 5 then
253                 baticon:set_image(theme.widget_battery_empty)
254             elseif not bat_now.perc and tonumber(bat_now.perc) <= 15 then
255                 baticon:set_image(theme.widget_battery_low)
256             else
257                 baticon:set_image(theme.widget_battery)
258             end
259             widget:set_markup(markup.font(theme.font, " " .. bat_now.perc .. "% "))
260         else
261             widget:set_markup()
262             baticon:set_image(theme.widget_ac)
263         end
264     end
265 })
266
267 -- Net
268 local neticon = wibox.widget.imagebox(theme.widget_net)
269 local net = lain.widget.net({
270     settings = function()
271         widget:set_markup(markup.fontfg(theme.font, "#FEFEFE", " " .. net_now.received .. " ↓↑ " .. net_now.sent .. " "))
272     end
273 })
274
275 -- Brigtness
276 local brighticon = wibox.widget.imagebox(theme.widget_brightness)
277 -- If you use xbacklight, comment the line with "light -G" and uncomment the line bellow
278 -- local brightwidget = awful.widget.watch('xbacklight -get', 0.1,
279 local brightwidget = awful.widget.watch('light -G', 0.1,
280     function(widget, stdout, stderr, exitreason, exitcode)
281         local brightness_level = tonumber(string.format("%.0f", stdout))
282         widget:set_markup(markup.font(theme.font, " " .. brightness_level .. "%"))
283 end)
284
285 -- Separators
286 local arrow = separators.arrow_left
287
288 function theme.powerline_rl(cr, width, height)
289     local arrow_depth, offset = height/2, 0
290
291     -- Avoid going out of the (potential) clip area
292     if arrow_depth < 0 then
293         width  =  width + 2*arrow_depth
294         offset = -arrow_depth
295     end
296
297     cr:move_to(offset + arrow_depth         , 0        )
298     cr:line_to(offset + width               , 0        )
299     cr:line_to(offset + width - arrow_depth , height/2 )
300     cr:line_to(offset + width               , height   )
301     cr:line_to(offset + arrow_depth         , height   )
302     cr:line_to(offset                       , height/2 )
303
304     cr:close_path()
305 end
306
307 local function pl(widget, bgcolor, padding)
308     return wibox.container.background(wibox.container.margin(widget, dpi(16), dpi(16)), bgcolor, theme.powerline_rl)
309 end
310
311 function theme.at_screen_connect(s)
312     -- Quake application
313     s.quake = lain.util.quake({ app = awful.util.terminal })
314
315     -- If wallpaper is a function, call it with the screen
316     local wallpaper = theme.wallpaper
317     if type(wallpaper) == "function" then
318         wallpaper = wallpaper(s)
319     end
320     gears.wallpaper.maximized(wallpaper, s, true)
321
322     -- Tags
323     awful.tag(awful.util.tagnames, s, awful.layout.layouts)
324
325     -- Create a promptbox for each screen
326     s.mypromptbox = awful.widget.prompt()
327     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
328     -- We need one layoutbox per screen.
329     s.mylayoutbox = awful.widget.layoutbox(s)
330     s.mylayoutbox:buttons(my_table.join(
331                            awful.button({}, 1, function () awful.layout.inc( 1) end),
332                            awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
333                            awful.button({}, 3, function () awful.layout.inc(-1) end),
334                            awful.button({}, 4, function () awful.layout.inc( 1) end),
335                            awful.button({}, 5, function () awful.layout.inc(-1) end)))
336     -- Create a taglist widget
337     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
338
339     -- Create a tasklist widget
340     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
341
342     -- Create the wibox
343     s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(16), bg = theme.bg_normal, fg = theme.fg_normal })
344
345     -- Add widgets to the wibox
346     s.mywibox:setup {
347         layout = wibox.layout.align.horizontal,
348         { -- Left widgets
349             layout = wibox.layout.fixed.horizontal,
350             --spr,
351             s.mytaglist,
352             s.mypromptbox,
353             spr,
354         },
355         s.mytasklist, -- Middle widget
356         { -- Right widgets
357             layout = wibox.layout.fixed.horizontal,
358             wibox.widget.systray(),
359             wibox.container.margin(scissors, dpi(4), dpi(8)),
360             --[[ using shapes
361             pl(wibox.widget { mpdicon, theme.mpd.widget, layout = wibox.layout.align.horizontal }, "#343434"),
362             pl(task, "#343434"),
363             --pl(wibox.widget { mailicon, mail and theme.mail.widget, layout = wibox.layout.align.horizontal }, "#343434"),
364             pl(wibox.widget { memicon, mem.widget, layout = wibox.layout.align.horizontal }, "#777E76"),
365             pl(wibox.widget { cpuicon, cpu.widget, layout = wibox.layout.align.horizontal }, "#4B696D"),
366             pl(wibox.widget { tempicon, temp.widget, layout = wibox.layout.align.horizontal }, "#4B3B51"),
367             --pl(wibox.widget { fsicon, theme.fs and theme.fs.widget, layout = wibox.layout.align.horizontal }, "#CB755B"),
368             pl(wibox.widget { baticon, bat.widget, layout = wibox.layout.align.horizontal }, "#8DAA9A"),
369             pl(wibox.widget { neticon, net.widget, layout = wibox.layout.align.horizontal }, "#C0C0A2"),
370             pl(binclock.widget, "#777E76"),
371             --]]
372             -- using separators
373             arrow(theme.bg_normal, "#343434"),
374             wibox.container.background(wibox.container.margin(wibox.widget { mailicon, theme.mail and theme.mail.widget, layout = wibox.layout.align.horizontal }, dpi(4), dpi(7)), "#343434"),
375             arrow("#343434", theme.bg_normal),
376             wibox.container.background(wibox.container.margin(wibox.widget { mpdicon, theme.mpd.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(6)), theme.bg_focus),
377             arrow(theme.bg_normal, "#343434"),
378             wibox.container.background(wibox.container.margin(task, dpi(3), dpi(7)), "#343434"),
379             arrow("#343434", "#777E76"),
380             wibox.container.background(wibox.container.margin(wibox.widget { memicon, mem.widget, layout = wibox.layout.align.horizontal }, dpi(2), dpi(3)), "#777E76"),
381             arrow("#777E76", "#4B696D"),
382             wibox.container.background(wibox.container.margin(wibox.widget { cpuicon, cpu.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(4)), "#4B696D"),
383             arrow("#4B696D", "#4B3B51"),
384             wibox.container.background(wibox.container.margin(wibox.widget { tempicon, temp.widget, layout = wibox.layout.align.horizontal }, dpi(4), dpi(4)), "#4B3B51"),
385             arrow("#4B3B51", "#CB755B"),
386             wibox.container.background(wibox.container.margin(wibox.widget { fsicon, theme.fs and theme.fs.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(3)), "#CB755B"),
387             arrow("#CB755B", "#8DAA9A"),
388             wibox.container.background(wibox.container.margin(wibox.widget { baticon, bat.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(3)), "#8DAA9A"),
389             arrow("#8DAA9A", "#C0C0A2"),
390             wibox.container.background(wibox.container.margin(wibox.widget { nil, neticon, net.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(3)), "#C0C0A2"),
391             arrow("#C0C0A2", "#777E76"),
392             wibox.container.background(wibox.container.margin(binclock.widget, dpi(4), dpi(8)), "#777E76"),
393             arrow("#777E76", "alpha"),
394             --]]
395             s.mylayoutbox,
396         },
397     }
398 end
399
400 return theme