Initial commit
This commit is contained in:
commit
290c28cc83
34 changed files with 1157 additions and 0 deletions
85
yawl/widgets/battery.lua
Normal file
85
yawl/widgets/battery.lua
Normal file
|
@ -0,0 +1,85 @@
|
|||
-- YAWL, Battery widget module
|
||||
local battery = {}
|
||||
local mt = {}
|
||||
|
||||
-- Requires
|
||||
local wibox = require("wibox")
|
||||
local base = require("yawl.base")
|
||||
local utils = require("yawl.utils")
|
||||
local beautiful = require("beautiful")
|
||||
local watch = require("awful.widget.watch")
|
||||
|
||||
-- Entrypoint
|
||||
function mt.__call()
|
||||
|
||||
-- base txt widget
|
||||
local t = base.txt()
|
||||
local w = base.bg()
|
||||
w:set_widget(t)
|
||||
-- change default bg to battery full
|
||||
w:set_bg(beautiful.yawl_battery_full)
|
||||
|
||||
-- icon widget
|
||||
local i = base.icon("")
|
||||
|
||||
-- merge of the two
|
||||
local widget = wibox.widget {
|
||||
i,
|
||||
w,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
}
|
||||
|
||||
-- watch func
|
||||
watch(
|
||||
'acpi', 10,
|
||||
function(_, stdout, stderr, exitreason, exitcode)
|
||||
-- get lines for acpi
|
||||
local lines = utils.split(stdout, "[^\r\n]+")
|
||||
-- use first line (BAT0), get elements
|
||||
-- 1 : Battery
|
||||
-- 2 : :0
|
||||
-- 3 : State (Full, Discharching, Charging)
|
||||
-- 4 : Level (X%)
|
||||
local parts = utils.split(lines[1], "%S+")
|
||||
|
||||
-- format data in dedicated vars
|
||||
local level = string.gsub(parts[4], "%%,?", "")
|
||||
local state = string.gsub(parts[3], ",", "")
|
||||
|
||||
-- set background based on level
|
||||
if tonumber(level) >= 70 then
|
||||
i:set_text(" ")
|
||||
w:set_bg(beautiful.yawl_battery_full)
|
||||
elseif tonumber(level) >= 30 then
|
||||
i:set_text(" ")
|
||||
w:set_bg(beautiful.yawl_battery_mid)
|
||||
else
|
||||
i:set_text(" ")
|
||||
w:set_bg(beautiful.yawl_battery_low)
|
||||
end
|
||||
|
||||
|
||||
-- set state based on charging, full or discharching
|
||||
local st = ""
|
||||
if state == "Full" then
|
||||
st = ""
|
||||
elseif state == "Discharging" then
|
||||
st = ""
|
||||
elseif state == "Charging" then
|
||||
st = ""
|
||||
else
|
||||
st = ""
|
||||
end
|
||||
|
||||
t:set_text(" " .. st .. " " .. level .. "% ")
|
||||
|
||||
end,
|
||||
w
|
||||
)
|
||||
|
||||
return widget
|
||||
|
||||
end
|
||||
|
||||
-- Return widget
|
||||
return setmetatable(battery, mt)
|
43
yawl/widgets/date.lua
Normal file
43
yawl/widgets/date.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
-- YAWL, Date widget module
|
||||
local date = {}
|
||||
local mt = {}
|
||||
|
||||
-- Requires
|
||||
local wibox = require("wibox")
|
||||
local base = require("yawl.base")
|
||||
local utils = require("yawl.utils")
|
||||
local watch = require("awful.widget.watch")
|
||||
|
||||
-- Entrypoint
|
||||
function mt.__call()
|
||||
|
||||
-- base
|
||||
local t = base.txt()
|
||||
local w = base.bg()
|
||||
w:set_widget(t)
|
||||
|
||||
-- icon widget
|
||||
local i = base.icon("")
|
||||
|
||||
-- merge of the two
|
||||
local widget = wibox.widget {
|
||||
i,
|
||||
w,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
}
|
||||
|
||||
-- watch func
|
||||
watch(
|
||||
'date "+%H:%M - %d/%m/%y"', 10,
|
||||
function(_, stdout, stderr, exitreason, exitcode)
|
||||
t:set_text(" " .. utils.strim(stdout) .. " ")
|
||||
end,
|
||||
w
|
||||
)
|
||||
|
||||
return widget
|
||||
|
||||
end
|
||||
|
||||
-- Return widget
|
||||
return setmetatable(date, mt)
|
66
yawl/widgets/spotify.lua
Normal file
66
yawl/widgets/spotify.lua
Normal file
|
@ -0,0 +1,66 @@
|
|||
-- YAWL, Spotify widget module
|
||||
local spotify = {}
|
||||
local mt = {}
|
||||
|
||||
-- Requires
|
||||
local wibox = require("wibox")
|
||||
local base = require("yawl.base")
|
||||
local utils = require("yawl.utils")
|
||||
local beautiful = require("beautiful")
|
||||
local watch = require("awful.widget.watch")
|
||||
|
||||
-- Entrypoint
|
||||
function mt.__call()
|
||||
|
||||
-- base
|
||||
local t = base.txt()
|
||||
local w = base.bg()
|
||||
w:set_widget(t)
|
||||
-- change default bg to paused
|
||||
w:set_bg(beautiful.yawl_spotify_absent)
|
||||
|
||||
-- icon widget
|
||||
local i = base.icon("")
|
||||
|
||||
-- merge of the two
|
||||
local widget = wibox.widget {
|
||||
i,
|
||||
w,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
}
|
||||
|
||||
-- watch func
|
||||
watch(
|
||||
-- is spotify running ?
|
||||
'pidof spotify', 5,
|
||||
function(_, stdout, stderr, exitreason, exitcode)
|
||||
|
||||
if stdout == "" then
|
||||
w:set_bg(beautiful.yawl_spotify_absent)
|
||||
w:set_fg(beautiful.yawl_spotify_absent_fg)
|
||||
t:set_text(" not running ")
|
||||
return
|
||||
end
|
||||
|
||||
w:set_fg(beautiful.yawl_fg)
|
||||
local status = utils.sanitize(utils.run("playerctl -p spotify status"))
|
||||
local np = utils.sanitize(utils.run('playerctl -p spotify metadata --format="{{ artist }} · {{ title }}"'))
|
||||
|
||||
if status == "Playing" then
|
||||
w:set_bg(beautiful.yawl_spotify_play)
|
||||
else
|
||||
w:set_bg(beautiful.yawl_spotify_pause)
|
||||
end
|
||||
|
||||
t:set_text(" " .. np .. " ")
|
||||
|
||||
end,
|
||||
w
|
||||
)
|
||||
|
||||
return widget
|
||||
|
||||
end
|
||||
|
||||
-- Return widget
|
||||
return setmetatable(spotify, mt)
|
Loading…
Add table
Add a link
Reference in a new issue