441 lines
20 KiB
Lua
441 lines
20 KiB
Lua
--[[
|
|
|
|
Powerarrow Awesome WM theme
|
|
github.com/lcpz
|
|
|
|
--]]
|
|
|
|
local gears = require("gears")
|
|
local lain = require("lain")
|
|
local awful = require("awful")
|
|
local wibox = require("wibox")
|
|
local dpi = require("beautiful.xresources").apply_dpi
|
|
--local notif = require("notif-center")
|
|
|
|
local math, string, os = math, string, os
|
|
local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility
|
|
|
|
local theme = {}
|
|
theme.dir = os.getenv("HOME") .. "/.config/awesome/themes/powerarrow"
|
|
--theme.wallpaper = theme.dir .. "/wallpaper.jpg"
|
|
theme.font = "Hack Nerd Font 10"
|
|
theme.taglist_font = "Hack Nerd Font Mono 16"
|
|
theme.fg_normal = "#FEFEFE"
|
|
theme.fg_focus = "#b74822"
|
|
theme.fg_urgent = "#A9454C"
|
|
theme.bg_normal = "#22222260"
|
|
theme.bg_focus = "#1E2320"
|
|
theme.bg_urgent = "#3F3F3F"
|
|
theme.taglist_fg_focus = "#A9454C"
|
|
theme.tasklist_bg_focus = "#22222260"
|
|
theme.tasklist_fg_focus = "#A9454C"
|
|
theme.border_width = dpi(1)
|
|
theme.border_normal = "#3F3F3F60"
|
|
theme.border_focus = "#CF6F6F"
|
|
theme.border_marked = "#CC939350"
|
|
theme.titlebar_bg_focus = "#3F3F3F00"
|
|
theme.titlebar_bg_normal = "#3F3F3F00"
|
|
theme.titlebar_bg_focus = theme.bg_focus
|
|
theme.titlebar_bg_normal = theme.bg_normal
|
|
theme.titlebar_fg_focus = theme.fg_focus
|
|
theme.menu_height = dpi(25)
|
|
theme.menu_width = dpi(260)
|
|
theme.menu_submenu_icon = theme.dir .. "/icons/submenu.png"
|
|
theme.awesome_icon = theme.dir .. "/icons/awesome.png"
|
|
theme.taglist_squares_sel = theme.dir .. "/icons/square_sel.png"
|
|
theme.taglist_squares_unsel = theme.dir .. "/icons/square_unsel.png"
|
|
theme.layout_tile = theme.dir .. "/icons/tile.png"
|
|
theme.layout_tileleft = theme.dir .. "/icons/tileleft.png"
|
|
theme.layout_tilebottom = theme.dir .. "/icons/tilebottom.png"
|
|
theme.layout_tiletop = theme.dir .. "/icons/tiletop.png"
|
|
theme.layout_fairv = theme.dir .. "/icons/fairv.png"
|
|
theme.layout_fairh = theme.dir .. "/icons/fairh.png"
|
|
theme.layout_spiral = theme.dir .. "/icons/spiral.png"
|
|
theme.layout_dwindle = theme.dir .. "/icons/dwindle.png"
|
|
theme.layout_max = theme.dir .. "/icons/max.png"
|
|
theme.layout_fullscreen = theme.dir .. "/icons/fullscreen.png"
|
|
theme.layout_magnifier = theme.dir .. "/icons/magnifier.png"
|
|
theme.layout_floating = theme.dir .. "/icons/floating.png"
|
|
theme.widget_ac = theme.dir .. "/icons/ac.png"
|
|
theme.widget_battery = theme.dir .. "/icons/battery.png"
|
|
theme.widget_battery_low = theme.dir .. "/icons/battery_low.png"
|
|
theme.widget_battery_empty = theme.dir .. "/icons/battery_empty.png"
|
|
theme.widget_mem = theme.dir .. "/icons/mem.png"
|
|
theme.widget_cpu = theme.dir .. "/icons/cpu.png"
|
|
theme.widget_temp = theme.dir .. "/icons/temp.png"
|
|
theme.widget_net = theme.dir .. "/icons/net.png"
|
|
theme.widget_hdd = theme.dir .. "/icons/hdd.png"
|
|
theme.widget_music = theme.dir .. "/icons/note.png"
|
|
theme.widget_music_on = theme.dir .. "/icons/note.png"
|
|
theme.widget_music_pause = theme.dir .. "/icons/pause.png"
|
|
theme.widget_music_stop = theme.dir .. "/icons/stop.png"
|
|
theme.widget_vol = theme.dir .. "/icons/vol.png"
|
|
theme.widget_vol_low = theme.dir .. "/icons/vol_low.png"
|
|
theme.widget_vol_no = theme.dir .. "/icons/vol_no.png"
|
|
theme.widget_vol_mute = theme.dir .. "/icons/vol_mute.png"
|
|
theme.widget_mail = theme.dir .. "/icons/mail.png"
|
|
theme.widget_mail_on = theme.dir .. "/icons/mail_on.png"
|
|
theme.widget_task = theme.dir .. "/icons/task.png"
|
|
theme.widget_scissors = theme.dir .. "/icons/scissors.png"
|
|
theme.widget_weather = theme.dir .. "/icons/dish.png"
|
|
theme.tasklist_plain_task_name = true
|
|
theme.tasklist_disable_icon = true
|
|
theme.useless_gap = dpi(0)
|
|
theme.titlebar_close_button_focus = theme.dir .. "/icons/titlebar/close_focus.png"
|
|
theme.titlebar_close_button_normal = theme.dir .. "/icons/titlebar/close_normal.png"
|
|
theme.titlebar_ontop_button_focus_active = theme.dir .. "/icons/titlebar/ontop_focus_active.png"
|
|
theme.titlebar_ontop_button_normal_active = theme.dir .. "/icons/titlebar/ontop_normal_active.png"
|
|
theme.titlebar_ontop_button_focus_inactive = theme.dir .. "/icons/titlebar/ontop_focus_inactive.png"
|
|
theme.titlebar_ontop_button_normal_inactive = theme.dir .. "/icons/titlebar/ontop_normal_inactive.png"
|
|
theme.titlebar_sticky_button_focus_active = theme.dir .. "/icons/titlebar/sticky_focus_active.png"
|
|
theme.titlebar_sticky_button_normal_active = theme.dir .. "/icons/titlebar/sticky_normal_active.png"
|
|
theme.titlebar_sticky_button_focus_inactive = theme.dir .. "/icons/titlebar/sticky_focus_inactive.png"
|
|
theme.titlebar_sticky_button_normal_inactive = theme.dir .. "/icons/titlebar/sticky_normal_inactive.png"
|
|
theme.titlebar_floating_button_focus_active = theme.dir .. "/icons/titlebar/floating_focus_active.png"
|
|
theme.titlebar_floating_button_normal_active = theme.dir .. "/icons/titlebar/floating_normal_active.png"
|
|
theme.titlebar_floating_button_focus_inactive = theme.dir .. "/icons/titlebar/floating_focus_inactive.png"
|
|
theme.titlebar_floating_button_normal_inactive = theme.dir .. "/icons/titlebar/floating_normal_inactive.png"
|
|
theme.titlebar_maximized_button_focus_active = theme.dir .. "/icons/titlebar/maximized_focus_active.png"
|
|
theme.titlebar_maximized_button_normal_active = theme.dir .. "/icons/titlebar/maximized_normal_active.png"
|
|
theme.titlebar_maximized_button_focus_inactive = theme.dir .. "/icons/titlebar/maximized_focus_inactive.png"
|
|
theme.titlebar_maximized_button_normal_inactive = theme.dir .. "/icons/titlebar/maximized_normal_inactive.png"
|
|
|
|
local markup = lain.util.markup
|
|
local separators = lain.util.separators
|
|
|
|
|
|
-- Textclock
|
|
local clockicon = wibox.widget.imagebox(theme.widget_clock)
|
|
local clock = awful.widget.watch(
|
|
"date +'%a %d %b %R'", 60,
|
|
function(widget, stdout)
|
|
widget:set_markup(" " .. markup.font(theme.font, stdout))
|
|
end
|
|
)
|
|
|
|
-- Calendar
|
|
theme.cal = lain.widget.cal({
|
|
attach_to = { clock },
|
|
notification_preset = {
|
|
font = "Hack Nerd Font Mono 10",
|
|
fg = theme.fg_normal,
|
|
bg = theme.bg_focus
|
|
}
|
|
})
|
|
|
|
|
|
|
|
-- Taskwarrior
|
|
--local task = wibox.widget.imagebox(theme.widget_task)
|
|
--lain.widget.contrib.task.attach(task, {
|
|
-- do not colorize output
|
|
-- show_cmd = "task | sed -r 's/\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g'"
|
|
--})
|
|
--task:buttons(my_table.join(awful.button({}, 1, lain.widget.contrib.task.prompt)))
|
|
|
|
|
|
|
|
-- Mail IMAP check
|
|
local mailicon = wibox.widget.imagebox(theme.widget_mail)
|
|
--[[ commented because it needs to be set before use
|
|
mailicon:buttons(my_table.join(awful.button({ }, 1, function () awful.spawn(mail) end)))
|
|
theme.mail = lain.widget.imap({
|
|
timeout = 180,
|
|
server = "server",
|
|
mail = "mail",
|
|
password = "keyring get mail",
|
|
settings = function()
|
|
if mailcount > 0 then
|
|
widget:set_text(" " .. mailcount .. " ")
|
|
mailicon:set_image(theme.widget_mail_on)
|
|
else
|
|
widget:set_text("")
|
|
mailicon:set_image(theme.widget_mail)
|
|
end
|
|
end
|
|
})
|
|
--]]
|
|
|
|
-- ALSA volume
|
|
theme.volume = lain.widget.alsabar({
|
|
--togglechannel = "IEC958,3",
|
|
notification_preset = { font = theme.font, fg = theme.fg_normal },
|
|
})
|
|
|
|
-- MPD
|
|
local musicplr = "urxvt -title Music -g 130x34-320+16 -e ncmpcpp"
|
|
local mpdicon = wibox.widget.imagebox(theme.widget_music)
|
|
mpdicon:buttons(my_table.join(
|
|
awful.button({ modkey }, 1, function () awful.spawn.with_shell(musicplr) end),
|
|
--[[awful.button({ }, 1, function ()
|
|
awful.spawn.with_shell("mpc prev")
|
|
theme.mpd.update()
|
|
end),
|
|
--]]
|
|
awful.button({ }, 2, function ()
|
|
awful.spawn.with_shell("mpc toggle")
|
|
theme.mpd.update()
|
|
end),
|
|
awful.button({ modkey }, 3, function () awful.spawn.with_shell("pkill ncmpcpp") end),
|
|
awful.button({ }, 3, function ()
|
|
awful.spawn.with_shell("mpc stop")
|
|
theme.mpd.update()
|
|
end)))
|
|
theme.mpd = lain.widget.mpd({
|
|
settings = function()
|
|
if mpd_now.state == "play" then
|
|
artist = " " .. mpd_now.artist .. " "
|
|
title = mpd_now.title .. " "
|
|
mpdicon:set_image(theme.widget_music_on)
|
|
widget:set_markup(markup.font(theme.font, markup("#FFFFFF", artist) .. " " .. title))
|
|
elseif mpd_now.state == "pause" then
|
|
widget:set_markup(markup.font(theme.font, " mpd paused "))
|
|
mpdicon:set_image(theme.widget_music_pause)
|
|
else
|
|
widget:set_text("")
|
|
mpdicon:set_image(theme.widget_music)
|
|
end
|
|
end
|
|
})
|
|
|
|
-- MEM
|
|
local function round(num, numDecimalPlaces)
|
|
local mult = 10^(numDecimalPlaces or 0)
|
|
return math.floor(num * mult + 0.5) / mult
|
|
end
|
|
|
|
local memicon = wibox.widget.imagebox(theme.widget_mem)
|
|
local mem = lain.widget.mem({
|
|
settings = function()
|
|
widget:set_markup(markup.font(theme.font, " " .. round(mem_now.used/1024, 2) .. " GB"))
|
|
end
|
|
})
|
|
|
|
-- CPU
|
|
local cpuicon = wibox.widget.imagebox(theme.widget_cpu)
|
|
local cpu = lain.widget.cpu({
|
|
settings = function()
|
|
widget:set_markup(markup.font(theme.font, " " .. cpu_now.usage .. "% "))
|
|
end
|
|
})
|
|
|
|
--[[ Coretemp (lm_sensors, per core)
|
|
local tempwidget = awful.widget.watch({awful.util.shell, '-c', 'sensors | grep Core'}, 30,
|
|
function(widget, stdout)
|
|
local temps = ""
|
|
for line in stdout:gmatch("[^\r\n]+") do
|
|
temps = temps .. line:match("+(%d+).*°C") .. "° " -- in Celsius
|
|
end
|
|
widget:set_markup(markup.font(theme.font, " " .. temps))
|
|
end)
|
|
--]]
|
|
-- Coretemp (lain, average)
|
|
local temp = lain.widget.temp({
|
|
settings = function()
|
|
widget:set_markup(markup.font(theme.font, " " .. coretemp_now .. "°C "))
|
|
end
|
|
})
|
|
--]]
|
|
local tempicon = wibox.widget.imagebox(theme.widget_temp)
|
|
|
|
--[[ Weather
|
|
https://openweathermap.org/
|
|
Type in the name of your city
|
|
Copy/paste the city code in the URL to this file in city_id
|
|
--]]
|
|
local weathericon = wibox.widget.imagebox(theme.widget_weather)
|
|
theme.weather = lain.widget.weather({
|
|
city_id = 2803138, -- placeholder (Belgium)
|
|
notification_preset = { font = "Noto Sans Mono Medium 10", fg = theme.fg_normal },
|
|
weather_na_markup = markup.fontfg(theme.font, "#ffffff", "N/A "),
|
|
settings = function()
|
|
descr = weather_now["weather"][1]["description"]:lower()
|
|
units = math.floor(weather_now["main"]["temp"])
|
|
widget:set_markup(markup.fontfg(theme.font, "#ffffff", descr .. " @ " .. units .. "°C "))
|
|
end
|
|
})
|
|
|
|
-- / fs
|
|
local fsicon = wibox.widget.imagebox(theme.widget_hdd)
|
|
--[[ commented because it needs Gio/Glib >= 2.54
|
|
theme.fs = lain.widget.fs({
|
|
notification_preset = { fg = theme.fg_normal, bg = theme.bg_normal, font = "Noto Sans Mono Medium 10" },
|
|
settings = function()
|
|
local fsp = string.format(" %3.2f %s ", fs_now["/"].free, fs_now["/"].units)
|
|
widget:set_markup(markup.font(theme.font, fsp))
|
|
end
|
|
})
|
|
--]]
|
|
|
|
-- Battery
|
|
local baticon = wibox.widget.imagebox(theme.widget_battery)
|
|
local bat = lain.widget.bat({
|
|
settings = function()
|
|
if bat_now.status and bat_now.status ~= "N/A" then
|
|
if bat_now.ac_status == 1 then
|
|
widget:set_markup(markup.font(theme.font, " AC "))
|
|
baticon:set_image(theme.widget_ac)
|
|
return
|
|
elseif not bat_now.perc and tonumber(bat_now.perc) <= 5 then
|
|
baticon:set_image(theme.widget_battery_empty)
|
|
elseif not bat_now.perc and tonumber(bat_now.perc) <= 15 then
|
|
baticon:set_image(theme.widget_battery_low)
|
|
else
|
|
baticon:set_image(theme.widget_battery)
|
|
end
|
|
widget:set_markup(markup.font(theme.font, " " .. bat_now.perc .. "% "))
|
|
else
|
|
widget:set_markup()
|
|
baticon:set_image(theme.widget_ac)
|
|
end
|
|
end
|
|
})
|
|
|
|
-- ALSA volume
|
|
local volicon = wibox.widget.imagebox(theme.widget_vol)
|
|
theme.volume = lain.widget.alsa({
|
|
settings = function()
|
|
if volume_now.status == "off" then
|
|
volicon:set_image(theme.widget_vol_mute)
|
|
elseif tonumber(volume_now.level) == 0 then
|
|
volicon:set_image(theme.widget_vol_no)
|
|
elseif tonumber(volume_now.level) <= 50 then
|
|
volicon:set_image(theme.widget_vol_low)
|
|
else
|
|
volicon:set_image(theme.widget_vol)
|
|
end
|
|
|
|
widget:set_markup(markup.font(theme.font, " " .. volume_now.level .. "% "))
|
|
end
|
|
})
|
|
|
|
-- Net
|
|
local neticon = wibox.widget.imagebox(theme.widget_net)
|
|
local net = lain.widget.net({
|
|
settings = function()
|
|
widget:set_markup(markup.fontfg(theme.font, "#FEFEFE", " " .. net_now.received .. " ↓↑ " .. net_now.sent .. " "))
|
|
end
|
|
})
|
|
|
|
-- Separators
|
|
local arrow = separators.arrow_left
|
|
|
|
function theme.powerline_rl(cr, width, height)
|
|
local arrow_depth, offset = height/2, 0
|
|
|
|
-- Avoid going out of the (potential) clip area
|
|
if arrow_depth < 0 then
|
|
width = width + 2*arrow_depth
|
|
offset = -arrow_depth
|
|
end
|
|
|
|
cr:move_to(offset + arrow_depth , 0 )
|
|
cr:line_to(offset + width , 0 )
|
|
cr:line_to(offset + width - arrow_depth , height/2 )
|
|
cr:line_to(offset + width , height )
|
|
cr:line_to(offset + arrow_depth , height )
|
|
cr:line_to(offset , height/2 )
|
|
|
|
cr:close_path()
|
|
end
|
|
|
|
local function pl(widget, bgcolor, padding)
|
|
return wibox.container.background(wibox.container.margin(widget, dpi(16), dpi(16)), bgcolor, theme.powerline_rl)
|
|
end
|
|
|
|
function theme.at_screen_connect(s)
|
|
-- Quake application
|
|
-- s.quake = lain.util.quake({ app = awful.util.terminal })
|
|
s.quake = lain.util.quake({ app = "termite", height = 0.50, argname = "--name %s" })
|
|
|
|
|
|
|
|
-- If wallpaper is a function, call it with the screen
|
|
local wallpaper = theme.wallpaper
|
|
if type(wallpaper) == "function" then
|
|
wallpaper = wallpaper(s)
|
|
end
|
|
--gears.wallpaper.maximized(wallpaper, s, true)
|
|
|
|
-- All tags open with layout 1
|
|
awful.tag(awful.util.tagnames, s, awful.layout.layouts[1])
|
|
|
|
-- Create a promptbox for each screen
|
|
s.mypromptbox = awful.widget.prompt()
|
|
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
|
-- We need one layoutbox per screen.
|
|
s.mylayoutbox = awful.widget.layoutbox(s)
|
|
s.mylayoutbox:buttons(my_table.join(
|
|
awful.button({ }, 1, function () awful.layout.inc( 1) end),
|
|
awful.button({ }, 3, function () awful.layout.inc(-1) end),
|
|
awful.button({ }, 4, function () awful.layout.inc( 1) end),
|
|
awful.button({ }, 5, function () awful.layout.inc(-1) end)))
|
|
-- Create a taglist widget
|
|
s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.taglist_buttons)
|
|
|
|
-- Create a tasklist widget
|
|
s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, awful.util.tasklist_buttons)
|
|
|
|
-- Create the wibox
|
|
s.mywibox = awful.wibar({ position = "top", screen = s, height = dpi(25), bg = theme.bg_normal, fg = theme.fg_normal })
|
|
|
|
--arrow colors
|
|
local color1 = "#70232A80"
|
|
local color2 = "#61151C80"
|
|
local color3 = "#70061080"
|
|
local color4 = "#64131A80"
|
|
local color5 = "#843B6280"
|
|
local color6 = "#74546A80"
|
|
local color7 = "#0B032D80"
|
|
-- Add widgets to the wibox
|
|
s.mywibox:setup {
|
|
layout = wibox.layout.align.horizontal,
|
|
{ -- Left widgets
|
|
layout = wibox.layout.fixed.horizontal,
|
|
--spr,
|
|
s.mytaglist,
|
|
s.mypromptbox,
|
|
spr,
|
|
},
|
|
s.mytasklist, -- Middle widget
|
|
{ -- Right widgets
|
|
layout = wibox.layout.fixed.horizontal,
|
|
-- using shapes
|
|
--pl(wibox.widget { mpdicon, theme.mpd.widget, layout = wibox.layout.align.horizontal }, "#343434"),
|
|
--pl(task, "#343434"),
|
|
--pl(wibox.widget { mailicon, mail and theme.mail.widget, layout = wibox.layout.align.horizontal }, "#343434"),
|
|
--pl(wibox.widget { memicon, mem.widget, layout = wibox.layout.align.horizontal }, color1),
|
|
--pl(wibox.widget { cpuicon, cpu.widget, layout = wibox.layout.align.horizontal }, color1),
|
|
pl(wibox.widget { tempicon, temp.widget, layout = wibox.layout.align.horizontal }, color2),
|
|
--pl(wibox.widget { fsicon, theme.fs and theme.fs.widget, layout = wibox.layout.align.horizontal }, "#CB755B"),
|
|
pl(wibox.widget { baticon, bat.widget, layout = wibox.layout.align.horizontal }, color3),
|
|
pl(wibox.widget { volicon, theme.volume.widget, layout = wibox.layout.align.horizontal }, color3),
|
|
pl(wibox.widget { clock, layout = wibox.layout.align.horizontal }, color7),
|
|
--pl(binclock.widget, "#777E76"),
|
|
--]]
|
|
--[[ using separators
|
|
--arrow(theme.bg_normal, "#343434"),
|
|
-- wibox.container.background(wibox.container.margin(wibox.widget { mailicon, mail and mail.widget, layout = wibox.layout.align.horizontal }, dpi(4), dpi(7)), "#343434"),
|
|
--arrow("alpha", color1),
|
|
-- wibox.container.background(wibox.container.margin(wibox.widget { mpdicon, theme.mpd.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(6)), "#889FA7"),
|
|
wibox.container.background(wibox.container.margin(wibox.widget { cpuicon, cpu.widget, layout = wibox.layout.align.horizontal }, dpi(2), dpi(1)), color1),
|
|
wibox.container.background(wibox.container.margin(wibox.widget { tempicon, temp.widget, layout = wibox.layout.align.horizontal }, dpi(1), dpi(2)), color1),
|
|
--arrow(color1, color2),
|
|
wibox.container.background(wibox.container.margin(wibox.widget { memicon, mem.widget, layout = wibox.layout.align.horizontal }, dpi(2), dpi(1)), color2),
|
|
-- wibox.container.background(wibox.container.margin(wibox.widget { weathericon, theme.weather.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(3)), "#CB755B"),
|
|
|
|
-- wibox.container.background(wibox.container.margin(wibox.widget { nil, neticon, net.widget, layout = wibox.layout.align.horizontal }, dpi(3), dpi(3)), color6),
|
|
--arrow(color2, color3),
|
|
wibox.container.background(wibox.container.margin(wibox.widget { baticon, bat.widget, layout = wibox.layout.align.horizontal }, dpi(2), dpi(1)), color3),
|
|
wibox.container.background(wibox.container.margin(wibox.widget { volicon, theme.volume.widget, layout = wibox.layout.align.horizontal }, dpi(1), dpi(2)), color3),
|
|
--arrow(color3, color7),
|
|
wibox.container.background(wibox.container.margin(clock, dpi(1), dpi(8)), color7),
|
|
--]]
|
|
wibox.widget.systray(),
|
|
s.mylayoutbox,
|
|
--require('notif-center')
|
|
},
|
|
}
|
|
end
|
|
|
|
return theme
|