Advertisement
msjche

MoJo's Awesome theme.lua

Mar 24th, 2020
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.62 KB | None | 0 0
  1. -- theme.lua by msjche
  2. -- forked from github copycatkiller's copland theme
  3.  
  4. local gears = require("gears")
  5. local lain = require("lain")
  6. local awful = require("awful")
  7. local wibox = require("wibox")
  8. local os = { getenv = os.getenv, setlocale = os.setlocale }
  9. local awesome, client = awesome, client
  10. local brightnessarc_widget = require("widgets.brightnessarc")
  11. local cpu_widget = require("widgets.cpu-widget")
  12. local volumearc_widget = require("widgets.volumearc")
  13. local batteryarc_widget = require("widgets.batteryarc-widget.batteryarc")
  14. local fs_widget = require("widgets.fs-widget")
  15. local ram_widget = require("widgets.ram-widget")
  16. local net_widgets = require("net_widgets")
  17.  
  18. local theme = {}
  19. theme.dir = os.getenv("HOME") .. "/.config/awesome/themes/msjche"
  20. theme.wallpaper = theme.dir .. "/wall.png"
  21. theme.font = "Dejavu Sans 13"
  22. theme.taglist_font = "Xirod 14"
  23. theme.fg_normal = "#757575"
  24. theme.fg_focus = "#1793d0"
  25. theme.bg_normal = "#11111199"
  26. theme.bg_focus = "#11111199"
  27. theme.fg_urgent = "#000000"
  28. theme.bg_urgent = "#FFFFFF"
  29. theme.border_width = 3
  30. theme.border_normal = "#141414"
  31. theme.border_focus = "#1793D090"
  32. theme.taglist_fg_focus = "#FFFFFF"
  33. theme.taglist_bg_focus = "#111111"
  34. theme.taglist_bg_normal = "#111111"
  35. theme.titlebar_bg_normal = "#191919"
  36. theme.titlebar_bg_focus = "#262626"
  37. theme.menu_height = 25
  38. theme.menu_width = 250
  39. theme.tasklist_disable_icon = true
  40. theme.awesome_icon = theme.dir .."/icons/awesome.png"
  41. theme.menu_submenu_icon = theme.dir .. "/icons/submenu.png"
  42. theme.taglist_squares_sel = theme.dir .. "/icons/square_unsel.png"
  43. theme.taglist_squares_unsel = theme.dir .. "/icons/square_unsel.png"
  44. theme.vol = theme.dir .. "/icons/vol.png"
  45. theme.vol_low = theme.dir .. "/icons/vol_low.png"
  46. theme.vol_no = theme.dir .. "/icons/vol_no.png"
  47. theme.vol_mute = theme.dir .. "/icons/vol_mute.png"
  48. theme.disk = theme.dir .. "/icons/disk.png"
  49. theme.ac = theme.dir .. "/icons/ac.png"
  50. theme.bat = theme.dir .. "/icons/bat.png"
  51. theme.bat_low = theme.dir .. "/icons/bat_low.png"
  52. theme.bat_no = theme.dir .. "/icons/bat_no.png"
  53. theme.bat_full = theme.dir .. "/icons/bat_full.png"
  54. theme.bat_90 = theme.dir .. "/icons/bat_90.png"
  55. theme.bat_80 = theme.dir .. "/icons/bat_80.png"
  56. theme.bat_70 = theme.dir .. "/icons/bat_70.png"
  57. theme.bat_60 = theme.dir .. "/icons/bat_60.png"
  58. theme.bat_50 = theme.dir .. "/icons/bat_50.png"
  59. theme.bat_40 = theme.dir .. "/icons/bat_40.png"
  60. theme.bat_30 = theme.dir .. "/icons/bat_30.png"
  61. theme.bat_20 = theme.dir .. "/icons/bat_20.png"
  62. theme.bat_10 = theme.dir .. "/icons/bat_10.png"
  63. theme.bat_empty = theme.dir .. "/icons/bat_empty.png"
  64. theme.charged_ac = theme.dir .. "/icons/charged_ac.png"
  65. theme.charge_full = theme.dir .. "/icons/charge_full.png"
  66. theme.charge_90 = theme.dir .. "/icons/charge_90.png"
  67. theme.charge_80 = theme.dir .. "/icons/charge_80.png"
  68. theme.charge_70 = theme.dir .. "/icons/charge_70.png"
  69. theme.charge_60 = theme.dir .. "/icons/charge_60.png"
  70. theme.charge_50 = theme.dir .. "/icons/charge_50.png"
  71. theme.charge_40 = theme.dir .. "/icons/charge_40.png"
  72. theme.charge_30 = theme.dir .. "/icons/charge_30.png"
  73. theme.charge_20 = theme.dir .. "/icons/charge_20.png"
  74. theme.charge_10 = theme.dir .. "/icons/charge_10.png"
  75. theme.charge_empty = theme.dir .. "/icons/charge_empty.png"
  76. theme.play = theme.dir .. "/icons/play.png"
  77. theme.pause = theme.dir .. "/icons/pause.png"
  78. theme.stop = theme.dir .. "/icons/stop.png"
  79. theme.layout_tile = theme.dir .. "/icons/tile.png"
  80. theme.layout_tileleft = theme.dir .. "/icons/tileleft.png"
  81. theme.layout_tilebottom = theme.dir .. "/icons/tilebottom.png"
  82. theme.layout_tiletop = theme.dir .. "/icons/tiletop.png"
  83. theme.layout_fairv = theme.dir .. "/icons/fairv.png"
  84. theme.layout_fairh = theme.dir .. "/icons/fairh.png"
  85. theme.layout_spiral = theme.dir .. "/icons/spiral.png"
  86. theme.layout_dwindle = theme.dir .. "/icons/dwindle.png"
  87. theme.layout_max = theme.dir .. "/icons/max.png"
  88. theme.layout_fullscreen = theme.dir .. "/icons/fullscreen.png"
  89. theme.layout_magnifier = theme.dir .. "/icons/magnifier.png"
  90. theme.layout_floating = theme.dir .. "/icons/floating.png"
  91. theme.useless_gap = 4
  92. theme.titlebar_close_button_focus = theme.dir .. "/icons/titlebar/close_focus.png"
  93. theme.titlebar_close_button_normal = theme.dir .. "/icons/titlebar/close_normal.png"
  94. theme.titlebar_ontop_button_focus_active = theme.dir .. "/icons/titlebar/ontop_focus_active.png"
  95. theme.titlebar_ontop_button_normal_active = theme.dir .. "/icons/titlebar/ontop_normal_active.png"
  96. theme.titlebar_ontop_button_focus_inactive = theme.dir .. "/icons/titlebar/ontop_focus_inactive.png"
  97. theme.titlebar_ontop_button_normal_inactive = theme.dir .. "/icons/titlebar/ontop_normal_inactive.png"
  98. theme.titlebar_sticky_button_focus_active = theme.dir .. "/icons/titlebar/sticky_focus_active.png"
  99. theme.titlebar_sticky_button_normal_active = theme.dir .. "/icons/titlebar/sticky_normal_active.png"
  100. theme.titlebar_sticky_button_focus_inactive = theme.dir .. "/icons/titlebar/sticky_focus_inactive.png"
  101. theme.titlebar_sticky_button_normal_inactive = theme.dir .. "/icons/titlebar/sticky_normal_inactive.png"
  102. theme.titlebar_floating_button_focus_active = theme.dir .. "/icons/titlebar/floating_focus_active.png"
  103. theme.titlebar_floating_button_normal_active = theme.dir .. "/icons/titlebar/floating_normal_active.png"
  104. theme.titlebar_floating_button_focus_inactive = theme.dir .. "/icons/titlebar/floating_focus_inactive.png"
  105. theme.titlebar_floating_button_normal_inactive = theme.dir .. "/icons/titlebar/floating_normal_inactive.png"
  106. theme.titlebar_maximized_button_focus_active = theme.dir .. "/icons/titlebar/maximized_focus_active.png"
  107. theme.titlebar_maximized_button_normal_active = theme.dir .. "/icons/titlebar/maximized_normal_active.png"
  108. theme.titlebar_maximized_button_focus_inactive = theme.dir .. "/icons/titlebar/maximized_focus_inactive.png"
  109. theme.titlebar_maximized_button_normal_inactive = theme.dir .. "/icons/titlebar/maximized_normal_inactive.png"
  110.  
  111. -- lain related
  112. theme.layout_centerfair = theme.dir .. "/icons/centerfair.png"
  113. theme.layout_termfair = theme.dir .. "/icons/termfair.png"
  114. theme.layout_centerwork = theme.dir .. "/icons/centerwork.png"
  115.  
  116. local markup = lain.util.markup
  117. local blue = theme.fg_focus
  118. local red = "#EB8F8F"
  119. local green = "#8FEB8F"
  120. local white = theme.fg_normal
  121.  
  122. -- Awesome WM Widgets
  123. theme.widget_main_color = "#74aeab"
  124. theme.widget_red = "#e53935"
  125. theme.widget_yelow = "#c0ca33"
  126. theme.widget_green = "#43a047"
  127. theme.widget_black = "#000000"
  128. theme.widget_transparent = "#00000000"
  129.  
  130. local mytextclock = wibox.widget.textclock(markup(blue, " %a") .. markup(white, " %d ") .. markup(blue, "%b ") .. markup(white, "%H:%M "))
  131. mytextclock.font = theme.font
  132.  
  133. --local corona = awful.widget.watch('corona', 15)
  134. --corona.font = theme.font
  135.  
  136. --local uptimewidget = wibox.widget.textbox(vicious.widget.uptime, (markup(blue, "$1") .. markup(white, " D") .. markup(blue, " $2") .. markup(white, " h"))
  137. --lock.font = theme.font
  138.  
  139. -- Calendar
  140. lain.widget.calendar({
  141. attach_to = { mytextclock },
  142. notification_preset = {
  143. font = "Play Mono 13",
  144. fg = white,
  145. bg = theme.bg_normal
  146. }})
  147.  
  148. -- Launcher
  149. local mylauncher = awful.widget.button({image = theme.awesome_icon})
  150. mylauncher:connect_signal("button::press", function() awful.util.mymainmenu:toggle() end)
  151.  
  152. -- WiFi signal
  153. net_wireless = net_widgets.wireless({
  154. -- onclick = terminal .. "-e sudo wifi-menu",
  155. interface="wlo1",
  156. popup_signal=true
  157. })
  158.  
  159. local net = lain.widget.net({
  160. settings = function()
  161. widget:set_markup(
  162. markup("#7AC82E", " " .. net_now.received)
  163. .. " " ..
  164. markup("#46A8C3", " " .. net_now.sent) .. " ")
  165. end
  166. })
  167.  
  168. -- MPD
  169. local mpdicon = wibox.widget.imagebox()
  170. theme.mpd = lain.widget.mpd({
  171. settings = function()
  172. if mpd_now.state == "play" then
  173. title = markup("#1ed760", " " .. mpd_now.title)
  174. artist = mpd_now.artist
  175. spacer = " | "
  176. mpdicon:set_image(theme.play)
  177. elseif mpd_now.state == "pause" then
  178. title = ""
  179. artist = ""
  180. spacer = ""
  181. mpdicon:set_image(theme.pause)
  182. else
  183. title = ""
  184. artist = ""
  185. spacer = ""
  186. mpdicon._private.image = nil
  187. mpdicon:emit_signal("widget::redraw_needed")
  188. mpdicon:emit_signal("widget::layout_changed")
  189. end
  190.  
  191. widget:set_markup(title .. spacer .. artist)
  192. theme.mpd.widget.font = theme.font
  193. end
  194. })
  195.  
  196. -- Battery
  197.  
  198. local baticon = wibox.widget.imagebox(theme.bat)
  199.  
  200. local batwidget = lain.widget.bat({
  201.  
  202. settings = function()
  203. if bat_now.status == "N/A" or type(bat_now.perc) ~= "number" then return end
  204.  
  205. if bat_now.status == "Charging" then
  206. baticon:set_image(theme.charged_ac)
  207. if bat_now.perc >= 92 then
  208. baticon:set_image(theme.charge_full)
  209. batwidget = widget:set_markup(markup(green, " " .. bat_now.time))
  210. elseif bat_now.perc >= 85 and bat_now.perc < 92 then
  211. baticon:set_image(theme.charge_90)
  212. batwidget = widget:set_markup(markup(green, " " .. bat_now.time))
  213. elseif bat_now.perc >= 75 and bat_now.perc < 85 then
  214. baticon:set_image(theme.charge_80)
  215. batwidget = widget:set_markup(markup(green, " " .. bat_now.time))
  216. elseif bat_now.perc >= 65 and bat_now.perc < 75 then
  217. baticon:set_image(theme.charge_70)
  218. batwidget = widget:set_markup(markup(blue, " " .. bat_now.time))
  219. elseif bat_now.perc >= 55 and bat_now.perc < 65 then
  220. baticon:set_image(theme.charge_60)
  221. batwidget = widget:set_markup(markup(blue, " " .. bat_now.time))
  222. elseif bat_now.perc >= 45 and bat_now.perc < 55 then
  223. baticon:set_image(theme.charge_50)
  224. elseif bat_now.perc >= 35 and bat_now.perc < 45 then
  225. baticon:set_image(theme.charge_40)
  226. batwidget = widget:set_markup(markup(blue, " " .. bat_now.time))
  227. elseif bat_now.perc >= 25 and bat_now.perc < 35 then
  228. baticon:set_image(theme.charge_30)
  229. batwidget = widget:set_markup(markup(blue, " " .. bat_now.time))
  230. elseif bat_now.perc >= 15 and bat_now.perc < 25 then
  231. baticon:set_image(theme.charge_20)
  232. batwidget = widget:set_markup(markup(red, " " .. bat_now.time))
  233. elseif bat_now.perc >= 7 and bat_now.perc < 15 then
  234. baticon:set_image(theme.charge_10)
  235. batwidget = widget:set_markup(markup(red, " " .. bat_now.time))
  236. else
  237. baticon:set_image(theme.charge_empty)
  238. batwidget = widget:set_markup(markup(red, " " .. bat_now.time))
  239. end
  240. else
  241. if bat_now.status == "Full" then
  242. baticon:set_image(theme.charged_ac)
  243. elseif bat_now.perc >= 92 then
  244. baticon:set_image(theme.bat_full)
  245. batwidget = widget:set_markup(" " .. markup(green, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(green, " " .. bat_now.time))
  246. elseif bat_now.perc >= 85 and bat_now.perc < 92 then
  247. baticon:set_image(theme.bat_90)
  248. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  249. elseif bat_now.perc >= 75 and bat_now.perc < 85 then
  250. baticon:set_image(theme.bat_80)
  251. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  252. elseif bat_now.perc >= 65 and bat_now.perc < 75 then
  253. baticon:set_image(theme.bat_70)
  254. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  255. elseif bat_now.perc >= 55 and bat_now.perc < 65 then
  256. baticon:set_image(theme.bat_60)
  257. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  258. elseif bat_now.perc >= 45 and bat_now.perc < 55 then
  259. baticon:set_image(theme.bat_50)
  260. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  261. elseif bat_now.perc >= 35 and bat_now.perc < 45 then
  262. baticon:set_image(theme.bat_40)
  263. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  264. elseif bat_now.perc >= 25 and bat_now.perc < 35 then
  265. baticon:set_image(theme.bat_30)
  266. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(blue, " " .. bat_now.time))
  267. elseif bat_now.perc >= 15 and bat_now.perc < 25 then
  268. baticon:set_image(theme.bat_20)
  269. batwidget = widget:set_markup(" " .. markup(blue, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(red, " " .. bat_now.time))
  270. elseif bat_now.perc >= 7 and bat_now.perc < 15 then
  271. baticon:set_image(theme.bat_10)
  272. batwidget = widget:set_markup(" " .. markup(red, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(red, " " .. bat_now.time))
  273. else
  274. baticon:set_image(theme.bat_empty)
  275. batwidget = widget:set_markup(" " .. markup(red, bat_now.perc) .. markup("#ADADAD", "% ") .. markup(red, " " .. bat_now.time))
  276. end
  277. end
  278. end
  279. })
  280. --batwidget.font = theme.font
  281.  
  282. volumearc_widget({
  283. main_color = '#af13f7',
  284. mute_color = '#ff0000',
  285. thickness = 5,
  286. height = 25
  287. })
  288.  
  289. cpu_widget({
  290. width = 70,
  291. step_width = 2,
  292. step_spacing = 0,
  293. color = '#434c5e'
  294. })
  295.  
  296. brightnessarc_widget({
  297. color = '#43C5E'
  298. })
  299.  
  300.  
  301. vpnwidget = wibox.widget.textbox()
  302. vpnwidget:set_text(" ")
  303. vpnwidgettimer = timer({ timeout = 2 })
  304. vpnwidgettimer:connect_signal("timeout",
  305. function()
  306. status = io.popen("ifconfig | grep tun0")
  307. if status:read() == nil then
  308. vpnwidget:set_markup(markup(red, "VPN down "))
  309. else
  310. vpnwidget:set_markup(markup(green, " VPN "))
  311. end
  312. status:close()
  313. end
  314. )
  315. --vpnwidget.font = theme.font
  316. vpnwidgettimer:start()
  317.  
  318. bbswidget = wibox.widget.textbox()
  319. bbswidget:set_text(" ")
  320. bbswidgettimer = timer({ timeout = 2 })
  321. bbswidgettimer:connect_signal("timeout",
  322. function()
  323. status = io.popen("cat /proc/acpi/bbswitch | grep ON")
  324. if status:read() == nil then
  325. bbswidget:set_markup(markup(blue, "Intel"))
  326. else
  327. bbswidget:set_markup(markup(green, "NVIDIA"))
  328. end
  329. status:close()
  330. end
  331. )
  332. bbswidget.font = theme.font
  333. bbswidgettimer:start()
  334.  
  335. -- Weather
  336. theme.weather = lain.widget.weather({
  337. --city_id = 2643743, -- placeholder (London)
  338. city_id = 5570160, -- placeholder (not London)
  339. notification_preset = { font = "Play 11" },
  340. settings = function()
  341. units = math.floor(weather_now["main"]["temp"])
  342. widget:set_markup(" " .. markup.font(theme.font, markup(blue,units) .. "°F") .. " ")
  343. end
  344. })
  345.  
  346. -- Separators
  347. local first = wibox.widget.textbox(markup.font("Tamzen 3", " "))
  348. local spr = wibox.widget.textbox(' ')
  349. local small_spr = wibox.widget.textbox(markup.font("Tamzen 4", " "))
  350. local bar_spr = wibox.widget.textbox(markup.font("Tamzen 3", " ") .. markup.fontfg(theme.font, "#333333", "|") .. markup.font("Tamzen 5", " "))
  351.  
  352. -- Eminent-like task filtering
  353. local orig_filter = awful.widget.taglist.filter.all
  354.  
  355. -- Taglist label functions
  356. awful.widget.taglist.filter.all = function (t, args)
  357. if t.selected or #t:clients() > 0 then
  358. return orig_filter(t, args)
  359. end
  360. end
  361.  
  362. function theme.at_screen_connect(s)
  363. -- Quake application
  364. s.quake = lain.util.quake({ app = awful.util.terminal })
  365.  
  366. -- If wallpaper is a function, call it with the screen
  367. local wallpaper = theme.wallpaper
  368. if type(wallpaper) == "function" then
  369. wallpaper = wallpaper(s)
  370. end
  371. gears.wallpaper.maximized(wallpaper, s, true)
  372.  
  373. -- Tag names and layouts
  374. --awful.tag(awful.util.tagnames, s, awful.layout.layouts)
  375. local names = { "DEV", "WEB", "PAC", "NEW", "MUS", "PIR", "REM", "MOV", "WOR" }
  376. local l = awful.layout.suit
  377. local layouts = { l.tile, l.max, lain.layout.centerwork, lain.layout.centerwork, l.tile.bottom, lain.layout.centerwork, l.corner.se, l.magnifier, l.floating, }
  378. awful.tag(names, s, layouts)
  379.  
  380. -- Create a promptbox for each screen
  381. s.mypromptbox = awful.widget.prompt()
  382. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  383. -- We need one layoutbox per screen.
  384. s.mylayoutbox = awful.widget.layoutbox(s)
  385. s.mylayoutbox:buttons(awful.util.table.join(
  386. awful.button({ }, 1, function () awful.layout.inc( 1) end),
  387. awful.button({ }, 3, function () awful.layout.inc(-1) end),
  388. awful.button({ }, 4, function () awful.layout.inc( 1) end),
  389. awful.button({ }, 5, function () awful.layout.inc(-1) end)))
  390.  
  391. -- Create a taglist widget
  392. s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
  393.  
  394. -- Create a tasklist widget
  395. s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
  396.  
  397. -- Create the horizontal wibox
  398. s.mywibox = awful.wibar({ position = "top", screen = s, height = 29, bg = theme.bg_normal, fg = theme.fg_normal })
  399.  
  400. -- Add widgets to the wibox
  401. s.mywibox:setup {
  402. layout = wibox.layout.align.horizontal,
  403. { -- Left widgets
  404. layout = wibox.layout.fixed.horizontal,
  405. small_spr,
  406. s.mylayoutbox,
  407. --first,
  408. small_spr,
  409. bbswidget,
  410. small_spr,
  411. s.mytaglist,
  412. small_spr,
  413. theme.weather.icon,
  414. theme.weather,
  415. small_spr,
  416. first,
  417. s.mypromptbox,
  418. },
  419. s.mytasklist, -- Middle widget
  420. { -- Right widgets
  421. layout = wibox.layout.fixed.horizontal,
  422. mpdicon,
  423. theme.mpd.widget,
  424. small_spr,
  425. corona,
  426. vpnwidget,
  427. net_wireless,
  428. net,
  429. small_spr,
  430. cpu_widget(),
  431. small_spr,
  432. fs_widget({ mounts = { '/', '/home', '/media/Vault' } }),
  433. --fs_widget({ mounts = { '/', '/home' } }),
  434. small_spr,
  435. volumearc_widget(),
  436. small_spr,
  437. brightnessarc_widget(),
  438. small_spr,
  439. ram_widget(),
  440. small_spr,
  441. baticon,
  442. batwidget,
  443. small_spr,
  444. wibox.widget.systray(),
  445. mytextclock,
  446. },
  447. }
  448.  
  449. -- -- Create the vertical wibox
  450. -- s.myverticalwibox = awful.wibar({ position = "left", screen = s, width = 72, bg = theme.bg_normal, fg = theme.fg_normal })
  451. --
  452. -- -- Add widgets to the wibox
  453. -- s.myverticalwibox:setup {
  454. -- layout = wibox.layout.align.vertical,
  455. -- { -- Top widgets
  456. -- layout = wibox.layout.fixed.vertical,
  457. -- mylauncher,
  458. -- },
  459. -- }
  460.  
  461. end
  462.  
  463. return theme
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement