1669595574da2caf6cef98ccbc2440df160817d6
[dotfiles/.git] / .config / awesome / themes / blackburn / theme.lua
1 --[[
2
3      Blackburn 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 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/blackburn"
19 theme.wallpaper                                 = theme.dir .. "/wall.png"
20 theme.font                                      = "Terminus 10.5"
21 theme.taglist_font                              = "Icons 10"
22 theme.fg_normal                                 = "#D7D7D7"
23 theme.fg_focus                                  = "#F6784F"
24 theme.bg_normal                                 = "#060606"
25 theme.bg_focus                                  = "#060606"
26 theme.fg_urgent                                 = "#CC9393"
27 theme.bg_urgent                                 = "#2A1F1E"
28 theme.border_width                              = dpi(1)
29 theme.border_normal                             = "#0E0E0E"
30 theme.border_focus                              = "#F79372"
31 theme.taglist_fg_focus                          = "#F6784F"
32 theme.taglist_bg_focus                          = "#060606"
33 theme.tasklist_fg_focus                         = "#F6784F"
34 theme.tasklist_bg_focus                         = "#060606"
35 theme.menu_height                               = dpi(16)
36 theme.menu_width                                = dpi(130)
37 theme.menu_submenu_icon                         = theme.dir .. "/icons/submenu.png"
38 theme.awesome_icon                              = theme.dir .."/icons/awesome.png"
39 theme.taglist_squares_sel                       = theme.dir .. "/icons/square_sel.png"
40 theme.taglist_squares_unsel                     = theme.dir .. "/icons/square_unsel.png"
41 theme.layout_tile                               = theme.dir .. "/icons/tile.png"
42 theme.layout_tileleft                           = theme.dir .. "/icons/tileleft.png"
43 theme.layout_tilebottom                         = theme.dir .. "/icons/tilebottom.png"
44 theme.layout_tiletop                            = theme.dir .. "/icons/tiletop.png"
45 theme.layout_fairv                              = theme.dir .. "/icons/fairv.png"
46 theme.layout_fairh                              = theme.dir .. "/icons/fairh.png"
47 theme.layout_spiral                             = theme.dir .. "/icons/spiral.png"
48 theme.layout_dwindle                            = theme.dir .. "/icons/dwindle.png"
49 theme.layout_max                                = theme.dir .. "/icons/max.png"
50 theme.layout_fullscreen                         = theme.dir .. "/icons/fullscreen.png"
51 theme.layout_magnifier                          = theme.dir .. "/icons/magnifier.png"
52 theme.layout_floating                           = theme.dir .. "/icons/floating.png"
53 theme.tasklist_plain_task_name                  = true
54 theme.tasklist_disable_icon                     = true
55 theme.useless_gap                               = 0
56 theme.titlebar_close_button_focus               = theme.dir .. "/icons/titlebar/close_focus.png"
57 theme.titlebar_close_button_normal              = theme.dir .. "/icons/titlebar/close_normal.png"
58 theme.titlebar_ontop_button_focus_active        = theme.dir .. "/icons/titlebar/ontop_focus_active.png"
59 theme.titlebar_ontop_button_normal_active       = theme.dir .. "/icons/titlebar/ontop_normal_active.png"
60 theme.titlebar_ontop_button_focus_inactive      = theme.dir .. "/icons/titlebar/ontop_focus_inactive.png"
61 theme.titlebar_ontop_button_normal_inactive     = theme.dir .. "/icons/titlebar/ontop_normal_inactive.png"
62 theme.titlebar_sticky_button_focus_active       = theme.dir .. "/icons/titlebar/sticky_focus_active.png"
63 theme.titlebar_sticky_button_normal_active      = theme.dir .. "/icons/titlebar/sticky_normal_active.png"
64 theme.titlebar_sticky_button_focus_inactive     = theme.dir .. "/icons/titlebar/sticky_focus_inactive.png"
65 theme.titlebar_sticky_button_normal_inactive    = theme.dir .. "/icons/titlebar/sticky_normal_inactive.png"
66 theme.titlebar_floating_button_focus_active     = theme.dir .. "/icons/titlebar/floating_focus_active.png"
67 theme.titlebar_floating_button_normal_active    = theme.dir .. "/icons/titlebar/floating_normal_active.png"
68 theme.titlebar_floating_button_focus_inactive   = theme.dir .. "/icons/titlebar/floating_focus_inactive.png"
69 theme.titlebar_floating_button_normal_inactive  = theme.dir .. "/icons/titlebar/floating_normal_inactive.png"
70 theme.titlebar_maximized_button_focus_active    = theme.dir .. "/icons/titlebar/maximized_focus_active.png"
71 theme.titlebar_maximized_button_normal_active   = theme.dir .. "/icons/titlebar/maximized_normal_active.png"
72 theme.titlebar_maximized_button_focus_inactive  = theme.dir .. "/icons/titlebar/maximized_focus_inactive.png"
73 theme.titlebar_maximized_button_normal_inactive = theme.dir .. "/icons/titlebar/maximized_normal_inactive.png"
74
75 awful.util.tagnames   = { "ƀ", "Ƅ", "Ɗ", "ƈ", "ƙ" }
76
77 local markup     = lain.util.markup
78 local separators = lain.util.separators
79 local gray       = "#9E9C9A"
80
81 -- Textclock
82 local mytextclock = wibox.widget.textclock(" %H:%M ")
83 mytextclock.font = theme.font
84
85 -- Calendar
86 theme.cal = lain.widget.cal({
87     attach_to = { mytextclock },
88     notification_preset = {
89         font = "Terminus 11",
90         fg   = theme.fg_normal,
91         bg   = theme.bg_normal
92     }
93 })
94
95 -- Mail IMAP check
96 --[[ commented because it needs to be set before use
97 theme.mail = lain.widget.imap({
98     timeout  = 180,
99     server   = "server",
100     mail     = "mail",
101     password = "keyring get mail",
102     notification_preset = { fg = white }
103     settings = function()
104         mail  = ""
105         count = ""
106
107         if mailcount > 0 then
108             mail = "Mail "
109             count = mailcount .. " "
110         end
111
112         widget:set_markup(markup.font(theme.font, markup(gray, mail) .. count))
113     end
114 })
115 --]]
116
117 -- MPD
118 theme.mpd = lain.widget.mpd({
119     settings = function()
120         mpd_notification_preset.fg = white
121         artist = mpd_now.artist .. " "
122         title  = mpd_now.title  .. " "
123
124         if mpd_now.state == "pause" then
125             artist = "mpd "
126             title  = "paused "
127         elseif mpd_now.state == "stop" then
128             artist = ""
129             title  = ""
130         end
131
132         widget:set_markup(markup.font(theme.font, markup(gray, artist) .. title .. " "))
133     end
134 })
135
136 -- /home fs
137 --[[ commented because it needs Gio/Glib >= 2.54
138 theme.fs = lain.widget.fs({
139     notification_preset = { fg = white, bg = theme.bg_normal, font = "Terminus 10.5" },
140     settings  = function()
141         fs_header = ""
142         fs_p      = ""
143
144         if fs_now["/home"].percentage >= 90 then
145             fs_header = " Hdd "
146             fs_p      = fs_now["/home"].percentage
147         end
148
149         widget:set_markup(markup.font(theme.font, markup(gray, fs_header) .. fs_p))
150     end
151 })
152 --]]
153
154 -- Battery
155 local bat = lain.widget.bat({
156     settings = function()
157         bat_header = " Bat "
158         bat_p      = bat_now.perc .. " "
159         widget:set_markup(markup.font(theme.font, markup(gray, bat_header) .. bat_p))
160     end
161 })
162
163 -- ALSA volume
164 theme.volume = lain.widget.alsa({
165     --togglechannel = "IEC958,3",
166     settings = function()
167         header = " Vol "
168         vlevel  = volume_now.level
169
170         if volume_now.status == "off" then
171             vlevel = vlevel .. "M "
172         else
173             vlevel = vlevel .. " "
174         end
175
176         widget:set_markup(markup.font(theme.font, markup(gray, header) .. vlevel))
177     end
178 })
179
180 -- Weather
181 theme.weather = lain.widget.weather({
182     city_id = 2643743, -- placeholder (London)
183     settings = function()
184         units = math.floor(weather_now["main"]["temp"])
185         widget:set_markup(" " .. units .. " ")
186     end
187 })
188
189 -- Separators
190 local first     = wibox.widget.textbox('<span font="Terminus 4"> </span>')
191 local arrl_pre  = separators.arrow_right("alpha", "#1A1A1A")
192 local arrl_post = separators.arrow_right("#1A1A1A", "alpha")
193
194 local barheight = dpi(18)
195 local barcolor  = gears.color({
196     type  = "linear",
197     from  = { barheight, 0 },
198     to    = { barheight, barheight },
199     stops = { {0, theme.bg_focus }, {0.8, theme.border_normal}, {1, "#1A1A1A"} }
200 })
201 theme.titlebar_bg = barcolor
202
203 theme.titlebar_bg_focus = gears.color({
204     type  = "linear",
205     from  = { barheight, 0 },
206     to    = { barheight, barheight },
207     stops = { {0, theme.bg_normal}, {0.5, theme.border_normal}, {1, "#492417"} }
208 })
209
210 function theme.at_screen_connect(s)
211     -- Quake application
212     s.quake = lain.util.quake({ app = awful.util.terminal })
213
214     -- If wallpaper is a function, call it with the screen
215     local wallpaper = theme.wallpaper
216     if type(wallpaper) == "function" then
217         wallpaper = wallpaper(s)
218     end
219     gears.wallpaper.maximized(wallpaper, s, true)
220
221     -- Tags
222     awful.tag(awful.util.tagnames, s, awful.layout.layouts)
223
224     -- Create a promptbox for each screen
225     s.mypromptbox = awful.widget.prompt()
226     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
227     -- We need one layoutbox per screen.
228     s.mylayoutbox = awful.widget.layoutbox(s)
229     s.mylayoutbox:buttons(my_table.join(
230                            awful.button({}, 1, function () awful.layout.inc( 1) end),
231                            awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
232                            awful.button({}, 3, function () awful.layout.inc(-1) end),
233                            awful.button({}, 4, function () awful.layout.inc( 1) end),
234                            awful.button({}, 5, function () awful.layout.inc(-1) end)))
235
236     -- Create a taglist widget
237     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
238
239     -- Create a tasklist widget
240     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons, { bg_normal = barcolor, bg_focus = barcolor })
241
242     -- Create the wibox
243     s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(18), bg = barcolor })
244
245     -- Add widgets to the wibox
246     s.mywibox:setup {
247         layout = wibox.layout.align.horizontal,
248         { -- Left widgets
249             layout = wibox.layout.fixed.horizontal,
250             first,
251             s.mytaglist,
252             arrl_pre,
253             s.mylayoutbox,
254             arrl_post,
255             s.mypromptbox,
256             first,
257         },
258         s.mytasklist, -- Middle widget
259         { -- Right widgets
260             layout = wibox.layout.fixed.horizontal,
261             wibox.widget.systray(),
262             first,
263             theme.mpd.widget,
264             --theme.mail.widget,
265             theme.weather.icon,
266             theme.weather.widget,
267             --theme.fs.widget,
268             bat,
269             theme.volume.widget,
270             mytextclock,
271         },
272     }
273 end
274
275 return theme