dotfiles/.config/awesome/widgets.lua

173 lines
4.6 KiB
Lua
Raw Normal View History

2017-04-22 16:53:37 +03:00
local gputemp = require("gputemp")
local hubic = require("hubic")
2017-07-08 20:12:50 +03:00
local dpmsstatus = require("dpmsstatus")
2017-04-22 16:53:37 +03:00
local lain = require("lain")
local vicious = require("vicious") -- Custom
local beautiful = require("beautiful") -- CPU temp
local wibox = require("wibox")
2019-03-23 17:28:58 +02:00
local gears = require("gears")
2017-04-22 16:53:37 +03:00
-- Variables
local valuecolor = "white"
2019-03-23 17:28:58 +02:00
icons_dir = os.getenv("HOME") .. "/.config/awesome/themes/lanxu/icons/"
cpuicon = wibox.widget.imagebox()
cpuicon.image = icons_dir .. "cpu.png"
cpuicon.resize = false
-- Helpers
function file_exists(name)
local f = io.open(name,"r")
if f ~= nil then io.close(f) return true else return false end
end
2017-04-22 16:53:37 +03:00
function create_markup(key, value, postfix, color)
return key .. " <span foreground='" .. color .. "'><b>" .. value .. postfix .."</b></span>"
end
-- Spacer
spacer = wibox.widget.textbox()
--spacer.text = "-"
spacer.forced_width = 8;
-- CPU
mycpu = lain.widget.cpu({
settings = function()
widget.markup = create_markup("CPU", cpu_now.usage, " %", valuecolor)
end
})
-- MEM
mymem = lain.widget.mem({
settings = function()
widget.markup = create_markup("MEM", mem_now.used, " MB", valuecolor)
end
})
-- GPU
2019-03-23 17:28:58 +02:00
mygputemp_text = wibox.widget.textbox()
mygputemp_text.align = "center"
vicious.register(mygputemp_text, gputemp,
function(widget, args)
temp = string.format("%.0f", tonumber(args[0]))
return create_markup("", temp, "", valuecolor)
end, 15, "AMD")
mygputemp = wibox.container.background()
mygputemp.forced_width = 70
mygputemp:set_widget(mygputemp_text)
--mytextclock:set_shape(gears.shape.hexagon)
mygputemp:set_bg('#5e35b1')
2017-04-22 16:53:37 +03:00
-- Hubic
myhubic = wibox.widget.textbox()
vicious.register(myhubic, hubic, create_markup("CLOUD", "$0", "", valuecolor), 15, "HUBIC")
2017-04-22 16:53:37 +03:00
-- Volume
volume = lain.widget.pulse({
2017-04-22 16:53:37 +03:00
scallback = function()
return "pacmd list-sinks | grep -Paoz \"(?s)(\\* index.*$(pactl info | grep -e 'ink' | cut -d' ' -f3).*(index)?)\" | tr -d '\\000' | grep -e 'index' -e 'device.string' -e 'name:' -e 'volume: front' -e 'muted'"
end,
settings = function()
volstr = volume_now.left .. " "
volcolor = valuecolor
if volume_now.muted == "yes" then
volcolor = "red"
end
widget.markup = create_markup("VOL", volstr, "%", volcolor)
end
})
-- Text clock
2019-03-23 17:28:58 +02:00
mytextclock_text = wibox.widget.textclock(create_markup("","%Y-%m-%d %H:%M","", valuecolor))
mytextclock_text.align = "center"
lain.widget.cal({
followtag = true,
2019-03-23 17:28:58 +02:00
attach_to = {mytextclock_text},
notification_preset = {
font = "Monospace 11", fg = "#FFFFFF", bg = "#000000"
}
2017-04-22 16:53:37 +03:00
})
2019-03-23 17:28:58 +02:00
mytextclock = wibox.container.background()
mytextclock.forced_width = 130
mytextclock:set_widget(mytextclock_text)
mytextclock:set_bg('#512da8')
2017-04-22 16:53:37 +03:00
-- CPU temperature
local tempfile = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon1/temp1_input"
if file_exists(tempfile) == false then
tempfile = "/sys/class/thermal/thermal_zone0/temp"
end
2019-03-23 17:28:58 +02:00
mycputemp_text = lain.widget.temp({
tempfile = tempfile,
2017-04-22 16:53:37 +03:00
settings = function()
2019-03-23 17:28:58 +02:00
temp = string.format("%.0f", tonumber(coretemp_now))
widget.markup = create_markup("", temp, "", valuecolor)
2017-04-22 16:53:37 +03:00
end
})
2019-03-23 17:28:58 +02:00
mycputemp_text.widget.align = "center"
mycputemp = wibox.container.background()
mycputemp.forced_width = 70
mycputemp:set_widget(mycputemp_text.widget)
mycputemp:set_bg('#9575cd')
2017-04-22 16:53:37 +03:00
-- Weather Widget
myweather = lain.widget.weather({
city_id = 634963,
lang = "fi",
2017-07-08 20:12:50 +03:00
followtag = true,
2017-04-22 16:53:37 +03:00
settings = function()
widget.markup = create_markup("Tampere", weather_now.main.temp, "", valuecolor)
2019-03-23 17:28:58 +02:00
end,
notification_preset = {
font = "Monospace 11", fg = "#FFFFFF", bg = "#000000"
}
})
2017-04-22 16:53:37 +03:00
2017-07-08 20:12:50 +03:00
-- DPMS
mydpmsstatus = wibox.widget.textbox()
2019-03-23 17:28:58 +02:00
-- mydpmsstatus.container.background.bg = '#ff0000'
--mydpmsstatus = {
-- widget = wibox.widget.textbox
--}
2017-07-08 20:12:50 +03:00
vicious.register(mydpmsstatus, dpmsstatus, function(widget, args)
color = valuecolor
if args[0] == "Enabled" then
return create_markup("DPMS", "ON", "", color)
else
color = "red"
return create_markup("DPMS", "OFF", "", color)
end
end)
2018-11-02 01:05:38 +02:00
local notification = {
font = "Monospace 10"
}
-- Servers
2019-03-23 17:28:58 +02:00
--local mcstatus = require("lanxu/mcstatus")
--myserverstatus = mcstatus({
--notification_preset = notification,
--settings = function()
--widget.markup = create_markup("PLAYERS", totalplayers, "", valuecolor)
--end
--})
--local cloudstatus = require("lanxu/cloudstatus")
--mycloudstatus = cloudstatus({
--notification_preset = notification,
--settings = function()
--widget.markup = create_markup("CLOUD", currentstatus, "", valuecolor)
--end
--})
2018-11-02 01:05:38 +02:00
local ip = require("lanxu/ip")
ipaddress = ip({
homeaddress = "91.157.104.247",
settings = function()
widget.markup = create_markup("IP", address, "", valuecolor)
end
})
2019-03-23 17:28:58 +02:00