Actualizacion maquina principal
[dotfiles/.git] / .config / awesome / themes / rainbow / theme.lua
1 --[[
2
3      Rainbow 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.default_dir                               = require("awful.util").get_themes_dir() .. "default"
19 theme.dir                                       = os.getenv("HOME") .. "/.config/awesome/themes/rainbow"
20 theme.wallpaper                                 = theme.dir .. "/wall.png"
21 theme.font                                      = "Terminus 10.5"
22 theme.fg_normal                                 = "#9E9E9E"
23 theme.fg_focus                                  = "#EBEBFF"
24 theme.bg_normal                                 = "#242424"
25 theme.bg_focus                                  = "#242424"
26 theme.fg_urgent                                 = "#000000"
27 theme.bg_urgent                                 = "#FFFFFF"
28 theme.border_width                              = dpi(1)
29 theme.border_normal                             = "#242424"
30 theme.border_focus                              = "#EBEBFF"
31 theme.taglist_fg_focus                          = "#EDEFFF"
32 theme.taglist_bg_focus                          = "#242424"
33 theme.menu_height                               = dpi(16)
34 theme.menu_width                                = dpi(140)
35 theme.ocol                                      = "<span color='" .. theme.fg_normal .. "'>"
36 theme.tasklist_sticky                           = theme.ocol .. "[S]</span>"
37 theme.tasklist_ontop                            = theme.ocol .. "[T]</span>"
38 theme.tasklist_floating                         = theme.ocol .. "[F]</span>"
39 theme.tasklist_maximized_horizontal             = theme.ocol .. "[M] </span>"
40 theme.tasklist_maximized_vertical               = ""
41 theme.tasklist_disable_icon                     = true
42 theme.awesome_icon                              = theme.dir .."/icons/awesome.png"
43 theme.menu_submenu_icon                         = theme.dir .."/icons/submenu.png"
44 theme.taglist_squares_sel                       = theme.dir .. "/icons/square_sel.png"
45 theme.taglist_squares_unsel                     = theme.dir .. "/icons/square_unsel.png"
46 theme.useless_gap                               = dpi(8)
47 theme.layout_txt_tile                           = "[t]"
48 theme.layout_txt_tileleft                       = "[l]"
49 theme.layout_txt_tilebottom                     = "[b]"
50 theme.layout_txt_tiletop                        = "[tt]"
51 theme.layout_txt_fairv                          = "[fv]"
52 theme.layout_txt_fairh                          = "[fh]"
53 theme.layout_txt_spiral                         = "[s]"
54 theme.layout_txt_dwindle                        = "[d]"
55 theme.layout_txt_max                            = "[m]"
56 theme.layout_txt_fullscreen                     = "[F]"
57 theme.layout_txt_magnifier                      = "[M]"
58 theme.layout_txt_floating                       = "[*]"
59 theme.titlebar_close_button_normal              = theme.default_dir.."/titlebar/close_normal.png"
60 theme.titlebar_close_button_focus               = theme.default_dir.."/titlebar/close_focus.png"
61 theme.titlebar_minimize_button_normal           = theme.default_dir.."/titlebar/minimize_normal.png"
62 theme.titlebar_minimize_button_focus            = theme.default_dir.."/titlebar/minimize_focus.png"
63 theme.titlebar_ontop_button_normal_inactive     = theme.default_dir.."/titlebar/ontop_normal_inactive.png"
64 theme.titlebar_ontop_button_focus_inactive      = theme.default_dir.."/titlebar/ontop_focus_inactive.png"
65 theme.titlebar_ontop_button_normal_active       = theme.default_dir.."/titlebar/ontop_normal_active.png"
66 theme.titlebar_ontop_button_focus_active        = theme.default_dir.."/titlebar/ontop_focus_active.png"
67 theme.titlebar_sticky_button_normal_inactive    = theme.default_dir.."/titlebar/sticky_normal_inactive.png"
68 theme.titlebar_sticky_button_focus_inactive     = theme.default_dir.."/titlebar/sticky_focus_inactive.png"
69 theme.titlebar_sticky_button_normal_active      = theme.default_dir.."/titlebar/sticky_normal_active.png"
70 theme.titlebar_sticky_button_focus_active       = theme.default_dir.."/titlebar/sticky_focus_active.png"
71 theme.titlebar_floating_button_normal_inactive  = theme.default_dir.."/titlebar/floating_normal_inactive.png"
72 theme.titlebar_floating_button_focus_inactive   = theme.default_dir.."/titlebar/floating_focus_inactive.png"
73 theme.titlebar_floating_button_normal_active    = theme.default_dir.."/titlebar/floating_normal_active.png"
74 theme.titlebar_floating_button_focus_active     = theme.default_dir.."/titlebar/floating_focus_active.png"
75 theme.titlebar_maximized_button_normal_inactive = theme.default_dir.."/titlebar/maximized_normal_inactive.png"
76 theme.titlebar_maximized_button_focus_inactive  = theme.default_dir.."/titlebar/maximized_focus_inactive.png"
77 theme.titlebar_maximized_button_normal_active   = theme.default_dir.."/titlebar/maximized_normal_active.png"
78 theme.titlebar_maximized_button_focus_active    = theme.default_dir.."/titlebar/maximized_focus_active.png"
79
80 -- lain related
81 theme.layout_txt_cascade                        = "[cascade]"
82 theme.layout_txt_cascadetile                    = "[cascadetile]"
83 theme.layout_txt_centerwork                     = "[centerwork]"
84 theme.layout_txt_termfair                       = "[termfair]"
85 theme.layout_txt_centerfair                     = "[centerfair]"
86
87 local markup = lain.util.markup
88 local white  = theme.fg_focus
89 local gray   = theme.fg_normal
90
91 -- Textclock
92 local mytextclock = wibox.widget.textclock(markup(white, " %H:%M "))
93 mytextclock.font = theme.font
94
95 -- Calendar
96 theme.cal = lain.widget.cal({
97     attach_to = { mytextclock },
98     notification_preset = {
99         font = "Terminus 11",
100         fg   = white,
101         bg   = theme.bg_normal
102     }
103 })
104
105 -- Mail IMAP check
106 --[[ commented because it needs to be set before use
107 theme.mail = lain.widget.imap({
108     timeout  = 180,
109     server   = "server",
110     mail     = "mail",
111     password = "keyring get mail",
112     settings = function()
113         mail_notification_preset.fg = white
114
115         mail  = ""
116         count = ""
117
118         if mailcount > 0 then
119             mail = "Mail "
120             count = mailcount .. " "
121         end
122
123         widget:set_markup(markup.font(theme.font, markup(gray, mail) .. markup(white, count)))
124     end
125 })
126 --]]
127
128 -- MPD
129 theme.mpd = lain.widget.mpd({
130     settings = function()
131         mpd_notification_preset.fg = white
132
133         artist = mpd_now.artist .. " "
134         title  = mpd_now.title  .. " "
135
136         if mpd_now.state == "pause" then
137             artist = "mpd "
138             title  = "paused "
139         elseif mpd_now.state == "stop" then
140             artist = ""
141             title  = ""
142         end
143
144         widget:set_markup(markup.font(theme.font, markup(gray, artist) .. markup(white, title)))
145     end
146 })
147
148 -- /home fs
149 --[[ commented because it needs Gio/Glib >= 2.54
150 theme.fs = lain.widget.fs({
151     notification_preset = { fg = white, bg = theme.bg_normal, font = "Terminus 10.5" },
152     settings  = function()
153         local fs_header, fs_p = "", ""
154
155         if fs_now["/home"].percentage >= 90 then
156             fs_header = " Hdd "
157             fs_p      = fs_now["/home"].percentage
158         end
159
160         widget:set_markup(markup.font(theme.font, markup(gray, fs_header) .. markup(white, fs_p)))
161     end
162 })
163 --]]
164
165 -- ALSA volume bar
166 theme.volume = lain.widget.alsabar({
167     ticks = true, width = dpi(67),
168     notification_preset = { font = theme.font }
169 })
170 theme.volume.tooltip.wibox.fg = theme.fg_focus
171 theme.volume.tooltip.wibox.font = theme.font
172 theme.volume.bar:buttons(my_table.join (
173           awful.button({}, 1, function()
174             awful.spawn(string.format("%s -e alsamixer", terminal))
175           end),
176           awful.button({}, 2, function()
177             os.execute(string.format("%s set %s 100%%", theme.volume.cmd, theme.volume.channel))
178             theme.volume.update()
179           end),
180           awful.button({}, 3, function()
181             os.execute(string.format("%s set %s toggle", theme.volume.cmd, theme.volume.togglechannel or theme.volume.channel))
182             theme.volume.update()
183           end),
184           awful.button({}, 4, function()
185             os.execute(string.format("%s set %s 1%%+", theme.volume.cmd, theme.volume.channel))
186             theme.volume.update()
187           end),
188           awful.button({}, 5, function()
189             os.execute(string.format("%s set %s 1%%-", theme.volume.cmd, theme.volume.channel))
190             theme.volume.update()
191           end)
192 ))
193 local volumebg = wibox.container.background(theme.volume.bar, "#585858", gears.shape.rectangle)
194 local volumewidget = wibox.container.margin(volumebg, dpi(7), dpi(7), dpi(5), dpi(5))
195
196 -- Weather
197 theme.weather = lain.widget.weather({
198     city_id = 2643743, -- placeholder (London)
199     notification_preset = { font = theme.font, fg = white }
200 })
201
202 -- Separators
203 local first = wibox.widget.textbox(markup.font("Terminus 4", " "))
204 local spr   = wibox.widget.textbox(' ')
205
206 local function update_txt_layoutbox(s)
207     -- Writes a string representation of the current layout in a textbox widget
208     local txt_l = theme["layout_txt_" .. awful.layout.getname(awful.layout.get(s))] or ""
209     s.mytxtlayoutbox:set_text(txt_l)
210 end
211
212 function theme.at_screen_connect(s)
213     -- Quake application
214     s.quake = lain.util.quake({ app = awful.util.terminal })
215
216     -- If wallpaper is a function, call it with the screen
217     local wallpaper = theme.wallpaper
218     if type(wallpaper) == "function" then
219         wallpaper = wallpaper(s)
220     end
221     gears.wallpaper.maximized(wallpaper, s, true)
222
223     -- Tags
224     awful.tag(awful.util.tagnames, s, awful.layout.layouts)
225
226     -- Create a promptbox for each screen
227     s.mypromptbox = awful.widget.prompt()
228
229     -- Textual layoutbox
230     s.mytxtlayoutbox = wibox.widget.textbox(theme["layout_txt_" .. awful.layout.getname(awful.layout.get(s))])
231     awful.tag.attached_connect_signal(s, "property::selected", function () update_txt_layoutbox(s) end)
232     awful.tag.attached_connect_signal(s, "property::layout", function () update_txt_layoutbox(s) end)
233     s.mytxtlayoutbox:buttons(my_table.join(
234                            awful.button({}, 1, function() awful.layout.inc(1) end),
235                            awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[1] ) end),
236                            awful.button({}, 3, function() awful.layout.inc(-1) end),
237                            awful.button({}, 4, function() awful.layout.inc(1) end),
238                            awful.button({}, 5, function() awful.layout.inc(-1) end)))
239
240     -- Create a taglist widget
241     s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
242
243     -- Create a tasklist widget
244     s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
245
246     -- Create the wibox
247     s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(18), bg = theme.bg_normal, fg = theme.fg_normal })
248
249     -- Add widgets to the wibox
250     s.mywibox:setup {
251         layout = wibox.layout.align.horizontal,
252         { -- Left widgets
253             layout = wibox.layout.fixed.horizontal,
254             first,
255             s.mytaglist,
256             spr,
257             s.mytxtlayoutbox,
258             --spr,
259             s.mypromptbox,
260             spr,
261         },
262         s.mytasklist, -- Middle widget
263         { -- Right widgets
264             layout = wibox.layout.fixed.horizontal,
265             wibox.widget.systray(),
266             spr,
267             theme.mpd.widget,
268             --theme.mail.widget,
269             --theme.fs.widget,
270             volumewidget,
271             mytextclock,
272         },
273     }
274 end
275
276 return theme