some deletions
[dotfiles/.git] / .config / awesome / themes / powerarrow-dark / theme.lua
1 --[[
2
3      Powerarrow Dark 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 os = 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-dark"
19 theme.wallpaper                                 = theme.dir .. "/wall.png"
20 theme.font                                      = "Terminus 9"
21 theme.fg_normal                                 = "#DDDDFF"
22 theme.fg_focus                                  = "#EA6F81"
23 theme.fg_urgent                                 = "#CC9393"
24 theme.bg_normal                                 = "#1A1A1A"
25 theme.bg_focus                                  = "#313131"
26 theme.bg_urgent                                 = "#1A1A1A"
27 theme.border_width                              = dpi(1)
28 theme.border_normal                             = "#3F3F3F"
29 theme.border_focus                              = "#7F7F7F"
30 theme.border_marked                             = "#CC9393"
31 theme.tasklist_bg_focus                         = "#1A1A1A"
32 theme.titlebar_bg_focus                         = theme.bg_focus
33 theme.titlebar_bg_normal                        = theme.bg_normal
34 theme.titlebar_fg_focus                         = theme.fg_focus
35 theme.menu_height                               = dpi(16)
36 theme.menu_width                                = dpi(140)
37 theme.menu_submenu_icon                         = theme.dir .. "/icons/submenu.png"
38 theme.taglist_squares_sel                       = theme.dir .. "/icons/square_sel.png"
39 theme.taglist_squares_unsel                     = theme.dir .. "/icons/square_unsel.png"
40 theme.layout_tile                               = theme.dir .. "/icons/tile.png"
41 theme.layout_tileleft                           = theme.dir .. "/icons/tileleft.png"
42 theme.layout_tilebottom                         = theme.dir .. "/icons/tilebottom.png"
43 theme.layout_tiletop                            = theme.dir .. "/icons/tiletop.png"
44 theme.layout_fairv                              = theme.dir .. "/icons/fairv.png"
45 theme.layout_fairh                              = theme.dir .. "/icons/fairh.png"
46 theme.layout_spiral                             = theme.dir .. "/icons/spiral.png"
47 theme.layout_dwindle                            = theme.dir .. "/icons/dwindle.png"
48 theme.layout_max                                = theme.dir .. "/icons/max.png"
49 theme.layout_fullscreen                         = theme.dir .. "/icons/fullscreen.png"
50 theme.layout_magnifier                          = theme.dir .. "/icons/magnifier.png"
51 theme.layout_floating                           = theme.dir .. "/icons/floating.png"
52 theme.widget_ac                                 = theme.dir .. "/icons/ac.png"
53 theme.widget_battery                            = theme.dir .. "/icons/battery.png"
54 theme.widget_battery_low                        = theme.dir .. "/icons/battery_low.png"
55 theme.widget_battery_empty                      = theme.dir .. "/icons/battery_empty.png"
56 theme.widget_mem                                = theme.dir .. "/icons/mem.png"
57 theme.widget_cpu                                = theme.dir .. "/icons/cpu.png"
58 theme.widget_temp                               = theme.dir .. "/icons/temp.png"
59 theme.widget_net                                = theme.dir .. "/icons/net.png"
60 theme.widget_hdd                                = theme.dir .. "/icons/hdd.png"
61 theme.widget_music                              = theme.dir .. "/icons/note.png"
62 theme.widget_music_on                           = theme.dir .. "/icons/note_on.png"
63 theme.widget_vol                                = theme.dir .. "/icons/vol.png"
64 theme.widget_vol_low                            = theme.dir .. "/icons/vol_low.png"
65 theme.widget_vol_no                             = theme.dir .. "/icons/vol_no.png"
66 theme.widget_vol_mute                           = theme.dir .. "/icons/vol_mute.png"
67 theme.widget_mail                               = theme.dir .. "/icons/mail.png"
68 theme.widget_mail_on                            = theme.dir .. "/icons/mail_on.png"
69 theme.tasklist_plain_task_name                  = true
70 theme.tasklist_disable_icon                     = true
71 theme.useless_gap                               = dpi(0)
72 theme.titlebar_close_button_focus               = theme.dir .. "/icons/titlebar/close_focus.png"
73 theme.titlebar_close_button_normal              = theme.dir .. "/icons/titlebar/close_normal.png"
74 theme.titlebar_ontop_button_focus_active        = theme.dir .. "/icons/titlebar/ontop_focus_active.png"
75 theme.titlebar_ontop_button_normal_active       = theme.dir .. "/icons/titlebar/ontop_normal_active.png"
76 theme.titlebar_ontop_button_focus_inactive      = theme.dir .. "/icons/titlebar/ontop_focus_inactive.png"
77 theme.titlebar_ontop_button_normal_inactive     = theme.dir .. "/icons/titlebar/ontop_normal_inactive.png"
78 theme.titlebar_sticky_button_focus_active       = theme.dir .. "/icons/titlebar/sticky_focus_active.png"
79 theme.titlebar_sticky_button_normal_active      = theme.dir .. "/icons/titlebar/sticky_normal_active.png"
80 theme.titlebar_sticky_button_focus_inactive     = theme.dir .. "/icons/titlebar/sticky_focus_inactive.png"
81 theme.titlebar_sticky_button_normal_inactive    = theme.dir .. "/icons/titlebar/sticky_normal_inactive.png"
82 theme.titlebar_floating_button_focus_active     = theme.dir .. "/icons/titlebar/floating_focus_active.png"
83 theme.titlebar_floating_button_normal_active    = theme.dir .. "/icons/titlebar/floating_normal_active.png"
84 theme.titlebar_floating_button_focus_inactive   = theme.dir .. "/icons/titlebar/floating_focus_inactive.png"
85 theme.titlebar_floating_button_normal_inactive  = theme.dir .. "/icons/titlebar/floating_normal_inactive.png"
86 theme.titlebar_maximized_button_focus_active    = theme.dir .. "/icons/titlebar/maximized_focus_active.png"
87 theme.titlebar_maximized_button_normal_active   = theme.dir .. "/icons/titlebar/maximized_normal_active.png"
88 theme.titlebar_maximized_button_focus_inactive  = theme.dir .. "/icons/titlebar/maximized_focus_inactive.png"
89 theme.titlebar_maximized_button_normal_inactive = theme.dir .. "/icons/titlebar/maximized_normal_inactive.png"
90
91 local markup = lain.util.markup
92 local separators = lain.util.separators
93
94 -- Textclock
95 local clockicon = wibox.widget.imagebox(theme.widget_clock)
96 local clock = awful.widget.watch(
97     "date +'%a %d %b %R'", 60,
98     function(widget, stdout)
99         widget:set_markup(" " .. markup.font(theme.font, stdout))
100     end
101 )
102
103 -- Calendar
104 theme.cal = lain.widget.cal({
105     attach_to = { clock },
106     notification_preset = {
107         font = "Terminus 10",
108         fg   = theme.fg_normal,
109         bg   = theme.bg_normal
110     }
111 })
112
113 -- Mail IMAP check
114 local mailicon = wibox.widget.imagebox(theme.widget_mail)
115 --[[ commented because it needs to be set before use
116 mailicon:buttons(my_table.join(awful.button({ }, 1, function () awful.spawn(mail) end)))
117 theme.mail = lain.widget.imap({
118     timeout  = 180,
119     server   = "server",
120     mail     = "mail",
121     password = "keyring get mail",
122     settings = function()
123         if mailcount > 0 then
124             widget:set_markup(markup.font(theme.font, " " .. mailcount .. " "))
125             mailicon:set_image(theme.widget_mail_on)
126         else
127             widget:set_text("")
128             mailicon:set_image(theme.widget_mail)
129         end
130     end
131 })
132 --]]
133
134 -- MPD
135 local musicplr = awful.util.terminal .. " -title Music -g 130x34-320+16 -e ncmpcpp"
136 local mpdicon = wibox.widget.imagebox(theme.widget_music)
137 mpdicon:buttons(my_table.join(
138     awful.button({ modkey }, 1, function () awful.spawn.with_shell(musicplr) end),
139     awful.button({ }, 1, function ()
140         os.execute("mpc prev")
141         theme.mpd.update()
142     end),
143     awful.button({ }, 2, function ()
144         os.execute("mpc toggle")
145         theme.mpd.update()
146     end),
147     awful.button({ }, 3, function ()
148         os.execute("mpc next")
149         theme.mpd.update()
150     end)))
151 theme.mpd = lain.widget.mpd({
152     settings = function()
153         if mpd_now.state == "play" then
154             artist = " " .. mpd_now.artist .. " "
155             title  = mpd_now.title  .. " "
156             mpdicon:set_image(theme.widget_music_on)
157         elseif mpd_now.state == "pause" then
158             artist = " mpd "
159             title  = "paused "
160         else
161             artist = ""
162             title  = ""
163             mpdicon:set_image(theme.widget_music)
164         end
165
166         widget:set_markup(markup.font(theme.font, markup("#EA6F81", artist) .. title))
167     end
168 })
169
170 -- MEM
171 local memicon = wibox.widget.imagebox(theme.widget_mem)
172 local mem = lain.widget.mem({
173     settings = function()
174         widget:set_markup(markup.font(theme.font, " " .. mem_now.used .. "MB "))
175     end
176 })
177
178 -- CPU
179 local cpuicon = wibox.widget.imagebox(theme.widget_cpu)
180 local cpu = lain.widget.cpu({
181     settings = function()
182         widget:set_markup(markup.font(theme.font, " " .. cpu_now.usage .. "% "))
183     end
184 })
185
186 -- Coretemp
187 local tempicon = wibox.widget.imagebox(theme.widget_temp)
188 local temp = lain.widget.temp({
189     settings = function()
190         widget:set_markup(markup.font(theme.font, " " .. coretemp_now .. "°C "))
191     end
192 })
193
194 -- / fs
195 local fsicon = wibox.widget.imagebox(theme.widget_hdd)
196 --[[ commented because it needs Gio/Glib >= 2.54
197 theme.fs = lain.widget.fs({
198     notification_preset = { fg = theme.fg_normal, bg = theme.bg_normal, font = "Terminus 10" },
199     settings = function()
200         widget:set_markup(markup.font(theme.font, " " .. fs_now["/"].percentage .. "% "))
201     end
202 })
203 --]]
204
205 -- Battery
206 local baticon = wibox.widget.imagebox(theme.widget_battery)
207 local bat = lain.widget.bat({
208     settings = function()
209         if bat_now.status and bat_now.status ~= "N/A" then
210             if bat_now.ac_status == 1 then
211                 baticon:set_image(theme.widget_ac)
212             elseif not bat_now.perc and tonumber(bat_now.perc) <= 5 then
213                 baticon:set_image(theme.widget_battery_empty)
214             elseif not bat_now.perc and tonumber(bat_now.perc) <= 15 then
215                 baticon:set_image(theme.widget_battery_low)
216             else
217                 baticon:set_image(theme.widget_battery)
218             end
219             widget:set_markup(markup.font(theme.font, " " .. bat_now.perc .. "% "))
220         else
221             widget:set_markup(markup.font(theme.font, " AC "))
222             baticon:set_image(theme.widget_ac)
223         end
224     end
225 })
226
227 -- ALSA volume
228 local volicon = wibox.widget.imagebox(theme.widget_vol)
229 theme.volume = lain.widget.alsa({
230     settings = function()
231         if volume_now.status == "off" then
232             volicon:set_image(theme.widget_vol_mute)
233         elseif tonumber(volume_now.level) == 0 then
234             volicon:set_image(theme.widget_vol_no)
235         elseif tonumber(volume_now.level) <= 50 then
236             volicon:set_image(theme.widget_vol_low)
237         else
238             volicon:set_image(theme.widget_vol)
239         end
240
241         widget:set_markup(markup.font(theme.font, " " .. volume_now.level .. "% "))
242     end
243 })
244 theme.volume.widget:buttons(awful.util.table.join(
245                                awful.button({}, 4, function ()
246                                      awful.util.spawn("amixer set Master 1%+")
247                                      theme.volume.update()
248                                end),
249                                awful.button({}, 5, function ()
250                                      awful.util.spawn("amixer set Master 1%-")
251                                      theme.volume.update()
252                                end)
253 ))
254
255 -- Net
256 local neticon = wibox.widget.imagebox(theme.widget_net)
257 local net = lain.widget.net({
258     settings = function()
259         widget:set_markup(markup.font(theme.font,
260                           markup("#7AC82E", " " .. string.format("%06.1f", net_now.received))
261                           .. " " ..
262                           markup("#46A8C3", " " .. string.format("%06.1f", net_now.sent) .. " ")))
263     end
264 })
265
266 -- Separators
267 local spr     = wibox.widget.textbox(' ')
268 local arrl_dl = separators.arrow_left(theme.bg_focus, "alpha")
269 local arrl_ld = separators.arrow_left("alpha", theme.bg_focus)
270
271 function theme.at_screen_connect(s)
272     -- Quake application
273     s.quake = lain.util.quake({ app = awful.util.terminal })
274
275     -- If wallpaper is a function, call it with the screen
276     local wallpaper = theme.wallpaper
277     if type(wallpaper) == "function" then
278         wallpaper = wallpaper(s)
279     end
280     gears.wallpaper.maximized(wallpaper, s, true)
281
282     -- Tags
283     awful.tag(awful.util.tagnames, s, awful.layout.layouts)
284
285     -- Create a promptbox for each screen
286     s.mypromptbox = awful.widget.prompt()
287     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
288     -- We need one layoutbox per screen.
289     s.mylayoutbox = awful.widget.layoutbox(s)
290     s.mylayoutbox:buttons(my_table.join(
291                            awful.button({}, 1, function () awful.layout.inc( 1) end),
292                            awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
293                            awful.button({}, 3, function () awful.layout.inc(-1) end),
294                            awful.button({}, 4, function () awful.layout.inc( 1) end),
295                            awful.button({}, 5, function () awful.layout.inc(-1) end)))
296     -- Create a taglist widget
297     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
298
299     -- Create a tasklist widget
300     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
301
302     -- Create the wibox
303     s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(18), bg = theme.bg_normal, fg = theme.fg_normal })
304
305     -- Add widgets to the wibox
306     s.mywibox:setup {
307         layout = wibox.layout.align.horizontal,
308         { -- Left widgets
309             layout = wibox.layout.fixed.horizontal,
310             --spr,
311             s.mytaglist,
312             s.mypromptbox,
313             spr,
314         },
315         s.mytasklist, -- Middle widget
316         { -- Right widgets
317             layout = wibox.layout.fixed.horizontal,
318             wibox.widget.systray(),
319             spr,
320             arrl_ld,
321             wibox.container.background(mpdicon, theme.bg_focus),
322             wibox.container.background(theme.mpd.widget, theme.bg_focus),
323             arrl_dl,
324             volicon,
325             theme.volume.widget,
326             arrl_ld,
327             wibox.container.background(mailicon, theme.bg_focus),
328             --wibox.container.background(theme.mail.widget, theme.bg_focus),
329             arrl_dl,
330             memicon,
331             mem.widget,
332             arrl_ld,
333             wibox.container.background(cpuicon, theme.bg_focus),
334             wibox.container.background(cpu.widget, theme.bg_focus),
335             arrl_dl,
336             tempicon,
337             temp.widget,
338             arrl_ld,
339             wibox.container.background(fsicon, theme.bg_focus),
340             --wibox.container.background(theme.fs.widget, theme.bg_focus),
341             arrl_dl,
342             baticon,
343             bat.widget,
344             arrl_ld,
345             wibox.container.background(neticon, theme.bg_focus),
346             wibox.container.background(net.widget, theme.bg_focus),
347             arrl_dl,
348             clock,
349             spr,
350             arrl_ld,
351             wibox.container.background(s.mylayoutbox, theme.bg_focus),
352         },
353     }
354 end
355
356 return theme