theme.lua 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. --[[
  2. Ecchi Awesome WM theme 1.0
  3. --]]
  4. local gears = require("gears")
  5. local lain = require("lain")
  6. local awful = require("awful")
  7. local wibox = require("wibox")
  8. local dpi = require("beautiful.xresources").apply_dpi
  9. local os = os
  10. local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
  11. local colors = {
  12. black = "#131313",
  13. white = "#C6C6C6",
  14. yellow = "#b8c480",
  15. green = "#42e2b8",
  16. red = "#ff5a5f",
  17. charcoal = "#2f4452",
  18. periwinkle = "#cbd0ec",
  19. blue = "#617698",
  20. pine = "#6bab90",
  21. grape = "#5c4e90"
  22. }
  23. local theme = {}
  24. theme.confdir = os.getenv("HOME") .. "/.config/awesome/themes/ecchi"
  25. theme.font = "Noto Sans Regular 11"
  26. theme.taglist_font = "Noto Sans Regular 13"
  27. theme.menu_bg_normal = colors.black
  28. theme.menu_bg_focus = colors.black
  29. theme.bg_normal = colors.black
  30. theme.bg_focus = colors.black
  31. theme.bg_urgent = colors.black
  32. theme.fg_normal = colors.white
  33. theme.fg_focus = colors.pine
  34. theme.fg_urgent = colors.red
  35. theme.fg_minimize = colors.white
  36. theme.border_width = dpi(2)
  37. theme.border_normal = colors.charcoal
  38. theme.border_focus = colors.grape
  39. theme.border_marked = colors.pine
  40. theme.menu_border_width = 0
  41. theme.menu_height = dpi(25)
  42. theme.menu_width = dpi(260)
  43. theme.menu_fg_normal = colors.white
  44. theme.menu_fg_focus = colors.pine
  45. theme.menu_bg_normal = colors.black
  46. theme.menu_bg_focus = colors.black
  47. theme.tasklist_plain_task_name = true
  48. theme.tasklist_disable_icon = true
  49. theme.useless_gap = 5
  50. theme.layout_tile = theme.confdir .. "/icons/tile.png"
  51. theme.layout_tileleft = theme.confdir .. "/icons/tileleft.png"
  52. theme.layout_tilebottom = theme.confdir .. "/icons/tilebottom.png"
  53. theme.layout_tiletop = theme.confdir .. "/icons/tiletop.png"
  54. theme.layout_fairv = theme.confdir .. "/icons/fairv.png"
  55. theme.layout_fairh = theme.confdir .. "/icons/fairh.png"
  56. theme.layout_spiral = theme.confdir .. "/icons/spiral.png"
  57. theme.layout_dwindle = theme.confdir .. "/icons/dwindle.png"
  58. theme.layout_max = theme.confdir .. "/icons/max.png"
  59. theme.layout_fullscreen = theme.confdir .. "/icons/fullscreen.png"
  60. theme.layout_magnifier = theme.confdir .. "/icons/magnifier.png"
  61. theme.layout_floating = theme.confdir .. "/icons/floating.png"
  62. local markup = lain.util.markup
  63. local weather_na_text = "不明"
  64. local sep = wibox.widget.textbox(" ")
  65. -- Textclock
  66. os.setlocale(os.getenv("LANG")) -- to localize the clock
  67. local mytextclock = wibox.widget.textclock(
  68. markup(colors.periwinkle, "🝰 ") ..
  69. markup(colors.periwinkle, "%A %d %B ") ..
  70. markup(colors.periwinkle, "%H:%M"))
  71. mytextclock.font = theme.font
  72. -- Calendar
  73. theme.cal = lain.widget.cal({
  74. attach_to = {mytextclock},
  75. notification_preset = {
  76. font = "Noto Sans Mono Medium 10",
  77. fg = theme.fg_normal,
  78. bg = theme.bg_normal
  79. }
  80. })
  81. -- Weather
  82. theme.weather = lain.widget.weather({
  83. APPID = "ADD YOUR APPID HERE",
  84. city_id = 3457191,
  85. notification_preset = {
  86. font = "Noto Sans Mono Medium 10",
  87. fg = theme.fg_normal
  88. },
  89. weather_na_markup = markup.fontfg(theme.font, colors.grape, weather_na_text),
  90. settings = function()
  91. icon = "☀ "
  92. units = math.floor(weather_now["main"]["temp"])
  93. if units <= 0 then
  94. tempcolor = colors.blue
  95. elseif units > 0 and units <= 16 then
  96. tempcolor = colors.green
  97. elseif units > 16 and units < 30 then
  98. tempcolor = colors.yellow
  99. else
  100. tempcolor = colors.red
  101. end
  102. widget:set_markup(markup.fontfg(theme.font, tempcolor,
  103. icon .. units .. "°C"))
  104. end
  105. })
  106. -- CPU
  107. local cpu = lain.widget.cpu({
  108. settings = function()
  109. cpu_color = colors.green
  110. if cpu_now.usage > 40 and cpu_now.usage <= 65 then
  111. cpu_color = colors.yellow
  112. elseif cpu_now.usage > 65 then
  113. cpu_color = colors.red
  114. end
  115. icon = markup(cpu_color, "↺ ")
  116. widget:set_markup(markup.fontfg(theme.font, cpu_color,
  117. icon .. cpu_now.usage .. "%"))
  118. end
  119. })
  120. -- ALSA volume
  121. theme.volume = lain.widget.alsa({
  122. settings = function()
  123. if volume_now.status == "off" then
  124. volume_now.level = "静く"
  125. volume_color = colors.red
  126. volume_icon = " "
  127. else
  128. volume_now.level = volume_now.level .. "%"
  129. volume_color = colors.blue
  130. volume_icon = "∿ "
  131. end
  132. icon = markup(volume_color, volume_icon)
  133. widget:set_markup(markup.fontfg(theme.font, volume_color,
  134. icon .. volume_now.level))
  135. end
  136. })
  137. -- Net
  138. local netdowninfo = wibox.widget.textbox()
  139. local netupinfo = lain.widget.net({
  140. settings = function()
  141. if iface ~= "network off" and
  142. string.match(theme.weather.widget.text, weather_na_text) then
  143. theme.weather.update()
  144. end
  145. down_icon = markup(colors.green, "↓ ")
  146. up_icon = markup(colors.red, "↑ ")
  147. widget:set_markup(markup.fontfg(theme.font, colors.red,
  148. up_icon .. net_now.sent))
  149. netdowninfo:set_markup(markup.fontfg(theme.font, colors.green,
  150. down_icon .. net_now.received))
  151. end
  152. })
  153. -- MEM
  154. local memory = lain.widget.mem({
  155. settings = function()
  156. if mem_now.perc <= 25 then
  157. memcolor = colors.green
  158. elseif mem_now.perc > 25 and mem_now.perc <= 75 then
  159. memcolor = colors.yellow
  160. else
  161. memcolor = colors.red
  162. end
  163. icon = "⛶ "
  164. widget:set_markup(markup.fontfg(theme.font, memcolor,
  165. icon .. mem_now.perc .. "%"))
  166. end
  167. })
  168. function theme.at_screen_connect(s)
  169. -- Tags
  170. awful.tag(awful.util.tagnames, s, awful.layout.layouts[1])
  171. -- Create a promptbox for each screen
  172. s.mypromptbox = awful.widget.prompt()
  173. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  174. -- We need one layoutbox per screen.
  175. s.mylayoutbox = awful.widget.layoutbox(s)
  176. s.mylayoutbox:buttons(my_table.join(awful.button({}, 1, function()
  177. awful.layout.inc(1)
  178. end), awful.button({}, 3, function() awful.layout.inc(-1) end),
  179. awful.button({}, 4, function()
  180. awful.layout.inc(1)
  181. end), awful.button({}, 5, function() awful.layout.inc(-1) end)))
  182. -- Create a taglist widget
  183. s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all,
  184. awful.util.taglist_buttons)
  185. -- Create a tasklist widget
  186. s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter
  187. .currenttags,
  188. awful.util.tasklist_buttons)
  189. -- Create the wibox
  190. s.mywibox = awful.wibar({
  191. position = "top",
  192. screen = s,
  193. height = dpi(20),
  194. bg = theme.bg_normal,
  195. fg = colors.periwinkle
  196. })
  197. -- Add widgets to the wibox
  198. s.mywibox:setup{
  199. layout = wibox.layout.align.horizontal,
  200. { -- Left widgets
  201. layout = wibox.layout.fixed.horizontal,
  202. -- s.mylayoutbox,
  203. s.mytaglist,
  204. s.mypromptbox
  205. },
  206. -- s.mytasklist, -- Middle widget
  207. nil,
  208. { -- Right widgets
  209. layout = wibox.layout.fixed.horizontal,
  210. netdowninfo,
  211. sep,
  212. netupinfo.widget,
  213. sep,
  214. theme.volume.widget,
  215. sep,
  216. memory.widget,
  217. sep,
  218. cpu.widget,
  219. sep,
  220. theme.weather.widget,
  221. sep,
  222. mytextclock,
  223. sep,
  224. wibox.widget.systray()
  225. }
  226. }
  227. -- Create the bottom wibox
  228. s.mybottomwibox = awful.wibar({
  229. position = "bottom",
  230. screen = s,
  231. border_width = 0,
  232. height = dpi(20),
  233. bg = theme.bg_normal,
  234. fg = theme.fg_normal
  235. })
  236. -- Add widgets to the bottom wibox
  237. s.mybottomwibox:setup{
  238. layout = wibox.layout.align.horizontal,
  239. { -- Left widgets
  240. layout = wibox.layout.fixed.horizontal
  241. },
  242. s.mytasklist, -- Middle widget
  243. { -- Right widgets
  244. layout = wibox.layout.fixed.horizontal,
  245. s.mylayoutbox
  246. }
  247. }
  248. end
  249. return theme