Update users home folder, clean up some scripts and add comments
This commit is contained in:
parent
e322152f69
commit
662f7d9388
0
etc/X11/xorg.conf.d/50-acceleration.conf
Executable file → Normal file
0
etc/X11/xorg.conf.d/50-acceleration.conf
Executable file → Normal file
@ -1,27 +0,0 @@
|
|||||||
[settings]
|
|
||||||
usehal = false
|
|
||||||
|
|
||||||
[looks]
|
|
||||||
opacity = 80
|
|
||||||
bgcolor = black
|
|
||||||
buttontheme = adeos-archlabs
|
|
||||||
buttons = cancel, logout, suspend, lock, restart, shutdown
|
|
||||||
|
|
||||||
[shortcuts]
|
|
||||||
cancel = Escape
|
|
||||||
shutdown = S
|
|
||||||
restart = R
|
|
||||||
suspend = U
|
|
||||||
logout = L
|
|
||||||
lock = K
|
|
||||||
#hibernate = H
|
|
||||||
|
|
||||||
[commands]
|
|
||||||
shutdown = systemctl poweroff
|
|
||||||
restart = systemctl reboot
|
|
||||||
suspend = systemctl suspend
|
|
||||||
logout = session-logout
|
|
||||||
#hibernate = systemctl hibernate
|
|
||||||
lock = pkill oblogout; i3lock-fancy -p
|
|
||||||
#switchuser = gdm-control --switch-user
|
|
||||||
#safesuspend = safesuspend
|
|
@ -1,44 +1,44 @@
|
|||||||
<?xml encoding="UTF-8" version="1.0"?>
|
<?xml encoding="UTF-8" version="1.0"?>
|
||||||
<actions>
|
<actions>
|
||||||
<action>
|
<action>
|
||||||
<icon>utilities-terminal</icon>
|
<icon>utilities-terminal</icon>
|
||||||
<name>Open in Terminal</name>
|
<name>Open in Terminal</name>
|
||||||
<unique-id>1499240572835265-1</unique-id>
|
<unique-id>1499240572835265-1</unique-id>
|
||||||
<command>exo-open --launch TerminalEmulator %f</command>
|
<command>exo-open --launch TerminalEmulator %f</command>
|
||||||
<description></description>
|
<description></description>
|
||||||
<patterns>*</patterns>
|
<patterns>*</patterns>
|
||||||
<startup-notify/>
|
<startup-notify/>
|
||||||
<directories/>
|
<directories/>
|
||||||
</action>
|
</action>
|
||||||
<action>
|
<action>
|
||||||
<icon>document-open</icon>
|
<icon>document-open</icon>
|
||||||
<name>Open as Root</name>
|
<name>Open as Root</name>
|
||||||
<unique-id>1498523394840843-5</unique-id>
|
<unique-id>1498523394840843-5</unique-id>
|
||||||
<command>gksu thunar %f</command>
|
<command>gksu thunar %f</command>
|
||||||
<description></description>
|
<description></description>
|
||||||
<patterns>*</patterns>
|
<patterns>*</patterns>
|
||||||
<directories/>
|
<directories/>
|
||||||
</action>
|
</action>
|
||||||
<action>
|
<action>
|
||||||
<icon>archive-extract</icon>
|
<icon>archive-extract</icon>
|
||||||
<name>Extract Here</name>
|
<name>Extract Here</name>
|
||||||
<unique-id>1500573442438340-2</unique-id>
|
<unique-id>1500573442438340-2</unique-id>
|
||||||
<command>file-roller -h %N</command>
|
<command>file-roller -h %N</command>
|
||||||
<description></description>
|
<description></description>
|
||||||
<patterns>*</patterns>
|
<patterns>*</patterns>
|
||||||
<startup-notify/>
|
<startup-notify/>
|
||||||
<other-files/>
|
<other-files/>
|
||||||
</action>
|
</action>
|
||||||
<action>
|
<action>
|
||||||
<icon>archive-insert</icon>
|
<icon>archive-insert</icon>
|
||||||
<name>Archive</name>
|
<name>Archive</name>
|
||||||
<unique-id>1500573639456321-3</unique-id>
|
<unique-id>1500573639456321-3</unique-id>
|
||||||
<command>file-roller -d %F</command>
|
<command>file-roller -d %F</command>
|
||||||
<description>Archive selected items</description>
|
<description>Archive selected items</description>
|
||||||
<patterns>*</patterns>
|
<patterns>*</patterns>
|
||||||
<directories/>
|
<directories/>
|
||||||
<image-files/>
|
<image-files/>
|
||||||
<other-files/>
|
<other-files/>
|
||||||
<text-files/>
|
<text-files/>
|
||||||
</action>
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
|
@ -234,7 +234,7 @@ mytasklist.buttons = awful.util.table.join(
|
|||||||
instance:hide()
|
instance:hide()
|
||||||
instance = nil
|
instance = nil
|
||||||
else
|
else
|
||||||
instance = awful.menu.clients({ width=250 })
|
instance = awful.menu.clients({ width=200 })
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 4, function ()
|
awful.button({ }, 4, function ()
|
||||||
|
@ -9,9 +9,9 @@ local io = { open = io.open }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
local string = {
|
local string = {
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
gmatch = string.gmatch
|
gmatch = string.gmatch
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -23,56 +23,56 @@ local ati = {}
|
|||||||
|
|
||||||
-- {{{ Define variables
|
-- {{{ Define variables
|
||||||
local _units = { clock = { ["khz"] = 1, ["mhz"] = 1000 },
|
local _units = { clock = { ["khz"] = 1, ["mhz"] = 1000 },
|
||||||
voltage = { ["v"] = 1, ["mv"] = 1000 } }
|
voltage = { ["v"] = 1, ["mv"] = 1000 } }
|
||||||
local _reps = {
|
local _reps = {
|
||||||
["sclk"] = { name = "engine_clock", units = _units.clock, mul = 10 },
|
["sclk"] = { name = "engine_clock", units = _units.clock, mul = 10 },
|
||||||
["mclk"] = { name = "memory_clock", units = _units.clock, mul = 10 },
|
["mclk"] = { name = "memory_clock", units = _units.clock, mul = 10 },
|
||||||
["vddc"] = { name = "voltage", units = _units.voltage },
|
["vddc"] = { name = "voltage", units = _units.voltage },
|
||||||
["voltage"] = { name = "voltage", units = _units.voltage },
|
["voltage"] = { name = "voltage", units = _units.voltage },
|
||||||
["current engine clock"] = { name = "engine_clock", units = _units.clock },
|
["current engine clock"] = { name = "engine_clock", units = _units.clock },
|
||||||
["current memory clock"] = { name = "memory_clock", units = _units.clock }
|
["current memory clock"] = { name = "memory_clock", units = _units.clock }
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ ATI widget type
|
-- {{{ ATI widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local pm = helpers.pathtotable("/sys/class/drm/"..warg.."/device")
|
local pm = helpers.pathtotable("/sys/class/drm/"..warg.."/device")
|
||||||
local _data = {}
|
local _data = {}
|
||||||
|
|
||||||
-- Get power info
|
-- Get power info
|
||||||
_data["{method}"] =
|
_data["{method}"] =
|
||||||
pm.power_method and string.sub(pm.power_method, 1, -2) or "N/A"
|
pm.power_method and string.sub(pm.power_method, 1, -2) or "N/A"
|
||||||
_data["{dpm_state}"] =
|
_data["{dpm_state}"] =
|
||||||
pm.power_dpm_state and string.sub(pm.power_dpm_state, 1, -2) or "N/A"
|
pm.power_dpm_state and string.sub(pm.power_dpm_state, 1, -2) or "N/A"
|
||||||
_data["{dpm_perf_level}"] =
|
_data["{dpm_perf_level}"] =
|
||||||
pm.power_dpm_force_performance_level and
|
pm.power_dpm_force_performance_level and
|
||||||
string.sub(pm.power_dpm_force_performance_level, 1, -2) or "N/A"
|
string.sub(pm.power_dpm_force_performance_level, 1, -2) or "N/A"
|
||||||
_data["{profile}"] =
|
_data["{profile}"] =
|
||||||
pm.power_profile and string.sub(pm.power_profile, 1, -2) or "N/A"
|
pm.power_profile and string.sub(pm.power_profile, 1, -2) or "N/A"
|
||||||
|
|
||||||
local f = io.open("/sys/kernel/debug/dri/64/radeon_pm_info", "r")
|
local f = io.open("/sys/kernel/debug/dri/64/radeon_pm_info", "r")
|
||||||
if f then -- Get ATI info from the debug filesystem
|
if f then -- Get ATI info from the debug filesystem
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
for k, unit in string.gmatch(line, "(%a+[%a%s]*):[%s]+([%d]+)") do
|
for k, unit in string.gmatch(line, "(%a+[%a%s]*):[%s]+([%d]+)") do
|
||||||
unit = tonumber(unit)
|
unit = tonumber(unit)
|
||||||
|
|
||||||
_data["{dpm_power_level}"] = -- DPM active?
|
_data["{dpm_power_level}"] = -- DPM active?
|
||||||
tonumber(string.match(line, "power level ([%d])")) or "N/A"
|
tonumber(string.match(line, "power level ([%d])")) or "N/A"
|
||||||
|
|
||||||
if _reps[k] then
|
if _reps[k] then
|
||||||
for u, v in pairs(_reps[k].units) do
|
for u, v in pairs(_reps[k].units) do
|
||||||
_data["{".._reps[k].name.." "..u.."}"] =
|
_data["{".._reps[k].name.." "..u.."}"] =
|
||||||
(unit * (_reps[k].mul or 1)) / v
|
(unit * (_reps[k].mul or 1)) / v
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
end
|
end
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
|
||||||
return _data
|
return _data
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,33 +19,33 @@ local batacpi = {}
|
|||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local battery_info = {}
|
local battery_info = {}
|
||||||
local battery_state = {
|
local battery_state = {
|
||||||
["full"] = "↯",
|
["full"] = "↯",
|
||||||
["unknown"] = "⌁",
|
["unknown"] = "⌁",
|
||||||
["charged"] = "↯",
|
["charged"] = "↯",
|
||||||
["charging"] = "+",
|
["charging"] = "+",
|
||||||
["discharging"] = "-"
|
["discharging"] = "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get data from acpitool
|
-- Get data from acpitool
|
||||||
local f = io.popen("acpitool -b")
|
local f = io.popen("acpitool -b")
|
||||||
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
-- Check if the battery is present
|
-- Check if the battery is present
|
||||||
if string.match(line, "^[%s]+Battery.*") then
|
if string.match(line, "^[%s]+Battery.*") then
|
||||||
-- Store state and charge information
|
-- Store state and charge information
|
||||||
table.insert(battery_info, (battery_state[string.match(line, "([%a]*),") or "unknown"]))
|
table.insert(battery_info, (battery_state[string.match(line, "([%a]*),") or "unknown"]))
|
||||||
table.insert(battery_info, (tonumber(string.match(line, "([%d]?[%d]?[%d])%.")) or 0))
|
table.insert(battery_info, (tonumber(string.match(line, "([%d]?[%d]?[%d])%.")) or 0))
|
||||||
-- Store remaining time information
|
-- Store remaining time information
|
||||||
table.insert(battery_info, (string.match(line, "%%,%s(.*)") or "N/A"))
|
table.insert(battery_info, (string.match(line, "%%,%s(.*)") or "N/A"))
|
||||||
else
|
else
|
||||||
return {battery_state["unknown"], 0, "N/A"}
|
return {battery_state["unknown"], 0, "N/A"}
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
return battery_info
|
return battery_info
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -8,13 +8,13 @@ local tonumber = tonumber
|
|||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local math = {
|
local math = {
|
||||||
min = math.min,
|
min = math.min,
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
local string = {
|
local string = {
|
||||||
find = string.find,
|
find = string.find,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
format = string.format
|
format = string.format
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -26,53 +26,53 @@ local batpmu = {}
|
|||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format, batid)
|
local function worker(format, batid)
|
||||||
local battery_state = {
|
local battery_state = {
|
||||||
["full"] = "↯",
|
["full"] = "↯",
|
||||||
["unknown"] = "⌁",
|
["unknown"] = "⌁",
|
||||||
["00000013"] = "+",
|
["00000013"] = "+",
|
||||||
["00000011"] = "-"
|
["00000011"] = "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get /proc/pmu/battery* state
|
-- Get /proc/pmu/battery* state
|
||||||
local f = io.open("/proc/pmu/" .. batid)
|
local f = io.open("/proc/pmu/" .. batid)
|
||||||
-- Handler for incompetent users
|
-- Handler for incompetent users
|
||||||
if not f then return {battery_state["unknown"], 0, "N/A"} end
|
if not f then return {battery_state["unknown"], 0, "N/A"} end
|
||||||
local statefile = f:read("*all")
|
local statefile = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Get /proc/pmu/info data
|
-- Get /proc/pmu/info data
|
||||||
local f = io.open("/proc/pmu/info")
|
local f = io.open("/proc/pmu/info")
|
||||||
local infofile = f:read("*all")
|
local infofile = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Check if the battery is present
|
-- Check if the battery is present
|
||||||
if infofile == nil or string.find(infofile, "Battery count[%s]+:[%s]0") then
|
if infofile == nil or string.find(infofile, "Battery count[%s]+:[%s]0") then
|
||||||
return {battery_state["unknown"], 0, "N/A"}
|
return {battery_state["unknown"], 0, "N/A"}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Get capacity and charge information
|
-- Get capacity and charge information
|
||||||
local capacity = string.match(statefile, "max_charge[%s]+:[%s]([%d]+).*")
|
local capacity = string.match(statefile, "max_charge[%s]+:[%s]([%d]+).*")
|
||||||
local remaining = string.match(statefile, "charge[%s]+:[%s]([%d]+).*")
|
local remaining = string.match(statefile, "charge[%s]+:[%s]([%d]+).*")
|
||||||
|
|
||||||
-- Calculate percentage
|
-- Calculate percentage
|
||||||
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||||
|
|
||||||
|
|
||||||
-- Get timer information
|
-- Get timer information
|
||||||
local timer = string.match(statefile, "time rem%.[%s]+:[%s]([%d]+).*")
|
local timer = string.match(statefile, "time rem%.[%s]+:[%s]([%d]+).*")
|
||||||
if timer == "0" then return {battery_state["full"], percent, "N/A"} end
|
if timer == "0" then return {battery_state["full"], percent, "N/A"} end
|
||||||
|
|
||||||
-- Get state information
|
-- Get state information
|
||||||
local state = string.match(statefile, "flags[%s]+:[%s]([%d]+).*")
|
local state = string.match(statefile, "flags[%s]+:[%s]([%d]+).*")
|
||||||
local state = battery_state[state] or battery_state["unknown"]
|
local state = battery_state[state] or battery_state["unknown"]
|
||||||
|
|
||||||
-- Calculate remaining (charging or discharging) time
|
-- Calculate remaining (charging or discharging) time
|
||||||
local hoursleft = math.floor(tonumber(timer) / 3600)
|
local hoursleft = math.floor(tonumber(timer) / 3600)
|
||||||
local minutesleft = math.floor((tonumber(timer) / 60) % 60)
|
local minutesleft = math.floor((tonumber(timer) / 60) % 60)
|
||||||
local time = string.format("%02d:%02d", hoursleft, minutesleft)
|
local time = string.format("%02d:%02d", hoursleft, minutesleft)
|
||||||
|
|
||||||
return {state, percent, time}
|
return {state, percent, time}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -8,13 +8,13 @@ local tonumber = tonumber
|
|||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local math = {
|
local math = {
|
||||||
min = math.min,
|
min = math.min,
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
local string = {
|
local string = {
|
||||||
find = string.find,
|
find = string.find,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
format = string.format
|
format = string.format
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -26,60 +26,60 @@ local batproc = {}
|
|||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format, batid)
|
local function worker(format, batid)
|
||||||
local battery_state = {
|
local battery_state = {
|
||||||
["full"] = "↯",
|
["full"] = "↯",
|
||||||
["unknown"] = "⌁",
|
["unknown"] = "⌁",
|
||||||
["charged"] = "↯",
|
["charged"] = "↯",
|
||||||
["charging"] = "+",
|
["charging"] = "+",
|
||||||
["discharging"] = "-"
|
["discharging"] = "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get /proc/acpi/battery info
|
-- Get /proc/acpi/battery info
|
||||||
local f = io.open("/proc/acpi/battery/"..batid.."/info")
|
local f = io.open("/proc/acpi/battery/"..batid.."/info")
|
||||||
-- Handler for incompetent users
|
-- Handler for incompetent users
|
||||||
if not f then return {battery_state["unknown"], 0, "N/A"} end
|
if not f then return {battery_state["unknown"], 0, "N/A"} end
|
||||||
local infofile = f:read("*all")
|
local infofile = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Check if the battery is present
|
-- Check if the battery is present
|
||||||
if infofile == nil or string.find(infofile, "present:[%s]+no") then
|
if infofile == nil or string.find(infofile, "present:[%s]+no") then
|
||||||
return {battery_state["unknown"], 0, "N/A"}
|
return {battery_state["unknown"], 0, "N/A"}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get capacity information
|
-- Get capacity information
|
||||||
local capacity = string.match(infofile, "last full capacity:[%s]+([%d]+).*")
|
local capacity = string.match(infofile, "last full capacity:[%s]+([%d]+).*")
|
||||||
|
|
||||||
|
|
||||||
-- Get /proc/acpi/battery state
|
-- Get /proc/acpi/battery state
|
||||||
local f = io.open("/proc/acpi/battery/"..batid.."/state")
|
local f = io.open("/proc/acpi/battery/"..batid.."/state")
|
||||||
local statefile = f:read("*all")
|
local statefile = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Get state information
|
-- Get state information
|
||||||
local state = string.match(statefile, "charging state:[%s]+([%a]+).*")
|
local state = string.match(statefile, "charging state:[%s]+([%a]+).*")
|
||||||
local state = battery_state[state] or battery_state["unknown"]
|
local state = battery_state[state] or battery_state["unknown"]
|
||||||
|
|
||||||
-- Get charge information
|
-- Get charge information
|
||||||
local rate = string.match(statefile, "present rate:[%s]+([%d]+).*")
|
local rate = string.match(statefile, "present rate:[%s]+([%d]+).*")
|
||||||
local remaining = string.match(statefile, "remaining capacity:[%s]+([%d]+).*")
|
local remaining = string.match(statefile, "remaining capacity:[%s]+([%d]+).*")
|
||||||
|
|
||||||
|
|
||||||
-- Calculate percentage (but work around broken BAT/ACPI implementations)
|
-- Calculate percentage (but work around broken BAT/ACPI implementations)
|
||||||
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||||
|
|
||||||
-- Calculate remaining (charging or discharging) time
|
-- Calculate remaining (charging or discharging) time
|
||||||
if state == "+" then
|
if state == "+" then
|
||||||
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)
|
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)
|
||||||
elseif state == "-" then
|
elseif state == "-" then
|
||||||
timeleft = tonumber(remaining) / tonumber(rate)
|
timeleft = tonumber(remaining) / tonumber(rate)
|
||||||
else
|
else
|
||||||
return {state, percent, "N/A"}
|
return {state, percent, "N/A"}
|
||||||
end
|
end
|
||||||
local hoursleft = math.floor(timeleft)
|
local hoursleft = math.floor(timeleft)
|
||||||
local minutesleft = math.floor((timeleft - hoursleft) * 60 )
|
local minutesleft = math.floor((timeleft - hoursleft) * 60 )
|
||||||
local time = string.format("%02d:%02d", hoursleft, minutesleft)
|
local time = string.format("%02d:%02d", hoursleft, minutesleft)
|
||||||
|
|
||||||
return {state, percent, time}
|
return {state, percent, time}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -26,161 +26,160 @@ BB = {}
|
|||||||
BB.__index = BB
|
BB.__index = BB
|
||||||
|
|
||||||
function BB.create(url, builder)
|
function BB.create(url, builder)
|
||||||
local b = {}
|
local b = {}
|
||||||
setmetatable(b,BB)
|
setmetatable(b,BB)
|
||||||
b.url = url -- buildbot url
|
b.url = url -- buildbot url
|
||||||
b.builder = builder -- builder name
|
b.builder = builder -- builder name
|
||||||
b.lastChecked = 0 -- last checked build number
|
b.lastChecked = 0 -- last checked build number
|
||||||
b.lastSuccessful = 0 -- last successful build number
|
b.lastSuccessful = 0 -- last successful build number
|
||||||
b.lastResult = nil -- last json parsed result
|
b.lastResult = nil -- last json parsed result
|
||||||
b.lastError = nil -- last error string or nil if no error
|
b.lastError = nil -- last error string or nil if no error
|
||||||
return b
|
return b
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:_queryBuildbot(build_number)
|
function BB:_queryBuildbot(build_number)
|
||||||
local f = io.popen("curl --connect-timeout 1 "..self.url.."/json/builders/"..self.builder.."/builds/"..build_number)
|
local f = io.popen("curl --connect-timeout 1 "..self.url.."/json/builders/"..self.builder.."/builds/"..build_number)
|
||||||
local jsbuilder = f:read("*all")
|
local jsbuilder = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
if #jsbuilder == 0 then
|
if #jsbuilder == 0 then
|
||||||
return false, "can't read from url"
|
return false, "can't read from url"
|
||||||
end
|
end
|
||||||
|
|
||||||
local result_status, result = pcall(json.decode, jsbuilder, false)
|
local result_status, result = pcall(json.decode, jsbuilder, false)
|
||||||
if not result_status then
|
if not result_status then
|
||||||
return false, "can't parse json data"
|
return false, "can't parse json data"
|
||||||
end
|
end
|
||||||
return true, result
|
return true, result
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:_getBuildStatus(result)
|
function BB:_getBuildStatus(result)
|
||||||
if #result['text'] > 0 then
|
if #result['text'] > 0 then
|
||||||
local text = result['text']
|
local text = result['text']
|
||||||
if text[1] == "build" and text[2] == "successful" and #text == 2 then
|
if text[1] == "build" and text[2] == "successful" and #text == 2 then
|
||||||
--successful
|
--successful
|
||||||
return bs.OK
|
return bs.OK
|
||||||
else
|
|
||||||
--failed
|
|
||||||
return bs.FAILED
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
--in progress
|
--failed
|
||||||
return bs.RUNNING
|
return bs.FAILED
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
--in progress
|
||||||
|
return bs.RUNNING
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Function queries buildbot to refresh builds status.
|
-- Function queries buildbot to refresh builds status.
|
||||||
-- * if build is successful or failed it will not be queried again, number is stored in lasteChecked
|
-- * if build is successful or failed it will not be queried again, number is stored in lasteChecked
|
||||||
-- * up to 10 last builds will be checked to find last successful build
|
-- * up to 10 last builds will be checked to find last successful build
|
||||||
function BB:refresh()
|
function BB:refresh()
|
||||||
local last_pass_fail = 0
|
local last_pass_fail = 0
|
||||||
local nr = -1
|
local nr = -1
|
||||||
local last_result
|
local last_result
|
||||||
local iter_counter = 0
|
local iter_counter = 0
|
||||||
|
|
||||||
self.lastError = nil
|
self.lastError = nil
|
||||||
self.lastResult = nil
|
self.lastResult = nil
|
||||||
--- there is a gap to fill in, iterate all not checked builds starting from latest
|
--- there is a gap to fill in, iterate all not checked builds starting from latest
|
||||||
while nr > self.lastChecked or nr == -1 do
|
while nr > self.lastChecked or nr == -1 do
|
||||||
local r_status, r = self:_queryBuildbot(nr)
|
local r_status, r = self:_queryBuildbot(nr)
|
||||||
local s
|
local s
|
||||||
|
|
||||||
if not r_status then
|
if not r_status then
|
||||||
self.lastError = r
|
self.lastError = r
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
s = self:_getBuildStatus(r)
|
s = self:_getBuildStatus(r)
|
||||||
if not last_result then
|
if not last_result then
|
||||||
last_result = r
|
last_result = r
|
||||||
end
|
end
|
||||||
nr = r['number']
|
nr = r['number']
|
||||||
assert(nr > 0)
|
assert(nr > 0)
|
||||||
if last_pass_fail == 0 and (s == bs.OK or s == bs.FAILED) then
|
if last_pass_fail == 0 and (s == bs.OK or s == bs.FAILED) then
|
||||||
last_pass_fail = nr
|
last_pass_fail = nr
|
||||||
end
|
end
|
||||||
if s == bs.OK then --successful
|
if s == bs.OK then --successful
|
||||||
self.lastSuccessful = nr
|
self.lastSuccessful = nr
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
nr = nr - 1
|
nr = nr - 1
|
||||||
iter_counter = iter_counter + 1
|
iter_counter = iter_counter + 1
|
||||||
if iter_counter > 10 then --check max last 10 builds when searching for successful build
|
if iter_counter > 10 then --check max last 10 builds when searching for successful build
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if last_pass_fail ~= 0 then
|
if last_pass_fail ~= 0 then
|
||||||
self.lastChecked = last_pass_fail
|
self.lastChecked = last_pass_fail
|
||||||
end
|
end
|
||||||
if last_result then
|
if last_result then
|
||||||
self.lastResult = last_result
|
self.lastResult = last_result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getLastSuccessful()
|
function BB:getLastSuccessful()
|
||||||
return self.lastSuccessful
|
return self.lastSuccessful
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getCurrent()
|
function BB:getCurrent()
|
||||||
return self.lastResult['number']
|
return self.lastResult['number']
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getCurrentStatus()
|
function BB:getCurrentStatus()
|
||||||
return self:_getBuildStatus(self.lastResult)
|
return self:_getBuildStatus(self.lastResult)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getBuilder()
|
function BB:getBuilder()
|
||||||
return self.builder
|
return self.builder
|
||||||
end
|
end
|
||||||
|
|
||||||
function BB:getError()
|
function BB:getError()
|
||||||
return self.lastError
|
return self.lastError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function getBuilderStatus(b)
|
local function getBuilderStatus(b)
|
||||||
local s = "[" .. b:getBuilder()
|
local s = "[" .. b:getBuilder()
|
||||||
--check if json library was loaded correctly
|
--check if json library was loaded correctly
|
||||||
if not json_status then
|
if not json_status then
|
||||||
return s .. ".<span color=\"orange\">can't find libluaX.X-json</span>]"
|
return s .. ".<span color=\"orange\">can't find libluaX.X-json</span>]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local err = b:getError()
|
local err = b:getError()
|
||||||
if err then
|
if err then
|
||||||
return s .. ".<span color=\"orange\">" .. err .. "</span>]"
|
return s .. ".<span color=\"orange\">" .. err .. "</span>]"
|
||||||
end
|
end
|
||||||
|
|
||||||
if b:getLastSuccessful() ~= 0 then
|
if b:getLastSuccessful() ~= 0 then
|
||||||
success_build_nr_str = "<span color=\"green\">".. b:getLastSuccessful() .."</span>"
|
success_build_nr_str = "<span color=\"green\">".. b:getLastSuccessful() .."</span>"
|
||||||
else
|
else
|
||||||
success_build_nr_str = "-"
|
success_build_nr_str = "-"
|
||||||
end
|
end
|
||||||
|
|
||||||
local current_build_color = bc[b:getCurrentStatus()]
|
local current_build_color = bc[b:getCurrentStatus()]
|
||||||
current_build_nr_str = "<span color=\""..current_build_color.."\">"..b:getCurrent().."</span>"
|
current_build_nr_str = "<span color=\""..current_build_color.."\">"..b:getCurrent().."</span>"
|
||||||
|
|
||||||
if current_build_color ~= "green" then
|
if current_build_color ~= "green" then
|
||||||
s = s .. "." .. current_build_nr_str
|
s = s .. "." .. current_build_nr_str
|
||||||
end
|
end
|
||||||
return s .. "." .. success_build_nr_str .. "]"
|
return s .. "." .. success_build_nr_str .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Buildbot widget type
|
-- {{{ Buildbot widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if #bb == 0 then --fill up bb with builders when worker function is run for the first time
|
if #bb == 0 then --fill up bb with builders when worker function is run for the first time
|
||||||
for i,v in pairs(warg) do
|
for i,v in pairs(warg) do
|
||||||
bb[#bb+1] = BB.create(v["url"], v["builder"])
|
bb[#bb+1] = BB.create(v["url"], v["builder"])
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local str = ""
|
local str = ""
|
||||||
for i,v in pairs(bb) do
|
for i,v in pairs(bb) do
|
||||||
v:refresh()
|
v:refresh()
|
||||||
str = str .. " " .. getBuilderStatus(v)
|
str = str .. " " .. getBuilderStatus(v)
|
||||||
end
|
end
|
||||||
return {str .. " "}
|
return {str .. " "}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
||||||
|
@ -25,48 +25,48 @@ local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
|
|||||||
|
|
||||||
-- {{{ Disk I/O widget type
|
-- {{{ Disk I/O widget type
|
||||||
local function worker(format, disk)
|
local function worker(format, disk)
|
||||||
if not disk then return end
|
if not disk then return end
|
||||||
|
|
||||||
local disk_lines = { [disk] = {} }
|
local disk_lines = { [disk] = {} }
|
||||||
local disk_stats = helpers.pathtotable("/sys/block/" .. disk)
|
local disk_stats = helpers.pathtotable("/sys/block/" .. disk)
|
||||||
|
|
||||||
if disk_stats.stat then
|
if disk_stats.stat then
|
||||||
local match = string.gmatch(disk_stats.stat, "[%s]+([%d]+)")
|
local match = string.gmatch(disk_stats.stat, "[%s]+([%d]+)")
|
||||||
for i = 1, 11 do -- Store disk stats
|
for i = 1, 11 do -- Store disk stats
|
||||||
table.insert(disk_lines[disk], match())
|
table.insert(disk_lines[disk], match())
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Ensure tables are initialized correctly
|
-- Ensure tables are initialized correctly
|
||||||
local diff_total = { [disk] = {} }
|
local diff_total = { [disk] = {} }
|
||||||
if not disk_total[disk] then
|
if not disk_total[disk] then
|
||||||
disk_usage[disk] = {}
|
disk_usage[disk] = {}
|
||||||
disk_total[disk] = {}
|
disk_total[disk] = {}
|
||||||
|
|
||||||
while #disk_total[disk] < #disk_lines[disk] do
|
while #disk_total[disk] < #disk_lines[disk] do
|
||||||
table.insert(disk_total[disk], 0)
|
table.insert(disk_total[disk], 0)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for i, v in ipairs(disk_lines[disk]) do
|
for i, v in ipairs(disk_lines[disk]) do
|
||||||
-- Diskstats are absolute, substract our last reading
|
-- Diskstats are absolute, substract our last reading
|
||||||
diff_total[disk][i] = v - disk_total[disk][i]
|
diff_total[disk][i] = v - disk_total[disk][i]
|
||||||
|
|
||||||
-- Store totals
|
-- Store totals
|
||||||
disk_total[disk][i] = v
|
disk_total[disk][i] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Calculate and store I/O
|
-- Calculate and store I/O
|
||||||
helpers.uformat(disk_usage[disk], "read", diff_total[disk][3], unit)
|
helpers.uformat(disk_usage[disk], "read", diff_total[disk][3], unit)
|
||||||
helpers.uformat(disk_usage[disk], "write", diff_total[disk][7], unit)
|
helpers.uformat(disk_usage[disk], "write", diff_total[disk][7], unit)
|
||||||
helpers.uformat(disk_usage[disk], "total", diff_total[disk][7] + diff_total[disk][3], unit)
|
helpers.uformat(disk_usage[disk], "total", diff_total[disk][7] + diff_total[disk][3], unit)
|
||||||
|
|
||||||
-- Store I/O scheduler
|
-- Store I/O scheduler
|
||||||
if disk_stats.queue and disk_stats.queue.scheduler then
|
if disk_stats.queue and disk_stats.queue.scheduler then
|
||||||
disk_usage[disk]["{sched}"] = string.gmatch(disk_stats.queue.scheduler, "%[([%a]+)%]")
|
disk_usage[disk]["{sched}"] = string.gmatch(disk_stats.queue.scheduler, "%[([%a]+)%]")
|
||||||
end
|
end
|
||||||
|
|
||||||
return disk_usage[disk]
|
return disk_usage[disk]
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -20,28 +20,28 @@ local mpc = {}
|
|||||||
|
|
||||||
-- {{{ MPC widget type
|
-- {{{ MPC widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Get data from mpd
|
-- Get data from mpd
|
||||||
local f = io.popen("mpc")
|
local f = io.popen("mpc")
|
||||||
local np = f:read("*line")
|
local np = f:read("*line")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Not installed,
|
-- Not installed,
|
||||||
if np == nil or -- off or stoppped.
|
if np == nil or -- off or stoppped.
|
||||||
(string.find(np, "MPD_HOST") or string.find(np, "volume:"))
|
(string.find(np, "MPD_HOST") or string.find(np, "volume:"))
|
||||||
then
|
then
|
||||||
return {"Stopped"}
|
return {"Stopped"}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if we should scroll, or maybe truncate
|
||||||
|
if warg then
|
||||||
|
if type(warg) == "table" then
|
||||||
|
np = helpers.scroll(np, warg[1], warg[2])
|
||||||
|
else
|
||||||
|
np = helpers.truncate(np, warg)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if we should scroll, or maybe truncate
|
return {helpers.escape(np)}
|
||||||
if warg then
|
|
||||||
if type(warg) == "table" then
|
|
||||||
np = helpers.scroll(np, warg[1], warg[2])
|
|
||||||
else
|
|
||||||
np = helpers.truncate(np, warg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return {helpers.escape(np)}
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -25,114 +25,114 @@ local net = {}
|
|||||||
local nets = {}
|
local nets = {}
|
||||||
-- Variable definitions
|
-- Variable definitions
|
||||||
local unit = { ["b"] = 1, ["kb"] = 1024,
|
local unit = { ["b"] = 1, ["kb"] = 1024,
|
||||||
["mb"] = 1024^2, ["gb"] = 1024^3
|
["mb"] = 1024^2, ["gb"] = 1024^3
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ Net widget type
|
-- {{{ Net widget type
|
||||||
local function worker(format, tignorelist)
|
local function worker(format, tignorelist)
|
||||||
local args = {}
|
local args = {}
|
||||||
local tignore = {}
|
local tignore = {}
|
||||||
local total_rx = 0
|
local total_rx = 0
|
||||||
local total_tx = 0
|
local total_tx = 0
|
||||||
local any_up = 0
|
local any_up = 0
|
||||||
|
|
||||||
if not tignorelist then
|
if not tignorelist then
|
||||||
tignorelist = {"lo", "wmaster0"}
|
tignorelist = {"lo", "wmaster0"}
|
||||||
end
|
end
|
||||||
for k, i in pairs(tignorelist) do
|
for k, i in pairs(tignorelist) do
|
||||||
tignore[i] = true
|
tignore[i] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get NET stats
|
-- Get NET stats
|
||||||
for line in io.lines("/proc/net/dev") do
|
for line in io.lines("/proc/net/dev") do
|
||||||
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
||||||
local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
|
local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
|
||||||
if name ~= nil then
|
if name ~= nil then
|
||||||
-- Received bytes, first value after the name
|
-- Received bytes, first value after the name
|
||||||
local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
|
local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
|
||||||
-- Transmited bytes, 7 fields from end of the line
|
-- Transmited bytes, 7 fields from end of the line
|
||||||
local send = tonumber(string.match(line,
|
local send = tonumber(string.match(line,
|
||||||
"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
|
"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
|
||||||
|
|
||||||
if not tignore[name] then
|
if not tignore[name] then
|
||||||
total_rx = total_rx + recv
|
total_rx = total_rx + recv
|
||||||
total_tx = total_tx + send
|
total_tx = total_tx + send
|
||||||
end
|
end
|
||||||
|
|
||||||
helpers.uformat(args, name .. " rx", recv, unit)
|
helpers.uformat(args, name .. " rx", recv, unit)
|
||||||
helpers.uformat(args, name .. " tx", send, unit)
|
helpers.uformat(args, name .. " tx", send, unit)
|
||||||
|
|
||||||
if nets[name] == nil then
|
if nets[name] == nil then
|
||||||
-- Default values on the first run
|
|
||||||
nets[name] = {}
|
|
||||||
|
|
||||||
helpers.uformat(args, name .. " down", 0, unit)
|
|
||||||
helpers.uformat(args, name .. " up", 0, unit)
|
|
||||||
args["{"..name.." carrier}"] = 0
|
|
||||||
|
|
||||||
nets[name].time = os.time()
|
|
||||||
else -- Net stats are absolute, substract our last reading
|
|
||||||
local interval = os.time() - nets[name].time > 0 and
|
|
||||||
os.time() - nets[name].time or 1
|
|
||||||
nets[name].time = os.time()
|
|
||||||
|
|
||||||
local down = (recv - nets[name][1]) / interval
|
|
||||||
local up = (send - nets[name][2]) / interval
|
|
||||||
|
|
||||||
helpers.uformat(args, name .. " down", down, unit)
|
|
||||||
helpers.uformat(args, name .. " up", up, unit)
|
|
||||||
|
|
||||||
-- Carrier detection
|
|
||||||
sysnet = helpers.pathtotable("/sys/class/net/" .. name)
|
|
||||||
|
|
||||||
if sysnet.carrier then
|
|
||||||
ccarrier = tonumber(sysnet.carrier)
|
|
||||||
|
|
||||||
args["{"..name.." carrier}"] = ccarrier
|
|
||||||
if ccarrier ~= 0 and not tignore[name] then
|
|
||||||
any_up = 1
|
|
||||||
end
|
|
||||||
else
|
|
||||||
args["{"..name.." carrier}"] = 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Store totals
|
|
||||||
nets[name][1] = recv
|
|
||||||
nets[name][2] = send
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
helpers.uformat(args, "total rx", total_rx, unit)
|
|
||||||
helpers.uformat(args, "total tx", total_tx, unit)
|
|
||||||
|
|
||||||
if nets["total"] == nil then
|
|
||||||
-- Default values on the first run
|
-- Default values on the first run
|
||||||
nets["total"] = {}
|
nets[name] = {}
|
||||||
|
|
||||||
helpers.uformat(args, "total down", 0, unit)
|
helpers.uformat(args, name .. " down", 0, unit)
|
||||||
helpers.uformat(args, "total up", 0, unit)
|
helpers.uformat(args, name .. " up", 0, unit)
|
||||||
args["{total carrier}"] = 0
|
args["{"..name.." carrier}"] = 0
|
||||||
|
|
||||||
nets["total"].time = os.time()
|
nets[name].time = os.time()
|
||||||
else -- Net stats are absolute, substract our last reading
|
else -- Net stats are absolute, substract our last reading
|
||||||
local interval = os.time() - nets["total"].time > 0 and
|
local interval = os.time() - nets[name].time > 0 and
|
||||||
os.time() - nets["total"].time or 1
|
os.time() - nets[name].time or 1
|
||||||
nets["total"].time = os.time()
|
nets[name].time = os.time()
|
||||||
|
|
||||||
local down = (total_rx - nets["total"][1]) / interval
|
local down = (recv - nets[name][1]) / interval
|
||||||
local up = (total_tx - nets["total"][2]) / interval
|
local up = (send - nets[name][2]) / interval
|
||||||
|
|
||||||
helpers.uformat(args, "total down", down, unit)
|
helpers.uformat(args, name .. " down", down, unit)
|
||||||
helpers.uformat(args, "total up", up, unit)
|
helpers.uformat(args, name .. " up", up, unit)
|
||||||
args["{total carrier}"] = any_up
|
|
||||||
|
-- Carrier detection
|
||||||
|
sysnet = helpers.pathtotable("/sys/class/net/" .. name)
|
||||||
|
|
||||||
|
if sysnet.carrier then
|
||||||
|
ccarrier = tonumber(sysnet.carrier)
|
||||||
|
|
||||||
|
args["{"..name.." carrier}"] = ccarrier
|
||||||
|
if ccarrier ~= 0 and not tignore[name] then
|
||||||
|
any_up = 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
args["{"..name.." carrier}"] = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Store totals
|
||||||
|
nets[name][1] = recv
|
||||||
|
nets[name][2] = send
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Store totals
|
helpers.uformat(args, "total rx", total_rx, unit)
|
||||||
nets["total"][1] = total_rx
|
helpers.uformat(args, "total tx", total_tx, unit)
|
||||||
nets["total"][2] = total_tx
|
|
||||||
|
|
||||||
return args
|
if nets["total"] == nil then
|
||||||
|
-- Default values on the first run
|
||||||
|
nets["total"] = {}
|
||||||
|
|
||||||
|
helpers.uformat(args, "total down", 0, unit)
|
||||||
|
helpers.uformat(args, "total up", 0, unit)
|
||||||
|
args["{total carrier}"] = 0
|
||||||
|
|
||||||
|
nets["total"].time = os.time()
|
||||||
|
else -- Net stats are absolute, substract our last reading
|
||||||
|
local interval = os.time() - nets["total"].time > 0 and
|
||||||
|
os.time() - nets["total"].time or 1
|
||||||
|
nets["total"].time = os.time()
|
||||||
|
|
||||||
|
local down = (total_rx - nets["total"][1]) / interval
|
||||||
|
local up = (total_tx - nets["total"][2]) / interval
|
||||||
|
|
||||||
|
helpers.uformat(args, "total down", down, unit)
|
||||||
|
helpers.uformat(args, "total up", up, unit)
|
||||||
|
args["{total carrier}"] = any_up
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Store totals
|
||||||
|
nets["total"][1] = total_rx
|
||||||
|
nets["total"][2] = total_tx
|
||||||
|
|
||||||
|
return args
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -17,18 +17,18 @@ local netcfg = {}
|
|||||||
|
|
||||||
-- {{{ Netcfg widget type
|
-- {{{ Netcfg widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
-- Initialize counters
|
-- Initialize counters
|
||||||
local profiles = {}
|
local profiles = {}
|
||||||
|
|
||||||
local f = io.popen("ls -1 /var/run/network/profiles")
|
local f = io.popen("ls -1 /var/run/network/profiles")
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if line ~= nil then
|
if line ~= nil then
|
||||||
table.insert(profiles, line)
|
table.insert(profiles, line)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
return profiles
|
return profiles
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -18,24 +18,24 @@ local nvsmi = {}
|
|||||||
|
|
||||||
-- {{{ GPU Information widget type
|
-- {{{ GPU Information widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Fallback to querying first device
|
-- Fallback to querying first device
|
||||||
if not warg then warg = "0" end
|
if not warg then warg = "0" end
|
||||||
|
|
||||||
-- Get data from smi
|
-- Get data from smi
|
||||||
-- * Todo: support more; MEMORY,UTILIZATION,ECC,POWER,CLOCK,COMPUTE,PIDS,PERFORMANCE
|
-- * Todo: support more; MEMORY,UTILIZATION,ECC,POWER,CLOCK,COMPUTE,PIDS,PERFORMANCE
|
||||||
local f = io.popen("nvidia-smi -q -d TEMPERATURE -i " .. warg)
|
local f = io.popen("nvidia-smi -q -d TEMPERATURE -i " .. warg)
|
||||||
local smi = f:read("*all")
|
local smi = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Not installed
|
-- Not installed
|
||||||
if smi == nil then return {0} end
|
if smi == nil then return {0} end
|
||||||
|
|
||||||
-- Get temperature information
|
-- Get temperature information
|
||||||
local _thermal = string.match(smi, "Gpu[%s]+:[%s]([%d]+)[%s]C")
|
local _thermal = string.match(smi, "Gpu[%s]+:[%s]([%d]+)[%s]C")
|
||||||
-- Handle devices without data
|
-- Handle devices without data
|
||||||
if _thermal == nil then return {0} end
|
if _thermal == nil then return {0} end
|
||||||
|
|
||||||
return {tonumber(_thermal)}
|
return {tonumber(_thermal)}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ local io = { popen = io.popen }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
local math = {
|
local math = {
|
||||||
ceil = math.ceil,
|
ceil = math.ceil,
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -23,71 +23,71 @@ local openweather = {}
|
|||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
local _wdirs = { "N", "NE", "E", "SE", "S", "SW", "W", "NW", "N" }
|
local _wdirs = { "N", "NE", "E", "SE", "S", "SW", "W", "NW", "N" }
|
||||||
local _wdata = {
|
local _wdata = {
|
||||||
["{city}"] = "N/A",
|
["{city}"] = "N/A",
|
||||||
["{wind deg}"] = "N/A",
|
["{wind deg}"] = "N/A",
|
||||||
["{wind aim}"] = "N/A",
|
["{wind aim}"] = "N/A",
|
||||||
["{wind mps}"] = "N/A",
|
["{wind mps}"] = "N/A",
|
||||||
["{wind kmh}"] = "N/A",
|
["{wind kmh}"] = "N/A",
|
||||||
["{sky}"] = "N/A",
|
["{sky}"] = "N/A",
|
||||||
["{weather}"] = "N/A",
|
["{weather}"] = "N/A",
|
||||||
["{temp c}"] = "N/A",
|
["{temp c}"] = "N/A",
|
||||||
["{humid}"] = "N/A",
|
["{humid}"] = "N/A",
|
||||||
["{press}"] = "N/A"
|
["{press}"] = "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ Openweather widget type
|
-- {{{ Openweather widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Get weather forceast using the city ID code, from:
|
-- Get weather forceast using the city ID code, from:
|
||||||
-- * OpenWeatherMap.org
|
-- * OpenWeatherMap.org
|
||||||
local openweather = "http://api.openweathermap.org/data/2.5/weather?id="..warg.."&mode=json&units=metric"
|
local openweather = "http://api.openweathermap.org/data/2.5/weather?id="..warg.."&mode=json&units=metric"
|
||||||
local f = io.popen("curl --connect-timeout 1 -fsm 3 '"..openweather.."'")
|
local f = io.popen("curl --connect-timeout 1 -fsm 3 '"..openweather.."'")
|
||||||
local ws = f:read("*all")
|
local ws = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Check if there was a timeout or a problem with the station
|
-- Check if there was a timeout or a problem with the station
|
||||||
if ws == nil then return _wdata end
|
if ws == nil then return _wdata end
|
||||||
|
|
||||||
_wdata["{city}"] = -- City name
|
_wdata["{city}"] = -- City name
|
||||||
string.match(ws, '"name":"([%a%s%-]+)"') or _wdata["{city}"]
|
string.match(ws, '"name":"([%a%s%-]+)"') or _wdata["{city}"]
|
||||||
_wdata["{wind deg}"] = -- Wind degrees
|
_wdata["{wind deg}"] = -- Wind degrees
|
||||||
string.match(ws, '"deg":([%d]+)') or _wdata["{wind deg}"]
|
string.match(ws, '"deg":([%d]+)') or _wdata["{wind deg}"]
|
||||||
_wdata["{wind mps}"] = -- Wind speed in meters per second
|
_wdata["{wind mps}"] = -- Wind speed in meters per second
|
||||||
string.match(ws, '"speed":([%d%.]+)') or _wdata["{wind mps}"]
|
string.match(ws, '"speed":([%d%.]+)') or _wdata["{wind mps}"]
|
||||||
_wdata["{sky}"] = -- Sky conditions
|
_wdata["{sky}"] = -- Sky conditions
|
||||||
string.match(ws, '"main":"([%a]+)"') or _wdata["{sky}"]
|
string.match(ws, '"main":"([%a]+)"') or _wdata["{sky}"]
|
||||||
_wdata["{weather}"] = -- Weather description
|
_wdata["{weather}"] = -- Weather description
|
||||||
string.match(ws, '"description":"([%a%s]+)"') or _wdata["{weather}"]
|
string.match(ws, '"description":"([%a%s]+)"') or _wdata["{weather}"]
|
||||||
_wdata["{temp c}"] = -- Temperature in celsius
|
_wdata["{temp c}"] = -- Temperature in celsius
|
||||||
string.match(ws, '"temp":([%-]?[%d%.]+)') or _wdata["{temp c}"]
|
string.match(ws, '"temp":([%-]?[%d%.]+)') or _wdata["{temp c}"]
|
||||||
_wdata["{humid}"] = -- Relative humidity in percent
|
_wdata["{humid}"] = -- Relative humidity in percent
|
||||||
string.match(ws, '"humidity":([%d]+)') or _wdata["{humid}"]
|
string.match(ws, '"humidity":([%d]+)') or _wdata["{humid}"]
|
||||||
_wdata["{press}"] = -- Pressure in hPa
|
_wdata["{press}"] = -- Pressure in hPa
|
||||||
string.match(ws, '"pressure":([%d%.]+)') or _wdata["{press}"]
|
string.match(ws, '"pressure":([%d%.]+)') or _wdata["{press}"]
|
||||||
|
|
||||||
-- Wind speed in km/h
|
-- Wind speed in km/h
|
||||||
if _wdata["{wind mps}"] ~= "N/A" then
|
if _wdata["{wind mps}"] ~= "N/A" then
|
||||||
_wdata["{wind mps}"] = math.floor(tonumber(_wdata["{wind mps}"]) + .5)
|
_wdata["{wind mps}"] = math.floor(tonumber(_wdata["{wind mps}"]) + .5)
|
||||||
_wdata["{wind kmh}"] = math.ceil(_wdata["{wind mps}"] * 3.6)
|
_wdata["{wind kmh}"] = math.ceil(_wdata["{wind mps}"] * 3.6)
|
||||||
end -- Temperature in °C
|
end -- Temperature in °C
|
||||||
if _wdata["{temp c}"] ~= "N/A" then
|
if _wdata["{temp c}"] ~= "N/A" then
|
||||||
_wdata["{temp c}"] = math.floor(tonumber(_wdata["{temp c}"]) + .5)
|
_wdata["{temp c}"] = math.floor(tonumber(_wdata["{temp c}"]) + .5)
|
||||||
end -- Calculate wind direction
|
end -- Calculate wind direction
|
||||||
if _wdata["{wind deg}"] ~= "N/A" then
|
if _wdata["{wind deg}"] ~= "N/A" then
|
||||||
_wdata["{wind deg}"] = tonumber(_wdata["{wind deg}"])
|
_wdata["{wind deg}"] = tonumber(_wdata["{wind deg}"])
|
||||||
|
|
||||||
-- Lua tables start at [1]
|
-- Lua tables start at [1]
|
||||||
if (_wdata["{wind deg}"] / 45)%1 == 0 then
|
if (_wdata["{wind deg}"] / 45)%1 == 0 then
|
||||||
_wdata["{wind aim}"] = _wdirs[_wdata["{wind deg}"] / 45 + 1]
|
_wdata["{wind aim}"] = _wdirs[_wdata["{wind deg}"] / 45 + 1]
|
||||||
else
|
else
|
||||||
_wdata["{wind aim}"] =
|
_wdata["{wind aim}"] =
|
||||||
_wdirs[math.ceil(_wdata["{wind deg}"] / 45) + 1]..
|
_wdirs[math.ceil(_wdata["{wind deg}"] / 45) + 1]..
|
||||||
_wdirs[math.floor(_wdata["{wind deg}"] / 45) + 1]
|
_wdirs[math.floor(_wdata["{wind deg}"] / 45) + 1]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return _wdata
|
return _wdata
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -18,36 +18,36 @@ local ossvol = {}
|
|||||||
|
|
||||||
-- {{{ Volume widget type
|
-- {{{ Volume widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local mixer_state = {
|
local mixer_state = {
|
||||||
["on"] = "♫", -- "",
|
["on"] = "♫", -- "",
|
||||||
["off"] = "♩" -- "M"
|
["off"] = "♩" -- "M"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get mixer control contents
|
-- Get mixer control contents
|
||||||
local f = io.popen("ossmix -c")
|
local f = io.popen("ossmix -c")
|
||||||
local mixer = f:read("*all")
|
local mixer = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Capture mixer control state
|
-- Capture mixer control state
|
||||||
local volu = tonumber(string.match(mixer, warg .. "[%s]([%d%.]+)"))/0.25
|
local volu = tonumber(string.match(mixer, warg .. "[%s]([%d%.]+)"))/0.25
|
||||||
local mute = string.match(mixer, "vol%.mute[%s]([%a]+)")
|
local mute = string.match(mixer, "vol%.mute[%s]([%a]+)")
|
||||||
-- Handle mixers without data
|
-- Handle mixers without data
|
||||||
if volu == nil then
|
if volu == nil then
|
||||||
return {0, mixer_state["off"]}
|
return {0, mixer_state["off"]}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle mixers without mute
|
-- Handle mixers without mute
|
||||||
if mute == "OFF" and volu == "0"
|
if mute == "OFF" and volu == "0"
|
||||||
-- Handle mixers that are muted
|
-- Handle mixers that are muted
|
||||||
or mute == "ON" then
|
or mute == "ON" then
|
||||||
mute = mixer_state["off"]
|
mute = mixer_state["off"]
|
||||||
else
|
else
|
||||||
mute = mixer_state["on"]
|
mute = mixer_state["on"]
|
||||||
end
|
end
|
||||||
|
|
||||||
return {volu, mute}
|
return {volu, mute}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -25,30 +25,30 @@ local pop = {}
|
|||||||
|
|
||||||
-- {{{ POP3 count widget type
|
-- {{{ POP3 count widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not sock_avail or (not warg or #warg ~= 4) then
|
if not sock_avail or (not warg or #warg ~= 4) then
|
||||||
return {"N/A"}
|
return {"N/A"}
|
||||||
end
|
end
|
||||||
|
|
||||||
local host, port = warg[1], tonumber(warg[2])
|
local host, port = warg[1], tonumber(warg[2])
|
||||||
local user, pass = warg[3], warg[4]
|
local user, pass = warg[3], warg[4]
|
||||||
|
|
||||||
local client = socket.tcp()
|
local client = socket.tcp()
|
||||||
client:settimeout(3)
|
client:settimeout(3)
|
||||||
client:connect(host, port)
|
client:connect(host, port)
|
||||||
client:receive("*l")
|
client:receive("*l")
|
||||||
client:send("USER " .. user .. "\r\n")
|
client:send("USER " .. user .. "\r\n")
|
||||||
client:receive("*l")
|
client:receive("*l")
|
||||||
client:send("PASS " .. pass .. "\r\n")
|
client:send("PASS " .. pass .. "\r\n")
|
||||||
client:receive("*l")
|
client:receive("*l")
|
||||||
client:send("STAT" .. "\r\n")
|
client:send("STAT" .. "\r\n")
|
||||||
local response = client:receive("*l")
|
local response = client:receive("*l")
|
||||||
client:close()
|
client:close()
|
||||||
|
|
||||||
if response:find("%+OK") then
|
if response:find("%+OK") then
|
||||||
response = response:match("%+OK (%d+)")
|
response = response:match("%+OK (%d+)")
|
||||||
end
|
end
|
||||||
|
|
||||||
return {response}
|
return {response}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@ local setmetatable = setmetatable
|
|||||||
local os = { execute = os.execute }
|
local os = { execute = os.execute }
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
find = string.find,
|
find = string.find,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
format = string.format,
|
format = string.format,
|
||||||
gmatch = string.gmatch
|
gmatch = string.gmatch
|
||||||
}
|
}
|
||||||
local math = {
|
local math = {
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -29,36 +29,36 @@ local pulse = {}
|
|||||||
|
|
||||||
-- {{{ Helper function
|
-- {{{ Helper function
|
||||||
local function pacmd(args)
|
local function pacmd(args)
|
||||||
local f = io.popen("pacmd "..args)
|
local f = io.popen("pacmd "..args)
|
||||||
if f == nil then
|
if f == nil then
|
||||||
return nil
|
return nil
|
||||||
else
|
else
|
||||||
local line = f:read("*all")
|
local line = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function escape(text)
|
local function escape(text)
|
||||||
local special_chars = { ["."] = "%.", ["-"] = "%-" }
|
local special_chars = { ["."] = "%.", ["-"] = "%-" }
|
||||||
return text:gsub("[%.%-]", special_chars)
|
return text:gsub("[%.%-]", special_chars)
|
||||||
end
|
end
|
||||||
|
|
||||||
local cached_sinks = {}
|
local cached_sinks = {}
|
||||||
local function get_sink_name(sink)
|
local function get_sink_name(sink)
|
||||||
if type(sink) == "string" then return sink end
|
if type(sink) == "string" then return sink end
|
||||||
-- avoid nil keys
|
-- avoid nil keys
|
||||||
local key = sink or 1
|
local key = sink or 1
|
||||||
-- Cache requests
|
-- Cache requests
|
||||||
if not cached_sinks[key] then
|
if not cached_sinks[key] then
|
||||||
local line = pacmd("list-sinks")
|
local line = pacmd("list-sinks")
|
||||||
if line == nil then return nil end
|
if line == nil then return nil end
|
||||||
for s in string.gmatch(line, "name: <(.-)>") do
|
for s in string.gmatch(line, "name: <(.-)>") do
|
||||||
table.insert(cached_sinks, s)
|
table.insert(cached_sinks, s)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return cached_sinks[key]
|
return cached_sinks[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -66,55 +66,55 @@ end
|
|||||||
|
|
||||||
-- {{{ Pulseaudio widget type
|
-- {{{ Pulseaudio widget type
|
||||||
local function worker(format, sink)
|
local function worker(format, sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return {0, "unknown"} end
|
if sink == nil then return {0, "unknown"} end
|
||||||
|
|
||||||
-- Get sink data
|
-- Get sink data
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
if sink == nil then return {0, "unknown"} end
|
if sink == nil then return {0, "unknown"} end
|
||||||
|
|
||||||
-- If mute return 0 (not "Mute") so we don't break progressbars
|
-- If mute return 0 (not "Mute") so we don't break progressbars
|
||||||
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
||||||
return {0, "off"}
|
return {0, "off"}
|
||||||
end
|
end
|
||||||
|
|
||||||
local vol = tonumber(string.match(data, "set%-sink%-volume "..escape(sink).." (0x[%x]+)"))
|
local vol = tonumber(string.match(data, "set%-sink%-volume "..escape(sink).." (0x[%x]+)"))
|
||||||
if vol == nil then vol = 0 end
|
if vol == nil then vol = 0 end
|
||||||
|
|
||||||
return { math.floor(vol/0x10000*100), "on"}
|
return { math.floor(vol/0x10000*100), "on"}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Volume control helper
|
-- {{{ Volume control helper
|
||||||
function pulse.add(percent, sink)
|
function pulse.add(percent, sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return end
|
if sink == nil then return end
|
||||||
|
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
|
|
||||||
local pattern = "set%-sink%-volume "..escape(sink).." (0x[%x]+)"
|
local pattern = "set%-sink%-volume "..escape(sink).." (0x[%x]+)"
|
||||||
local initial_vol = tonumber(string.match(data, pattern))
|
local initial_vol = tonumber(string.match(data, pattern))
|
||||||
|
|
||||||
local vol = initial_vol + percent/100*0x10000
|
local vol = initial_vol + percent/100*0x10000
|
||||||
if vol > 0x10000 then vol = 0x10000 end
|
if vol > 0x10000 then vol = 0x10000 end
|
||||||
if vol < 0 then vol = 0 end
|
if vol < 0 then vol = 0 end
|
||||||
|
|
||||||
local cmd = string.format("pacmd set-sink-volume %s 0x%x >/dev/null", sink, vol)
|
local cmd = string.format("pacmd set-sink-volume %s 0x%x >/dev/null", sink, vol)
|
||||||
return os.execute(cmd)
|
return os.execute(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pulse.toggle(sink)
|
function pulse.toggle(sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return end
|
if sink == nil then return end
|
||||||
|
|
||||||
local data = pacmd("dump")
|
local data = pacmd("dump")
|
||||||
local pattern = "set%-sink%-mute "..escape(sink).." (%a%a%a?)"
|
local pattern = "set%-sink%-mute "..escape(sink).." (%a%a%a?)"
|
||||||
local mute = string.match(data, pattern)
|
local mute = string.match(data, pattern)
|
||||||
|
|
||||||
-- 0 to enable a sink or 1 to mute it.
|
-- 0 to enable a sink or 1 to mute it.
|
||||||
local state = { yes = 0, no = 1}
|
local state = { yes = 0, no = 1}
|
||||||
local cmd = string.format("pacmd set-sink-mute %s %d", sink, state[mute])
|
local cmd = string.format("pacmd set-sink-mute %s %d", sink, state[mute])
|
||||||
return os.execute(cmd)
|
return os.execute(cmd)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -20,48 +20,48 @@ local rss = {}
|
|||||||
|
|
||||||
-- {{{ RSS widget type
|
-- {{{ RSS widget type
|
||||||
local function worker(format, input)
|
local function worker(format, input)
|
||||||
-- input: * feed - feed url
|
-- input: * feed - feed url
|
||||||
-- * object - entity to look for (typically: 'item')
|
-- * object - entity to look for (typically: 'item')
|
||||||
-- * fields - fields to read (example: 'link', 'title', 'description')
|
-- * fields - fields to read (example: 'link', 'title', 'description')
|
||||||
-- output: * count - number of entities found
|
-- output: * count - number of entities found
|
||||||
-- * one table for each field, containing wanted values
|
-- * one table for each field, containing wanted values
|
||||||
local feed = input.feed
|
local feed = input.feed
|
||||||
local object = input.object
|
local object = input.object
|
||||||
local fields = input.fields
|
local fields = input.fields
|
||||||
|
|
||||||
-- Initialise tables
|
-- Initialise tables
|
||||||
local out = {}
|
local out = {}
|
||||||
|
|
||||||
|
for _, v in pairs(fields) do
|
||||||
|
out[v] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Initialise variables
|
||||||
|
local ob = nil
|
||||||
|
local i,j,k = 1, 1, 0
|
||||||
|
local curl = "curl -A 'Mozilla/4.0' -fsm 5 --connect-timeout 3 "
|
||||||
|
|
||||||
|
-- Get the feed
|
||||||
|
local f = io.popen(curl .. '"' .. feed .. '"')
|
||||||
|
local feed = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
while true do
|
||||||
|
i, j, ob = feed.find(feed, "<" .. object .. ">(.-)</" .. object .. ">", i)
|
||||||
|
if not ob then break end
|
||||||
|
|
||||||
for _, v in pairs(fields) do
|
for _, v in pairs(fields) do
|
||||||
out[v] = {}
|
out[v][k] = ob:match("<" .. v .. ">(.*)</" .. v .. ">")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Initialise variables
|
k = k+1
|
||||||
local ob = nil
|
i = j+1
|
||||||
local i,j,k = 1, 1, 0
|
end
|
||||||
local curl = "curl -A 'Mozilla/4.0' -fsm 5 --connect-timeout 3 "
|
|
||||||
|
|
||||||
-- Get the feed
|
-- Update the entity count
|
||||||
local f = io.popen(curl .. '"' .. feed .. '"')
|
out.count = k
|
||||||
local feed = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
while true do
|
return out
|
||||||
i, j, ob = feed.find(feed, "<" .. object .. ">(.-)</" .. object .. ">", i)
|
|
||||||
if not ob then break end
|
|
||||||
|
|
||||||
for _, v in pairs(fields) do
|
|
||||||
out[v][k] = ob:match("<" .. v .. ">(.*)</" .. v .. ">")
|
|
||||||
end
|
|
||||||
|
|
||||||
k = k+1
|
|
||||||
i = j+1
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update the entity count
|
|
||||||
out.count = k
|
|
||||||
|
|
||||||
return out
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ local io = { popen = io.popen }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
gsub = string.gsub,
|
gsub = string.gsub,
|
||||||
match = string.match
|
match = string.match
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -22,47 +22,47 @@ local sensors = {}
|
|||||||
|
|
||||||
-- {{{ Split helper function
|
-- {{{ Split helper function
|
||||||
local function datasplit(str)
|
local function datasplit(str)
|
||||||
-- Splitting strings into associative array
|
-- Splitting strings into associative array
|
||||||
-- with some magic to get the values right.
|
-- with some magic to get the values right.
|
||||||
str = string.gsub(str, "\n", ":")
|
str = string.gsub(str, "\n", ":")
|
||||||
|
|
||||||
local tbl = {}
|
local tbl = {}
|
||||||
string.gsub(str, "([^:]*)", function (v)
|
string.gsub(str, "([^:]*)", function (v)
|
||||||
if string.match(v, ".") then
|
if string.match(v, ".") then
|
||||||
table.insert(tbl, v)
|
table.insert(tbl, v)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local assoc = {}
|
local assoc = {}
|
||||||
for c = 1, #tbl, 2 do
|
for c = 1, #tbl, 2 do
|
||||||
local k = string.gsub(tbl[c], ".*_", "")
|
local k = string.gsub(tbl[c], ".*_", "")
|
||||||
local v = tonumber(string.match(tbl[c+1], "[%d]+"))
|
local v = tonumber(string.match(tbl[c+1], "[%d]+"))
|
||||||
assoc[k] = v
|
assoc[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
return assoc
|
return assoc
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Sensors widget type
|
-- {{{ Sensors widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Get data from all sensors
|
-- Get data from all sensors
|
||||||
local f = io.popen("LANG=C sensors -uA")
|
local f = io.popen("LANG=C sensors -uA")
|
||||||
local lm_sensors = f:read("*all")
|
local lm_sensors = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
local sensor_data = string.gsub(
|
local sensor_data = string.gsub(
|
||||||
string.match(lm_sensors, warg..":\n(%s%s.-)\n[^ ]"), " ", "")
|
string.match(lm_sensors, warg..":\n(%s%s.-)\n[^ ]"), " ", "")
|
||||||
|
|
||||||
-- One of: crit, max
|
-- One of: crit, max
|
||||||
local divisor = "crit"
|
local divisor = "crit"
|
||||||
local s_data = datasplit(sensor_data)
|
local s_data = datasplit(sensor_data)
|
||||||
|
|
||||||
if s_data[divisor] and s_data[divisor] > 0 then
|
if s_data[divisor] and s_data[divisor] > 0 then
|
||||||
s_data.percent = s_data.input / s_data[divisor] * 100
|
s_data.percent = s_data.input / s_data[divisor] * 100
|
||||||
end
|
end
|
||||||
|
|
||||||
return {s_data.input, tonumber(s_data.percent)}
|
return {s_data.input, tonumber(s_data.percent)}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ local tonumber = tonumber
|
|||||||
local timer = (type(timer) == 'table' and timer or require("gears.timer"))
|
local timer = (type(timer) == 'table' and timer or require("gears.timer"))
|
||||||
local os = { time = os.time }
|
local os = { time = os.time }
|
||||||
local table = {
|
local table = {
|
||||||
insert = table.insert,
|
insert = table.insert,
|
||||||
remove = table.remove
|
remove = table.remove
|
||||||
}
|
}
|
||||||
|
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
@ -34,108 +34,108 @@ local widget_cache = {}
|
|||||||
-- {{{ Local functions
|
-- {{{ Local functions
|
||||||
-- {{{ Update a widget
|
-- {{{ Update a widget
|
||||||
local function update(widget, reg, disablecache)
|
local function update(widget, reg, disablecache)
|
||||||
-- Check if there are any equal widgets
|
-- Check if there are any equal widgets
|
||||||
if reg == nil then
|
if reg == nil then
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
if w == widget then
|
if w == widget then
|
||||||
for _, r in pairs(i) do
|
for _, r in pairs(i) do
|
||||||
update(w, r, disablecache)
|
update(w, r, disablecache)
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local t = os.time()
|
return
|
||||||
local data = {}
|
end
|
||||||
|
|
||||||
-- Check for chached output newer than the last update
|
local t = os.time()
|
||||||
if widget_cache[reg.wtype] ~= nil then
|
local data = {}
|
||||||
local c = widget_cache[reg.wtype]
|
|
||||||
|
|
||||||
if (c.time == nil or c.time <= t-reg.timer) or disablecache then
|
-- Check for chached output newer than the last update
|
||||||
c.time, c.data = t, reg.wtype(reg.format, reg.warg)
|
if widget_cache[reg.wtype] ~= nil then
|
||||||
end
|
local c = widget_cache[reg.wtype]
|
||||||
|
|
||||||
data = c.data
|
if (c.time == nil or c.time <= t-reg.timer) or disablecache then
|
||||||
else
|
c.time, c.data = t, reg.wtype(reg.format, reg.warg)
|
||||||
data = reg.wtype and reg.wtype(reg.format, reg.warg)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(data) == "table" then
|
data = c.data
|
||||||
if type(reg.format) == "string" then
|
else
|
||||||
data = helpers.format(reg.format, data)
|
data = reg.wtype and reg.wtype(reg.format, reg.warg)
|
||||||
elseif type(reg.format) == "function" then
|
end
|
||||||
data = reg.format(widget, data)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if widget.add_value ~= nil then
|
if type(data) == "table" then
|
||||||
widget:add_value(tonumber(data) and tonumber(data)/100)
|
if type(reg.format) == "string" then
|
||||||
elseif widget.set_value ~= nil then
|
data = helpers.format(reg.format, data)
|
||||||
widget:set_value(tonumber(data) and tonumber(data)/100)
|
elseif type(reg.format) == "function" then
|
||||||
elseif widget.set_markup ~= nil then
|
data = reg.format(widget, data)
|
||||||
widget:set_markup(data)
|
|
||||||
else
|
|
||||||
widget.text = data
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return data
|
if widget.add_value ~= nil then
|
||||||
|
widget:add_value(tonumber(data) and tonumber(data)/100)
|
||||||
|
elseif widget.set_value ~= nil then
|
||||||
|
widget:set_value(tonumber(data) and tonumber(data)/100)
|
||||||
|
elseif widget.set_markup ~= nil then
|
||||||
|
widget:set_markup(data)
|
||||||
|
else
|
||||||
|
widget.text = data
|
||||||
|
end
|
||||||
|
|
||||||
|
return data
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Register from reg object
|
-- {{{ Register from reg object
|
||||||
local function regregister(reg)
|
local function regregister(reg)
|
||||||
if not reg.running then
|
if not reg.running then
|
||||||
if registered[reg.widget] == nil then
|
if registered[reg.widget] == nil then
|
||||||
registered[reg.widget] = {}
|
registered[reg.widget] = {}
|
||||||
table.insert(registered[reg.widget], reg)
|
table.insert(registered[reg.widget], reg)
|
||||||
else
|
else
|
||||||
local already = false
|
local already = false
|
||||||
|
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
if w == reg.widget then
|
if w == reg.widget then
|
||||||
for _, v in pairs(i) do
|
for _, v in pairs(i) do
|
||||||
if v == reg then
|
if v == reg then
|
||||||
already = true
|
already = true
|
||||||
break
|
break
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if already then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if not already then
|
if already then
|
||||||
table.insert(registered[reg.widget], reg)
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Start the timer
|
if not already then
|
||||||
if reg.timer > 0 then
|
table.insert(registered[reg.widget], reg)
|
||||||
local tm = timers[reg.timer] and timers[reg.timer].timer
|
end
|
||||||
tm = tm or timer({ timeout = reg.timer })
|
|
||||||
if tm.connect_signal then
|
|
||||||
tm:connect_signal("timeout", reg.update)
|
|
||||||
else
|
|
||||||
tm:add_signal("timeout", reg.update)
|
|
||||||
end
|
|
||||||
if not timers[reg.timer] then
|
|
||||||
timers[reg.timer] = { timer = tm, refs = 1 }
|
|
||||||
else
|
|
||||||
timers[reg.timer].refs = timers[reg.timer].refs + 1
|
|
||||||
end
|
|
||||||
if not tm.started then
|
|
||||||
tm:start()
|
|
||||||
end
|
|
||||||
-- Initial update
|
|
||||||
reg.update()
|
|
||||||
end
|
|
||||||
reg.running = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Start the timer
|
||||||
|
if reg.timer > 0 then
|
||||||
|
local tm = timers[reg.timer] and timers[reg.timer].timer
|
||||||
|
tm = tm or timer({ timeout = reg.timer })
|
||||||
|
if tm.connect_signal then
|
||||||
|
tm:connect_signal("timeout", reg.update)
|
||||||
|
else
|
||||||
|
tm:add_signal("timeout", reg.update)
|
||||||
|
end
|
||||||
|
if not timers[reg.timer] then
|
||||||
|
timers[reg.timer] = { timer = tm, refs = 1 }
|
||||||
|
else
|
||||||
|
timers[reg.timer].refs = timers[reg.timer].refs + 1
|
||||||
|
end
|
||||||
|
if not tm.started then
|
||||||
|
tm:start()
|
||||||
|
end
|
||||||
|
-- Initial update
|
||||||
|
reg.update()
|
||||||
|
end
|
||||||
|
reg.running = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- }}}
|
-- }}}
|
||||||
@ -144,120 +144,120 @@ end
|
|||||||
-- {{{ Global functions
|
-- {{{ Global functions
|
||||||
-- {{{ Register a widget
|
-- {{{ Register a widget
|
||||||
function vicious.register(widget, wtype, format, timer, warg)
|
function vicious.register(widget, wtype, format, timer, warg)
|
||||||
local widget = widget
|
local widget = widget
|
||||||
local reg = {
|
local reg = {
|
||||||
-- Set properties
|
-- Set properties
|
||||||
wtype = wtype,
|
wtype = wtype,
|
||||||
format = format,
|
format = format,
|
||||||
timer = timer,
|
timer = timer,
|
||||||
warg = warg,
|
warg = warg,
|
||||||
widget = widget,
|
widget = widget,
|
||||||
}
|
}
|
||||||
-- Set functions
|
-- Set functions
|
||||||
reg.update = function ()
|
reg.update = function ()
|
||||||
update(widget, reg)
|
update(widget, reg)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Default to 2s timer
|
-- Default to 2s timer
|
||||||
if reg.timer == nil then
|
if reg.timer == nil then
|
||||||
reg.timer = 2
|
reg.timer = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Register a reg object
|
-- Register a reg object
|
||||||
regregister(reg)
|
regregister(reg)
|
||||||
|
|
||||||
-- Return a reg object for reuse
|
-- Return a reg object for reuse
|
||||||
return reg
|
return reg
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Unregister a widget
|
-- {{{ Unregister a widget
|
||||||
function vicious.unregister(widget, keep, reg)
|
function vicious.unregister(widget, keep, reg)
|
||||||
if reg == nil then
|
if reg == nil then
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
if w == widget then
|
if w == widget then
|
||||||
for _, v in pairs(i) do
|
for _, v in pairs(i) do
|
||||||
reg = vicious.unregister(w, keep, v)
|
reg = vicious.unregister(w, keep, v)
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return reg
|
|
||||||
end
|
|
||||||
|
|
||||||
if not keep then
|
|
||||||
for w, i in pairs(registered) do
|
|
||||||
if w == widget then
|
|
||||||
for k, v in pairs(i) do
|
|
||||||
if v == reg then
|
|
||||||
table.remove(registered[w], k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not reg.running then
|
|
||||||
return reg
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Disconnect from timer
|
|
||||||
local tm = timers[reg.timer]
|
|
||||||
if tm.timer.disconnect_signal then
|
|
||||||
tm.timer:disconnect_signal("timeout", reg.update)
|
|
||||||
else
|
|
||||||
tm.timer:remove_signal("timeout", reg.update)
|
|
||||||
end
|
|
||||||
reg.running = false
|
|
||||||
-- Stop the timer
|
|
||||||
tm.refs = tm.refs - 1
|
|
||||||
if tm.refs == 0 and tm.timer.started then
|
|
||||||
tm.timer:stop()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return reg
|
return reg
|
||||||
|
end
|
||||||
|
|
||||||
|
if not keep then
|
||||||
|
for w, i in pairs(registered) do
|
||||||
|
if w == widget then
|
||||||
|
for k, v in pairs(i) do
|
||||||
|
if v == reg then
|
||||||
|
table.remove(registered[w], k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not reg.running then
|
||||||
|
return reg
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Disconnect from timer
|
||||||
|
local tm = timers[reg.timer]
|
||||||
|
if tm.timer.disconnect_signal then
|
||||||
|
tm.timer:disconnect_signal("timeout", reg.update)
|
||||||
|
else
|
||||||
|
tm.timer:remove_signal("timeout", reg.update)
|
||||||
|
end
|
||||||
|
reg.running = false
|
||||||
|
-- Stop the timer
|
||||||
|
tm.refs = tm.refs - 1
|
||||||
|
if tm.refs == 0 and tm.timer.started then
|
||||||
|
tm.timer:stop()
|
||||||
|
end
|
||||||
|
|
||||||
|
return reg
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Enable caching of a widget type
|
-- {{{ Enable caching of a widget type
|
||||||
function vicious.cache(wtype)
|
function vicious.cache(wtype)
|
||||||
if wtype ~= nil then
|
if wtype ~= nil then
|
||||||
if widget_cache[wtype] == nil then
|
if widget_cache[wtype] == nil then
|
||||||
widget_cache[wtype] = {}
|
widget_cache[wtype] = {}
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Force update of widgets
|
-- {{{ Force update of widgets
|
||||||
function vicious.force(wtable)
|
function vicious.force(wtable)
|
||||||
if type(wtable) == "table" then
|
if type(wtable) == "table" then
|
||||||
for _, w in pairs(wtable) do
|
for _, w in pairs(wtable) do
|
||||||
update(w, nil, true)
|
update(w, nil, true)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Suspend all widgets
|
-- {{{ Suspend all widgets
|
||||||
function vicious.suspend()
|
function vicious.suspend()
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
for _, v in pairs(i) do
|
for _, v in pairs(i) do
|
||||||
vicious.unregister(w, true, v)
|
vicious.unregister(w, true, v)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Activate a widget
|
-- {{{ Activate a widget
|
||||||
function vicious.activate(widget)
|
function vicious.activate(widget)
|
||||||
for w, i in pairs(registered) do
|
for w, i in pairs(registered) do
|
||||||
if widget == nil or w == widget then
|
if widget == nil or w == widget then
|
||||||
for _, v in pairs(i) do
|
for _, v in pairs(i) do
|
||||||
regregister(v)
|
regregister(v)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ local setmetatable = setmetatable
|
|||||||
local string = { format = string.format }
|
local string = { format = string.format }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
local math = {
|
local math = {
|
||||||
min = math.min,
|
min = math.min,
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -23,71 +23,71 @@ local bat = {}
|
|||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local battery = helpers.pathtotable("/sys/class/power_supply/"..warg)
|
local battery = helpers.pathtotable("/sys/class/power_supply/"..warg)
|
||||||
local battery_state = {
|
local battery_state = {
|
||||||
["Full\n"] = "↯",
|
["Full\n"] = "↯",
|
||||||
["Unknown\n"] = "⌁",
|
["Unknown\n"] = "⌁",
|
||||||
["Charged\n"] = "↯",
|
["Charged\n"] = "↯",
|
||||||
["Charging\n"] = "+",
|
["Charging\n"] = "+",
|
||||||
["Discharging\n"] = "−"
|
["Discharging\n"] = "−"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Check if the battery is present
|
-- Check if the battery is present
|
||||||
if battery.present ~= "1\n" then
|
if battery.present ~= "1\n" then
|
||||||
return {battery_state["Unknown\n"], 0, "N/A", 0}
|
return {battery_state["Unknown\n"], 0, "N/A", 0}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Get state information
|
-- Get state information
|
||||||
local state = battery_state[battery.status] or battery_state["Unknown\n"]
|
local state = battery_state[battery.status] or battery_state["Unknown\n"]
|
||||||
|
|
||||||
-- Get capacity information
|
-- Get capacity information
|
||||||
if battery.charge_now then
|
if battery.charge_now then
|
||||||
remaining, capacity = battery.charge_now, battery.charge_full
|
remaining, capacity = battery.charge_now, battery.charge_full
|
||||||
capacity_design = battery.charge_full_design or capacity
|
capacity_design = battery.charge_full_design or capacity
|
||||||
elseif battery.energy_now then
|
elseif battery.energy_now then
|
||||||
remaining, capacity = battery.energy_now, battery.energy_full
|
remaining, capacity = battery.energy_now, battery.energy_full
|
||||||
capacity_design = battery.energy_full_design or capacity
|
capacity_design = battery.energy_full_design or capacity
|
||||||
|
else
|
||||||
|
return {battery_state["Unknown\n"], 0, "N/A", 0}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Calculate capacity and wear percentage (but work around broken BAT/ACPI implementations)
|
||||||
|
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||||
|
local wear = math.floor(100 - capacity / capacity_design * 100)
|
||||||
|
|
||||||
|
|
||||||
|
-- Get charge information
|
||||||
|
if battery.current_now then
|
||||||
|
rate = tonumber(battery.current_now)
|
||||||
|
elseif battery.power_now then
|
||||||
|
rate = tonumber(battery.power_now)
|
||||||
|
else
|
||||||
|
return {state, percent, "N/A", wear}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Calculate remaining (charging or discharging) time
|
||||||
|
local time = "N/A"
|
||||||
|
|
||||||
|
if rate ~= nil and rate ~= 0 then
|
||||||
|
if state == "+" then
|
||||||
|
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)
|
||||||
|
elseif state == "−" then
|
||||||
|
timeleft = tonumber(remaining) / tonumber(rate)
|
||||||
else
|
else
|
||||||
return {battery_state["Unknown\n"], 0, "N/A", 0}
|
return {state, percent, time, wear}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Calculate capacity and wear percentage (but work around broken BAT/ACPI implementations)
|
-- Calculate time
|
||||||
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
local hoursleft = math.floor(timeleft)
|
||||||
local wear = math.floor(100 - capacity / capacity_design * 100)
|
local minutesleft = math.floor((timeleft - hoursleft) * 60 )
|
||||||
|
|
||||||
|
time = string.format("%02d:%02d", hoursleft, minutesleft)
|
||||||
|
end
|
||||||
|
|
||||||
-- Get charge information
|
return {state, percent, time, wear}
|
||||||
if battery.current_now then
|
|
||||||
rate = tonumber(battery.current_now)
|
|
||||||
elseif battery.power_now then
|
|
||||||
rate = tonumber(battery.power_now)
|
|
||||||
else
|
|
||||||
return {state, percent, "N/A", wear}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Calculate remaining (charging or discharging) time
|
|
||||||
local time = "N/A"
|
|
||||||
|
|
||||||
if rate ~= nil and rate ~= 0 then
|
|
||||||
if state == "+" then
|
|
||||||
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)
|
|
||||||
elseif state == "−" then
|
|
||||||
timeleft = tonumber(remaining) / tonumber(rate)
|
|
||||||
else
|
|
||||||
return {state, percent, time, wear}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Calculate time
|
|
||||||
local hoursleft = math.floor(timeleft)
|
|
||||||
local minutesleft = math.floor((timeleft - hoursleft) * 60 )
|
|
||||||
|
|
||||||
time = string.format("%02d:%02d", hoursleft, minutesleft)
|
|
||||||
end
|
|
||||||
|
|
||||||
return {state, percent, time, wear}
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ local setmetatable = setmetatable
|
|||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
gmatch = string.gmatch
|
gmatch = string.gmatch
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -30,50 +30,50 @@ local cpu_active = {}
|
|||||||
|
|
||||||
-- {{{ CPU widget type
|
-- {{{ CPU widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local cpu_lines = {}
|
local cpu_lines = {}
|
||||||
|
|
||||||
-- Get CPU stats
|
-- Get CPU stats
|
||||||
local f = io.open("/proc/stat")
|
local f = io.open("/proc/stat")
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if string.sub(line, 1, 3) ~= "cpu" then break end
|
if string.sub(line, 1, 3) ~= "cpu" then break end
|
||||||
|
|
||||||
cpu_lines[#cpu_lines+1] = {}
|
cpu_lines[#cpu_lines+1] = {}
|
||||||
|
|
||||||
for i in string.gmatch(line, "[%s]+([^%s]+)") do
|
for i in string.gmatch(line, "[%s]+([^%s]+)") do
|
||||||
table.insert(cpu_lines[#cpu_lines], i)
|
table.insert(cpu_lines[#cpu_lines], i)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
-- Ensure tables are initialized correctly
|
-- Ensure tables are initialized correctly
|
||||||
for i = #cpu_total + 1, #cpu_lines do
|
for i = #cpu_total + 1, #cpu_lines do
|
||||||
cpu_total[i] = 0
|
cpu_total[i] = 0
|
||||||
cpu_usage[i] = 0
|
cpu_usage[i] = 0
|
||||||
cpu_active[i] = 0
|
cpu_active[i] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for i, v in ipairs(cpu_lines) do
|
||||||
|
-- Calculate totals
|
||||||
|
local total_new = 0
|
||||||
|
for j = 1, #v do
|
||||||
|
total_new = total_new + v[j]
|
||||||
end
|
end
|
||||||
|
local active_new = total_new - (v[4] + v[5])
|
||||||
|
|
||||||
|
-- Calculate percentage
|
||||||
|
local diff_total = total_new - cpu_total[i]
|
||||||
|
local diff_active = active_new - cpu_active[i]
|
||||||
|
|
||||||
for i, v in ipairs(cpu_lines) do
|
if diff_total == 0 then diff_total = 1E-6 end
|
||||||
-- Calculate totals
|
cpu_usage[i] = math.floor((diff_active / diff_total) * 100)
|
||||||
local total_new = 0
|
|
||||||
for j = 1, #v do
|
|
||||||
total_new = total_new + v[j]
|
|
||||||
end
|
|
||||||
local active_new = total_new - (v[4] + v[5])
|
|
||||||
|
|
||||||
-- Calculate percentage
|
-- Store totals
|
||||||
local diff_total = total_new - cpu_total[i]
|
cpu_total[i] = total_new
|
||||||
local diff_active = active_new - cpu_active[i]
|
cpu_active[i] = active_new
|
||||||
|
end
|
||||||
|
|
||||||
if diff_total == 0 then diff_total = 1E-6 end
|
return cpu_usage
|
||||||
cpu_usage[i] = math.floor((diff_active / diff_total) * 100)
|
|
||||||
|
|
||||||
-- Store totals
|
|
||||||
cpu_total[i] = total_new
|
|
||||||
cpu_active[i] = active_new
|
|
||||||
end
|
|
||||||
|
|
||||||
return cpu_usage
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -18,43 +18,43 @@ local cpufreq = {}
|
|||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
-- {{{ CPU frequency widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq")
|
local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq")
|
||||||
local governor_state = {
|
local governor_state = {
|
||||||
["ondemand\n"] = "↯",
|
["ondemand\n"] = "↯",
|
||||||
["powersave\n"] = "⌁",
|
["powersave\n"] = "⌁",
|
||||||
["userspace\n"] = "¤",
|
["userspace\n"] = "¤",
|
||||||
["performance\n"] = "⚡",
|
["performance\n"] = "⚡",
|
||||||
["conservative\n"] = "⊚"
|
["conservative\n"] = "⊚"
|
||||||
}
|
}
|
||||||
-- Default frequency and voltage values
|
-- Default frequency and voltage values
|
||||||
local freqv = {
|
local freqv = {
|
||||||
["mhz"] = "N/A", ["ghz"] = "N/A",
|
["mhz"] = "N/A", ["ghz"] = "N/A",
|
||||||
["v"] = "N/A", ["mv"] = "N/A",
|
["v"] = "N/A", ["mv"] = "N/A",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get the current frequency
|
-- Get the current frequency
|
||||||
local freq = tonumber(_cpufreq.scaling_cur_freq)
|
local freq = tonumber(_cpufreq.scaling_cur_freq)
|
||||||
-- Calculate MHz and GHz
|
-- Calculate MHz and GHz
|
||||||
if freq then
|
if freq then
|
||||||
freqv.mhz = freq / 1000
|
freqv.mhz = freq / 1000
|
||||||
freqv.ghz = freqv.mhz / 1000
|
freqv.ghz = freqv.mhz / 1000
|
||||||
|
|
||||||
-- Get the current voltage
|
-- Get the current voltage
|
||||||
if _cpufreq.scaling_voltages then
|
if _cpufreq.scaling_voltages then
|
||||||
freqv.mv = tonumber(string.match(_cpufreq.scaling_voltages, freq.."[%s]([%d]+)"))
|
freqv.mv = tonumber(string.match(_cpufreq.scaling_voltages, freq.."[%s]([%d]+)"))
|
||||||
-- Calculate voltage from mV
|
-- Calculate voltage from mV
|
||||||
freqv.v = freqv.mv / 1000
|
freqv.v = freqv.mv / 1000
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Get the current governor
|
-- Get the current governor
|
||||||
local governor = _cpufreq.scaling_governor
|
local governor = _cpufreq.scaling_governor
|
||||||
-- Represent the governor as a symbol
|
-- Represent the governor as a symbol
|
||||||
governor = governor_state[governor] or governor or "N/A"
|
governor = governor_state[governor] or governor or "N/A"
|
||||||
|
|
||||||
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -18,26 +18,26 @@ local cpuinf = {}
|
|||||||
|
|
||||||
-- {{{ CPU Information widget type
|
-- {{{ CPU Information widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local id = nil
|
local id = nil
|
||||||
|
|
||||||
local cpu_info = {} -- Get CPU info
|
local cpu_info = {} -- Get CPU info
|
||||||
for line in io.lines("/proc/cpuinfo") do
|
for line in io.lines("/proc/cpuinfo") do
|
||||||
for k, v in string.gmatch(line, "([%a%s]+)[%s]+:[%s]([%d]+).-$") do
|
for k, v in string.gmatch(line, "([%a%s]+)[%s]+:[%s]([%d]+).-$") do
|
||||||
if k == "processor" then
|
if k == "processor" then
|
||||||
id = v
|
id = v
|
||||||
elseif k == "cpu MHz\t" or k == "cpu MHz" then
|
elseif k == "cpu MHz\t" or k == "cpu MHz" then
|
||||||
local speed = tonumber(v)
|
local speed = tonumber(v)
|
||||||
cpu_info["{cpu"..id.." mhz}"] = speed
|
cpu_info["{cpu"..id.." mhz}"] = speed
|
||||||
cpu_info["{cpu"..id.." ghz}"] = speed / 1000
|
cpu_info["{cpu"..id.." ghz}"] = speed / 1000
|
||||||
elseif k == "cache size" then
|
elseif k == "cache size" then
|
||||||
local cache = tonumber(v)
|
local cache = tonumber(v)
|
||||||
cpu_info["{cpu"..id.." kb}"] = cache
|
cpu_info["{cpu"..id.." kb}"] = cache
|
||||||
cpu_info["{cpu"..id.." mb}"] = cache / 1024
|
cpu_info["{cpu"..id.." mb}"] = cache / 1024
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return cpu_info
|
return cpu_info
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local os = {
|
local os = {
|
||||||
date = os.date,
|
date = os.date,
|
||||||
time = os.time
|
time = os.time
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ local date = {}
|
|||||||
|
|
||||||
-- {{{ Date widget type
|
-- {{{ Date widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
return os.date(format or nil, warg and os.time()+warg or nil)
|
return os.date(format or nil, warg and os.time()+warg or nil)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ local setmetatable = setmetatable
|
|||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
local os = {
|
local os = {
|
||||||
time = os.time,
|
time = os.time,
|
||||||
difftime = os.difftime
|
difftime = os.difftime
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -30,43 +30,43 @@ local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
|
|||||||
|
|
||||||
-- {{{ Disk I/O widget type
|
-- {{{ Disk I/O widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local disk_lines = {}
|
local disk_lines = {}
|
||||||
|
|
||||||
for line in io.lines("/proc/diskstats") do
|
for line in io.lines("/proc/diskstats") do
|
||||||
local device, read, write =
|
local device, read, write =
|
||||||
-- Linux kernel documentation: Documentation/iostats.txt
|
-- Linux kernel documentation: Documentation/iostats.txt
|
||||||
string.match(line, "([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+)")
|
string.match(line, "([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+)")
|
||||||
disk_lines[device] = { read, write }
|
disk_lines[device] = { read, write }
|
||||||
|
end
|
||||||
|
|
||||||
|
local time = os.time()
|
||||||
|
local interval = os.difftime(time, disk_time)
|
||||||
|
if interval == 0 then interval = 1 end
|
||||||
|
|
||||||
|
for device, stats in pairs(disk_lines) do
|
||||||
|
-- Avoid insane values on startup
|
||||||
|
local last_stats = disk_stats[device] or stats
|
||||||
|
|
||||||
|
-- Check for overflows and counter resets (> 2^32)
|
||||||
|
if stats[1] < last_stats[1] or stats[2] < last_stats[2] then
|
||||||
|
last_stats[1], last_stats[2] = stats[1], stats[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
local time = os.time()
|
-- Diskstats are absolute, substract our last reading
|
||||||
local interval = os.difftime(time, disk_time)
|
-- * divide by timediff because we don't know the timer value
|
||||||
if interval == 0 then interval = 1 end
|
local read = (stats[1] - last_stats[1]) / interval
|
||||||
|
local write = (stats[2] - last_stats[2]) / interval
|
||||||
|
|
||||||
for device, stats in pairs(disk_lines) do
|
-- Calculate and store I/O
|
||||||
-- Avoid insane values on startup
|
helpers.uformat(disk_usage, device.." read", read, unit)
|
||||||
local last_stats = disk_stats[device] or stats
|
helpers.uformat(disk_usage, device.." write", write, unit)
|
||||||
|
helpers.uformat(disk_usage, device.." total", read + write, unit)
|
||||||
|
end
|
||||||
|
|
||||||
-- Check for overflows and counter resets (> 2^32)
|
disk_time = time
|
||||||
if stats[1] < last_stats[1] or stats[2] < last_stats[2] then
|
disk_stats = disk_lines
|
||||||
last_stats[1], last_stats[2] = stats[1], stats[2]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Diskstats are absolute, substract our last reading
|
return disk_usage
|
||||||
-- * divide by timediff because we don't know the timer value
|
|
||||||
local read = (stats[1] - last_stats[1]) / interval
|
|
||||||
local write = (stats[2] - last_stats[2]) / interval
|
|
||||||
|
|
||||||
-- Calculate and store I/O
|
|
||||||
helpers.uformat(disk_usage, device.." read", read, unit)
|
|
||||||
helpers.uformat(disk_usage, device.." write", write, unit)
|
|
||||||
helpers.uformat(disk_usage, device.." total", read + write, unit)
|
|
||||||
end
|
|
||||||
|
|
||||||
disk_time = time
|
|
||||||
disk_stats = disk_lines
|
|
||||||
|
|
||||||
return disk_usage
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -23,29 +23,29 @@ local unit = { ["mb"] = 1024, ["gb"] = 1024^2 }
|
|||||||
|
|
||||||
-- {{{ Filesystem widget type
|
-- {{{ Filesystem widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Fallback to listing local filesystems
|
-- Fallback to listing local filesystems
|
||||||
if warg then warg = "" else warg = "-l" end
|
if warg then warg = "" else warg = "-l" end
|
||||||
|
|
||||||
local fs_info = {} -- Get data from df
|
local fs_info = {} -- Get data from df
|
||||||
local f = io.popen("LC_ALL=C df -kP " .. helpers.shellquote(warg))
|
local f = io.popen("LC_ALL=C df -kP " .. helpers.shellquote(warg))
|
||||||
|
|
||||||
for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount)
|
for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount)
|
||||||
local s = string.match(line, "^.-[%s]([%d]+)")
|
local s = string.match(line, "^.-[%s]([%d]+)")
|
||||||
local u,a,p = string.match(line, "([%d]+)[%D]+([%d]+)[%D]+([%d]+)%%")
|
local u,a,p = string.match(line, "([%d]+)[%D]+([%d]+)[%D]+([%d]+)%%")
|
||||||
local m = string.match(line, "%%[%s]+([%p%w]+)")
|
local m = string.match(line, "%%[%s]+([%p%w]+)")
|
||||||
|
|
||||||
if u and m then -- Handle 1st line and broken regexp
|
if u and m then -- Handle 1st line and broken regexp
|
||||||
helpers.uformat(fs_info, m .. " size", s, unit)
|
helpers.uformat(fs_info, m .. " size", s, unit)
|
||||||
helpers.uformat(fs_info, m .. " used", u, unit)
|
helpers.uformat(fs_info, m .. " used", u, unit)
|
||||||
helpers.uformat(fs_info, m .. " avail", a, unit)
|
helpers.uformat(fs_info, m .. " avail", a, unit)
|
||||||
|
|
||||||
fs_info["{" .. m .. " used_p}"] = tonumber(p)
|
fs_info["{" .. m .. " used_p}"] = tonumber(p)
|
||||||
fs_info["{" .. m .. " avail_p}"] = 100 - tonumber(p)
|
fs_info["{" .. m .. " avail_p}"] = 100 - tonumber(p)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
return fs_info
|
return fs_info
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ local io = { popen = io.popen }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
local string = {
|
local string = {
|
||||||
match = string.match
|
match = string.match
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -30,47 +30,47 @@ local rss = {
|
|||||||
-- Default is just Inbox
|
-- Default is just Inbox
|
||||||
local feed = rss.inbox
|
local feed = rss.inbox
|
||||||
local mail = {
|
local mail = {
|
||||||
["{count}"] = 0,
|
["{count}"] = 0,
|
||||||
["{subject}"] = "N/A"
|
["{subject}"] = "N/A"
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Gmail widget type
|
-- {{{ Gmail widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Get info from the Gmail atom feed
|
-- Get info from the Gmail atom feed
|
||||||
local f = io.popen("curl --connect-timeout 1 -m 3 -fsn " .. feed)
|
local f = io.popen("curl --connect-timeout 1 -m 3 -fsn " .. feed)
|
||||||
|
|
||||||
-- Could be huge don't read it all at once, info we are after is at the top
|
-- Could be huge don't read it all at once, info we are after is at the top
|
||||||
local xml = f:read(2000)
|
local xml = f:read(2000)
|
||||||
|
|
||||||
if xml ~= nil then
|
|
||||||
return mail
|
|
||||||
end
|
|
||||||
|
|
||||||
mail["{count}"] = -- Count comes before messages and matches at least 0
|
|
||||||
tonumber(string.match(xml, "<fullcount>([%d]+)</fullcount>")) or mail["{count}"]
|
|
||||||
|
|
||||||
-- Find subject tag
|
|
||||||
local title = string.match(xml, "<entry>.-<title>(.-)</title>")
|
|
||||||
|
|
||||||
if title ~= nil then
|
|
||||||
-- Check if we should scroll, or maybe truncate
|
|
||||||
if warg then
|
|
||||||
if type(warg) == "table" then
|
|
||||||
title = helpers.scroll(title, warg[1], warg[2])
|
|
||||||
else
|
|
||||||
title = helpers.truncate(title, warg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Spam sanitize the subject and store
|
|
||||||
mail["{subject}"] = helpers.escape(title)
|
|
||||||
end
|
|
||||||
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
|
if xml ~= nil then
|
||||||
return mail
|
return mail
|
||||||
|
end
|
||||||
|
|
||||||
|
mail["{count}"] = -- Count comes before messages and matches at least 0
|
||||||
|
tonumber(string.match(xml, "<fullcount>([%d]+)</fullcount>")) or mail["{count}"]
|
||||||
|
|
||||||
|
-- Find subject tag
|
||||||
|
local title = string.match(xml, "<entry>.-<title>(.-)</title>")
|
||||||
|
|
||||||
|
if title ~= nil then
|
||||||
|
-- Check if we should scroll, or maybe truncate
|
||||||
|
if warg then
|
||||||
|
if type(warg) == "table" then
|
||||||
|
title = helpers.scroll(title, warg[1], warg[2])
|
||||||
|
else
|
||||||
|
title = helpers.truncate(title, warg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Spam sanitize the subject and store
|
||||||
|
mail["{subject}"] = helpers.escape(title)
|
||||||
|
end
|
||||||
|
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
return mail
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,21 +19,21 @@ local hddtemp = {}
|
|||||||
|
|
||||||
-- {{{ HDD Temperature widget type
|
-- {{{ HDD Temperature widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
-- Fallback to default hddtemp port
|
-- Fallback to default hddtemp port
|
||||||
if warg == nil then warg = 7634 end
|
if warg == nil then warg = 7634 end
|
||||||
|
|
||||||
local hdd_temp = {} -- Get info from the hddtemp daemon
|
local hdd_temp = {} -- Get info from the hddtemp daemon
|
||||||
local quoted = helpers.shellquote(warg)
|
local quoted = helpers.shellquote(warg)
|
||||||
local f = io.popen("echo | curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:"..quoted)
|
local f = io.popen("echo | curl --connect-timeout 1 -fsm 3 telnet://127.0.0.1:"..quoted)
|
||||||
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
for d, t in string.gmatch(line, "|([%/%a%d]+)|.-|([%d]+)|[CF]+|") do
|
for d, t in string.gmatch(line, "|([%/%a%d]+)|.-|([%d]+)|[CF]+|") do
|
||||||
hdd_temp["{"..d.."}"] = tonumber(t)
|
hdd_temp["{"..d.."}"] = tonumber(t)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
return hdd_temp
|
return hdd_temp
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -22,31 +22,31 @@ local subject = "N/A"
|
|||||||
|
|
||||||
-- {{{ Mailbox widget type
|
-- {{{ Mailbox widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- mbox could be huge, get a 30kb chunk from EOF
|
-- mbox could be huge, get a 30kb chunk from EOF
|
||||||
if type(warg) ~= "table" then _mbox = warg end
|
if type(warg) ~= "table" then _mbox = warg end
|
||||||
-- * attachment could be much bigger than 30kb
|
-- * attachment could be much bigger than 30kb
|
||||||
local f = io.open(_mbox or warg[1])
|
local f = io.open(_mbox or warg[1])
|
||||||
f:seek("end", -30720)
|
f:seek("end", -30720)
|
||||||
local txt = f:read("*all")
|
local txt = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Find all Subject lines
|
-- Find all Subject lines
|
||||||
for i in string.gfind(txt, "Subject: ([^\n]*)") do
|
for i in string.gfind(txt, "Subject: ([^\n]*)") do
|
||||||
subject = i
|
subject = i
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if we should scroll, or maybe truncate
|
||||||
|
if type(warg) == "table" then
|
||||||
|
if warg[3] ~= nil then
|
||||||
|
subject = helpers.scroll(subject, warg[2], warg[3])
|
||||||
|
else
|
||||||
|
subject = helpers.truncate(subject, warg[2])
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Check if we should scroll, or maybe truncate
|
return {helpers.escape(subject)}
|
||||||
if type(warg) == "table" then
|
|
||||||
if warg[3] ~= nil then
|
|
||||||
subject = helpers.scroll(subject, warg[2], warg[3])
|
|
||||||
else
|
|
||||||
subject = helpers.truncate(subject, warg[2])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return {helpers.escape(subject)}
|
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -17,41 +17,41 @@ local mboxc = {}
|
|||||||
|
|
||||||
-- {{{ Mbox count widget type
|
-- {{{ Mbox count widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Initialize counters
|
-- Initialize counters
|
||||||
local count = { old = 0, total = 0, new = 0 }
|
local count = { old = 0, total = 0, new = 0 }
|
||||||
|
|
||||||
-- Get data from mbox files
|
-- Get data from mbox files
|
||||||
for i=1, #warg do
|
for i=1, #warg do
|
||||||
local f = io.open(warg[i])
|
local f = io.open(warg[i])
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
-- Read the mbox line by line, if we are going to read
|
-- Read the mbox line by line, if we are going to read
|
||||||
-- some *HUGE* folders then switch to reading chunks
|
-- some *HUGE* folders then switch to reading chunks
|
||||||
local lines = f:read("*line")
|
local lines = f:read("*line")
|
||||||
if not lines then break end
|
if not lines then break end
|
||||||
|
|
||||||
-- Find all messages
|
-- Find all messages
|
||||||
-- * http://www.jwz.org/doc/content-length.html
|
-- * http://www.jwz.org/doc/content-length.html
|
||||||
local _, from = string.find(lines, "^From[%s]")
|
local _, from = string.find(lines, "^From[%s]")
|
||||||
if from ~= nil then count.total = count.total + 1 end
|
if from ~= nil then count.total = count.total + 1 end
|
||||||
|
|
||||||
-- Read messages have the Status header
|
-- Read messages have the Status header
|
||||||
local _, status = string.find(lines, "^Status:[%s]RO$")
|
local _, status = string.find(lines, "^Status:[%s]RO$")
|
||||||
if status ~= nil then count.old = count.old + 1 end
|
if status ~= nil then count.old = count.old + 1 end
|
||||||
|
|
||||||
-- Skip the folder internal data
|
-- Skip the folder internal data
|
||||||
local _, int = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA")
|
local _, int = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA")
|
||||||
if int ~= nil then count.total = count.total - 1 end
|
if int ~= nil then count.total = count.total - 1 end
|
||||||
end
|
|
||||||
f:close()
|
|
||||||
end
|
end
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
|
||||||
-- Substract total from old to get the new count
|
-- Substract total from old to get the new count
|
||||||
count.new = count.total - count.old
|
count.new = count.total - count.old
|
||||||
|
|
||||||
return {count.total, count.old, count.new}
|
return {count.total, count.old, count.new}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -18,25 +18,25 @@ local mdir = {}
|
|||||||
|
|
||||||
-- {{{ Maildir widget type
|
-- {{{ Maildir widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Initialize counters
|
-- Initialize counters
|
||||||
local count = { new = 0, cur = 0 }
|
local count = { new = 0, cur = 0 }
|
||||||
|
|
||||||
for i=1, #warg do
|
for i=1, #warg do
|
||||||
quoted_path = helpers.shellquote(warg[i])
|
quoted_path = helpers.shellquote(warg[i])
|
||||||
-- Recursively find new messages
|
-- Recursively find new messages
|
||||||
local f = io.popen("find "..quoted_path.." -type f -wholename '*/new/*'")
|
local f = io.popen("find "..quoted_path.." -type f -wholename '*/new/*'")
|
||||||
for line in f:lines() do count.new = count.new + 1 end
|
for line in f:lines() do count.new = count.new + 1 end
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Recursively find "old" messages lacking the Seen flag
|
-- Recursively find "old" messages lacking the Seen flag
|
||||||
local f = io.popen("find "..quoted_path.." -type f -regex '.*/cur/.*2,[^S]*$'")
|
local f = io.popen("find "..quoted_path.." -type f -regex '.*/cur/.*2,[^S]*$'")
|
||||||
for line in f:lines() do count.cur = count.cur + 1 end
|
for line in f:lines() do count.cur = count.cur + 1 end
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
return {count.new, count.cur}
|
return {count.new, count.cur}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,33 +19,33 @@ local mem = {}
|
|||||||
|
|
||||||
-- {{{ Memory widget type
|
-- {{{ Memory widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local _mem = { buf = {}, swp = {} }
|
local _mem = { buf = {}, swp = {} }
|
||||||
|
|
||||||
-- Get MEM info
|
-- Get MEM info
|
||||||
for line in io.lines("/proc/meminfo") do
|
for line in io.lines("/proc/meminfo") do
|
||||||
for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+") do
|
for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+") do
|
||||||
if k == "MemTotal" then _mem.total = math.floor(v/1024)
|
if k == "MemTotal" then _mem.total = math.floor(v/1024)
|
||||||
elseif k == "MemFree" then _mem.buf.f = math.floor(v/1024)
|
elseif k == "MemFree" then _mem.buf.f = math.floor(v/1024)
|
||||||
elseif k == "Buffers" then _mem.buf.b = math.floor(v/1024)
|
elseif k == "Buffers" then _mem.buf.b = math.floor(v/1024)
|
||||||
elseif k == "Cached" then _mem.buf.c = math.floor(v/1024)
|
elseif k == "Cached" then _mem.buf.c = math.floor(v/1024)
|
||||||
elseif k == "SwapTotal" then _mem.swp.t = math.floor(v/1024)
|
elseif k == "SwapTotal" then _mem.swp.t = math.floor(v/1024)
|
||||||
elseif k == "SwapFree" then _mem.swp.f = math.floor(v/1024)
|
elseif k == "SwapFree" then _mem.swp.f = math.floor(v/1024)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Calculate memory percentage
|
-- Calculate memory percentage
|
||||||
_mem.free = _mem.buf.f + _mem.buf.b + _mem.buf.c
|
_mem.free = _mem.buf.f + _mem.buf.b + _mem.buf.c
|
||||||
_mem.inuse = _mem.total - _mem.free
|
_mem.inuse = _mem.total - _mem.free
|
||||||
_mem.bcuse = _mem.total - _mem.buf.f
|
_mem.bcuse = _mem.total - _mem.buf.f
|
||||||
_mem.usep = math.floor(_mem.inuse / _mem.total * 100)
|
_mem.usep = math.floor(_mem.inuse / _mem.total * 100)
|
||||||
-- Calculate swap percentage
|
-- Calculate swap percentage
|
||||||
_mem.swp.inuse = _mem.swp.t - _mem.swp.f
|
_mem.swp.inuse = _mem.swp.t - _mem.swp.f
|
||||||
_mem.swp.usep = math.floor(_mem.swp.inuse / _mem.swp.t * 100)
|
_mem.swp.usep = math.floor(_mem.swp.inuse / _mem.swp.t * 100)
|
||||||
|
|
||||||
return {_mem.usep, _mem.inuse, _mem.total, _mem.free,
|
return {_mem.usep, _mem.inuse, _mem.total, _mem.free,
|
||||||
_mem.swp.usep, _mem.swp.inuse, _mem.swp.t, _mem.swp.f,
|
_mem.swp.usep, _mem.swp.inuse, _mem.swp.t, _mem.swp.f,
|
||||||
_mem.bcuse }
|
_mem.bcuse }
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,45 +19,45 @@ local mpd = {}
|
|||||||
|
|
||||||
-- {{{ MPD widget type
|
-- {{{ MPD widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
local mpd_state = {
|
local mpd_state = {
|
||||||
["{volume}"] = 0,
|
["{volume}"] = 0,
|
||||||
["{state}"] = "N/A",
|
["{state}"] = "N/A",
|
||||||
["{Artist}"] = "N/A",
|
["{Artist}"] = "N/A",
|
||||||
["{Title}"] = "N/A",
|
["{Title}"] = "N/A",
|
||||||
["{Album}"] = "N/A",
|
["{Album}"] = "N/A",
|
||||||
["{Genre}"] = "N/A",
|
["{Genre}"] = "N/A",
|
||||||
--["{Name}"] = "N/A",
|
--["{Name}"] = "N/A",
|
||||||
--["{file}"] = "N/A",
|
--["{file}"] = "N/A",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Fallback to MPD defaults
|
-- Fallback to MPD defaults
|
||||||
local pass = warg and (warg.password or warg[1]) or "\"\""
|
local pass = warg and (warg.password or warg[1]) or "\"\""
|
||||||
local host = warg and (warg.host or warg[2]) or "127.0.0.1"
|
local host = warg and (warg.host or warg[2]) or "127.0.0.1"
|
||||||
local port = warg and (warg.port or warg[3]) or "6600"
|
local port = warg and (warg.port or warg[3]) or "6600"
|
||||||
|
|
||||||
-- Construct MPD client options
|
-- Construct MPD client options
|
||||||
local mpdh = "telnet://"..host..":"..port
|
local mpdh = "telnet://"..host..":"..port
|
||||||
local echo = "echo 'password "..pass.."\nstatus\ncurrentsong\nclose'"
|
local echo = "echo 'password "..pass.."\nstatus\ncurrentsong\nclose'"
|
||||||
|
|
||||||
-- Get data from MPD server
|
-- Get data from MPD server
|
||||||
local f = io.popen(echo.." | curl --connect-timeout 1 -fsm 3 "..mpdh)
|
local f = io.popen(echo.." | curl --connect-timeout 1 -fsm 3 "..mpdh)
|
||||||
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do
|
for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do
|
||||||
if k == "volume" then mpd_state["{"..k.."}"] = v and tonumber(v)
|
if k == "volume" then mpd_state["{"..k.."}"] = v and tonumber(v)
|
||||||
elseif k == "state" then mpd_state["{"..k.."}"] = helpers.capitalize(v)
|
elseif k == "state" then mpd_state["{"..k.."}"] = helpers.capitalize(v)
|
||||||
elseif k == "Artist" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
elseif k == "Artist" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
||||||
elseif k == "Title" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
elseif k == "Title" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
||||||
elseif k == "Album" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
elseif k == "Album" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
||||||
elseif k == "Genre" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
elseif k == "Genre" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
||||||
--elseif k == "Name" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
--elseif k == "Name" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
||||||
--elseif k == "file" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
--elseif k == "file" then mpd_state["{"..k.."}"] = helpers.escape(v)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
return mpd_state
|
return mpd_state
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -23,57 +23,57 @@ local net = {}
|
|||||||
local nets = {}
|
local nets = {}
|
||||||
-- Variable definitions
|
-- Variable definitions
|
||||||
local unit = { ["b"] = 1, ["kb"] = 1024,
|
local unit = { ["b"] = 1, ["kb"] = 1024,
|
||||||
["mb"] = 1024^2, ["gb"] = 1024^3
|
["mb"] = 1024^2, ["gb"] = 1024^3
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ Net widget type
|
-- {{{ Net widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local args = {}
|
local args = {}
|
||||||
|
|
||||||
-- Get NET stats
|
-- Get NET stats
|
||||||
for line in io.lines("/proc/net/dev") do
|
for line in io.lines("/proc/net/dev") do
|
||||||
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
||||||
local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
|
local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
|
||||||
if name ~= nil then
|
if name ~= nil then
|
||||||
-- Received bytes, first value after the name
|
-- Received bytes, first value after the name
|
||||||
local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
|
local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
|
||||||
-- Transmited bytes, 7 fields from end of the line
|
-- Transmited bytes, 7 fields from end of the line
|
||||||
local send = tonumber(string.match(line,
|
local send = tonumber(string.match(line,
|
||||||
"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
|
"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
|
||||||
|
|
||||||
helpers.uformat(args, name .. " rx", recv, unit)
|
helpers.uformat(args, name .. " rx", recv, unit)
|
||||||
helpers.uformat(args, name .. " tx", send, unit)
|
helpers.uformat(args, name .. " tx", send, unit)
|
||||||
|
|
||||||
-- Operational state and carrier detection
|
-- Operational state and carrier detection
|
||||||
local sysnet = helpers.pathtotable("/sys/class/net/" .. name)
|
local sysnet = helpers.pathtotable("/sys/class/net/" .. name)
|
||||||
args["{"..name.." carrier}"] = tonumber(sysnet.carrier) or 0
|
args["{"..name.." carrier}"] = tonumber(sysnet.carrier) or 0
|
||||||
|
|
||||||
local now = os.time()
|
local now = os.time()
|
||||||
if nets[name] == nil then
|
if nets[name] == nil then
|
||||||
-- Default values on the first run
|
-- Default values on the first run
|
||||||
nets[name] = {}
|
nets[name] = {}
|
||||||
helpers.uformat(args, name .. " down", 0, unit)
|
helpers.uformat(args, name .. " down", 0, unit)
|
||||||
helpers.uformat(args, name .. " up", 0, unit)
|
helpers.uformat(args, name .. " up", 0, unit)
|
||||||
else -- Net stats are absolute, substract our last reading
|
else -- Net stats are absolute, substract our last reading
|
||||||
local interval = now - nets[name].time
|
local interval = now - nets[name].time
|
||||||
if interval <= 0 then interval = 1 end
|
if interval <= 0 then interval = 1 end
|
||||||
|
|
||||||
local down = (recv - nets[name][1]) / interval
|
local down = (recv - nets[name][1]) / interval
|
||||||
local up = (send - nets[name][2]) / interval
|
local up = (send - nets[name][2]) / interval
|
||||||
|
|
||||||
helpers.uformat(args, name .. " down", down, unit)
|
helpers.uformat(args, name .. " down", down, unit)
|
||||||
helpers.uformat(args, name .. " up", up, unit)
|
helpers.uformat(args, name .. " up", up, unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
nets[name].time = now
|
nets[name].time = now
|
||||||
|
|
||||||
-- Store totals
|
-- Store totals
|
||||||
nets[name][1] = recv
|
nets[name][1] = recv
|
||||||
nets[name][2] = send
|
nets[name][2] = send
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return args
|
return args
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ local io = { lines = io.lines }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local string = { find = string.find }
|
local string = { find = string.find }
|
||||||
local os = {
|
local os = {
|
||||||
time = os.time,
|
time = os.time,
|
||||||
date = os.date
|
date = os.date
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -22,40 +22,40 @@ local org = {}
|
|||||||
|
|
||||||
-- {{{ OrgMode widget type
|
-- {{{ OrgMode widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Compute delays
|
-- Compute delays
|
||||||
local today = os.time{ year=os.date("%Y"), month=os.date("%m"), day=os.date("%d") }
|
local today = os.time{ year=os.date("%Y"), month=os.date("%m"), day=os.date("%d") }
|
||||||
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
|
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
|
||||||
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
|
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
|
||||||
|
|
||||||
-- Initialize counters
|
-- Initialize counters
|
||||||
local count = { past = 0, today = 0, soon = 0, future = 0 }
|
local count = { past = 0, today = 0, soon = 0, future = 0 }
|
||||||
|
|
||||||
-- Get data from agenda files
|
-- Get data from agenda files
|
||||||
for i=1, #warg do
|
for i=1, #warg do
|
||||||
for line in io.lines(warg[i]) do
|
for line in io.lines(warg[i]) do
|
||||||
local scheduled = string.find(line, "SCHEDULED:")
|
local scheduled = string.find(line, "SCHEDULED:")
|
||||||
local closed = string.find(line, "CLOSED:")
|
local closed = string.find(line, "CLOSED:")
|
||||||
local deadline = string.find(line, "DEADLINE:")
|
local deadline = string.find(line, "DEADLINE:")
|
||||||
|
|
||||||
if (scheduled and not closed) or (deadline and not closed) then
|
if (scheduled and not closed) or (deadline and not closed) then
|
||||||
local b, e, y, m, d = string.find(line, "(%d%d%d%d)-(%d%d)-(%d%d)")
|
local b, e, y, m, d = string.find(line, "(%d%d%d%d)-(%d%d)-(%d%d)")
|
||||||
|
|
||||||
if b then
|
if b then
|
||||||
local t = os.time{ year = y, month = m, day = d }
|
local t = os.time{ year = y, month = m, day = d }
|
||||||
|
|
||||||
if t < today then count.past = count.past + 1
|
if t < today then count.past = count.past + 1
|
||||||
elseif t == today then count.today = count.today + 1
|
elseif t == today then count.today = count.today + 1
|
||||||
elseif t <= soon then count.soon = count.soon + 1
|
elseif t <= soon then count.soon = count.soon + 1
|
||||||
elseif t <= future then count.future = count.future + 1
|
elseif t <= future then count.future = count.future + 1
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {count.past, count.today, count.soon, count.future}
|
return {count.past, count.today, count.soon, count.future}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@ local los = { getenv = os.getenv }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
local string = {
|
local string = {
|
||||||
gsub = string.gsub,
|
gsub = string.gsub,
|
||||||
match = string.match
|
match = string.match
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -25,48 +25,48 @@ local os = {}
|
|||||||
|
|
||||||
-- {{{ Operating system widget type
|
-- {{{ Operating system widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local system = {
|
local system = {
|
||||||
["ostype"] = "N/A",
|
["ostype"] = "N/A",
|
||||||
["hostname"] = "N/A",
|
["hostname"] = "N/A",
|
||||||
["osrelease"] = "N/A",
|
["osrelease"] = "N/A",
|
||||||
["username"] = "N/A",
|
["username"] = "N/A",
|
||||||
["entropy"] = "N/A",
|
["entropy"] = "N/A",
|
||||||
["entropy_p"] = "N/A"
|
["entropy_p"] = "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Linux manual page: uname(2)
|
-- Linux manual page: uname(2)
|
||||||
local kernel = helpers.pathtotable("/proc/sys/kernel")
|
local kernel = helpers.pathtotable("/proc/sys/kernel")
|
||||||
for k, v in pairs(system) do
|
for k, v in pairs(system) do
|
||||||
if kernel[k] then
|
if kernel[k] then
|
||||||
system[k] = string.gsub(kernel[k], "[%s]*$", "")
|
system[k] = string.gsub(kernel[k], "[%s]*$", "")
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- BSD manual page: uname(1)
|
-- BSD manual page: uname(1)
|
||||||
if system["ostype"] == "N/A" then
|
if system["ostype"] == "N/A" then
|
||||||
local f = io.popen("uname -snr")
|
local f = io.popen("uname -snr")
|
||||||
local uname = f:read("*line")
|
local uname = f:read("*line")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
system["ostype"], system["hostname"], system["osrelease"] =
|
system["ostype"], system["hostname"], system["osrelease"] =
|
||||||
string.match(uname, "([%w]+)[%s]([%w%p]+)[%s]([%w%p]+)")
|
string.match(uname, "([%w]+)[%s]([%w%p]+)[%s]([%w%p]+)")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Linux manual page: random(4)
|
-- Linux manual page: random(4)
|
||||||
if kernel.random then
|
if kernel.random then
|
||||||
-- Linux 2.6 default entropy pool is 4096-bits
|
-- Linux 2.6 default entropy pool is 4096-bits
|
||||||
local poolsize = tonumber(kernel.random.poolsize)
|
local poolsize = tonumber(kernel.random.poolsize)
|
||||||
|
|
||||||
-- Get available entropy and calculate percentage
|
-- Get available entropy and calculate percentage
|
||||||
system["entropy"] = tonumber(kernel.random.entropy_avail)
|
system["entropy"] = tonumber(kernel.random.entropy_avail)
|
||||||
system["entropy_p"] = math.ceil(system["entropy"] * 100 / poolsize)
|
system["entropy_p"] = math.ceil(system["entropy"] * 100 / poolsize)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get user from the environment
|
-- Get user from the environment
|
||||||
system["username"] = los.getenv("USER")
|
system["username"] = los.getenv("USER")
|
||||||
|
|
||||||
return {system["ostype"], system["osrelease"], system["username"],
|
return {system["ostype"], system["osrelease"], system["username"],
|
||||||
system["hostname"], system["entropy"], system["entropy_p"]}
|
system["hostname"], system["entropy"], system["entropy_p"]}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -17,31 +17,31 @@ local pkg = {}
|
|||||||
|
|
||||||
-- {{{ Packages widget type
|
-- {{{ Packages widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Initialize counters
|
-- Initialize counters
|
||||||
local updates = 0
|
local updates = 0
|
||||||
local manager = {
|
local manager = {
|
||||||
["Arch"] = { cmd = "pacman -Qu" },
|
["Arch"] = { cmd = "pacman -Qu" },
|
||||||
["Arch C"] = { cmd = "checkupdates" },
|
["Arch C"] = { cmd = "checkupdates" },
|
||||||
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 1 },
|
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 1 },
|
||||||
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
||||||
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
||||||
["Fedora"] = { cmd = "yum list updates", sub = 3 },
|
["Fedora"] = { cmd = "yum list updates", sub = 3 },
|
||||||
["FreeBSD"] ={ cmd = "pkg_version -I -l '<'" },
|
["FreeBSD"] ={ cmd = "pkg_version -I -l '<'" },
|
||||||
["Mandriva"]={ cmd = "urpmq --auto-select" }
|
["Mandriva"]={ cmd = "urpmq --auto-select" }
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Check if updates are available
|
-- Check if updates are available
|
||||||
local _pkg = manager[warg]
|
local _pkg = manager[warg]
|
||||||
local f = io.popen(_pkg.cmd)
|
local f = io.popen(_pkg.cmd)
|
||||||
|
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
updates = updates + 1
|
updates = updates + 1
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
return {_pkg.sub and math.max(updates-_pkg.sub, 0) or updates}
|
return {_pkg.sub and math.max(updates-_pkg.sub, 0) or updates}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local string = {
|
local string = {
|
||||||
len = string.len,
|
len = string.len,
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
gmatch = string.gmatch
|
gmatch = string.gmatch
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -25,35 +25,35 @@ local mddev = {}
|
|||||||
|
|
||||||
-- {{{ RAID widget type
|
-- {{{ RAID widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
mddev[warg] = {
|
mddev[warg] = {
|
||||||
["found"] = false,
|
["found"] = false,
|
||||||
["active"] = 0,
|
["active"] = 0,
|
||||||
["assigned"] = 0
|
["assigned"] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Linux manual page: md(4)
|
-- Linux manual page: md(4)
|
||||||
local f = io.open("/proc/mdstat")
|
local f = io.open("/proc/mdstat")
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
if mddev[warg]["found"] then
|
if mddev[warg]["found"] then
|
||||||
local updev = string.match(line, "%[[_U]+%]")
|
local updev = string.match(line, "%[[_U]+%]")
|
||||||
|
|
||||||
for i in string.gmatch(updev, "U") do
|
for i in string.gmatch(updev, "U") do
|
||||||
mddev[warg]["active"] = mddev[warg]["active"] + 1
|
mddev[warg]["active"] = mddev[warg]["active"] + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
elseif string.sub(line, 1, string.len(warg)) == warg then
|
elseif string.sub(line, 1, string.len(warg)) == warg then
|
||||||
mddev[warg]["found"] = true
|
mddev[warg]["found"] = true
|
||||||
|
|
||||||
for i in string.gmatch(line, "%[[%d]%]") do
|
for i in string.gmatch(line, "%[[%d]%]") do
|
||||||
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
|
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
f:close()
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
return {mddev[warg]["assigned"], mddev[warg]["active"]}
|
return {mddev[warg]["assigned"], mddev[warg]["active"]}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,28 +19,28 @@ local thermal = {}
|
|||||||
|
|
||||||
-- {{{ Thermal widget type
|
-- {{{ Thermal widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local zone = { -- Known temperature data sources
|
local zone = { -- Known temperature data sources
|
||||||
["sys"] = {"/sys/class/thermal/", file = "temp", div = 1000},
|
["sys"] = {"/sys/class/thermal/", file = "temp", div = 1000},
|
||||||
["core"] = {"/sys/devices/platform/", file = "temp2_input",div = 1000},
|
["core"] = {"/sys/devices/platform/", file = "temp2_input",div = 1000},
|
||||||
["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"}
|
["proc"] = {"/proc/acpi/thermal_zone/",file = "temperature"}
|
||||||
} -- Default to /sys/class/thermal
|
} -- Default to /sys/class/thermal
|
||||||
warg = type(warg) == "table" and warg or { warg, "sys" }
|
warg = type(warg) == "table" and warg or { warg, "sys" }
|
||||||
|
|
||||||
-- Get temperature from thermal zone
|
-- Get temperature from thermal zone
|
||||||
local _thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1])
|
local _thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1])
|
||||||
|
|
||||||
local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file]
|
local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file]
|
||||||
if data then
|
if data then
|
||||||
if zone[warg[2]].div then
|
if zone[warg[2]].div then
|
||||||
return {data / zone[warg[2]].div}
|
return {data / zone[warg[2]].div}
|
||||||
else -- /proc/acpi "temperature: N C"
|
else -- /proc/acpi "temperature: N C"
|
||||||
return {tonumber(string.match(data, "[%d]+"))}
|
return {tonumber(string.match(data, "[%d]+"))}
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {0}
|
return {0}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,17 +19,17 @@ local uptime = {}
|
|||||||
|
|
||||||
-- {{{ Uptime widget type
|
-- {{{ Uptime widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local proc = helpers.pathtotable("/proc")
|
local proc = helpers.pathtotable("/proc")
|
||||||
|
|
||||||
-- Get system uptime
|
-- Get system uptime
|
||||||
local up_t = math.floor(string.match(proc.uptime, "[%d]+"))
|
local up_t = math.floor(string.match(proc.uptime, "[%d]+"))
|
||||||
local up_d = math.floor(up_t / (3600 * 24))
|
local up_d = math.floor(up_t / (3600 * 24))
|
||||||
local up_h = math.floor((up_t % (3600 * 24)) / 3600)
|
local up_h = math.floor((up_t % (3600 * 24)) / 3600)
|
||||||
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
|
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
|
||||||
|
|
||||||
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
|
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
|
||||||
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
|
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
|
||||||
return {up_d, up_h, up_m, l1, l5, l15}
|
return {up_d, up_h, up_m, l1, l5, l15}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -19,35 +19,35 @@ local volume = {}
|
|||||||
|
|
||||||
-- {{{ Volume widget type
|
-- {{{ Volume widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local mixer_state = {
|
local mixer_state = {
|
||||||
["on"] = "♫", -- "",
|
["on"] = "♫", -- "",
|
||||||
["off"] = "♩" -- "M"
|
["off"] = "♩" -- "M"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Get mixer control contents
|
-- Get mixer control contents
|
||||||
local f = io.popen("amixer -M get " .. helpers.shellquote(warg))
|
local f = io.popen("amixer -M get " .. helpers.shellquote(warg))
|
||||||
local mixer = f:read("*all")
|
local mixer = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Capture mixer control state: [5%] ... ... [on]
|
-- Capture mixer control state: [5%] ... ... [on]
|
||||||
local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
|
local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
|
||||||
-- Handle mixers without data
|
-- Handle mixers without data
|
||||||
if volu == nil then
|
if volu == nil then
|
||||||
return {0, mixer_state["off"]}
|
return {0, mixer_state["off"]}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle mixers without mute
|
-- Handle mixers without mute
|
||||||
if mute == "" and volu == "0"
|
if mute == "" and volu == "0"
|
||||||
-- Handle mixers that are muted
|
-- Handle mixers that are muted
|
||||||
or mute == "off" then
|
or mute == "off" then
|
||||||
mute = mixer_state["off"]
|
mute = mixer_state["off"]
|
||||||
else
|
else
|
||||||
mute = mixer_state["on"]
|
mute = mixer_state["on"]
|
||||||
end
|
end
|
||||||
|
|
||||||
return {tonumber(volu), mute}
|
return {tonumber(volu), mute}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -20,74 +20,74 @@ local weather = {}
|
|||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
local _weather = {
|
local _weather = {
|
||||||
["{city}"] = "N/A",
|
["{city}"] = "N/A",
|
||||||
["{wind}"] = "N/A",
|
["{wind}"] = "N/A",
|
||||||
["{windmph}"] = "N/A",
|
["{windmph}"] = "N/A",
|
||||||
["{windkmh}"] = "N/A",
|
["{windkmh}"] = "N/A",
|
||||||
["{sky}"] = "N/A",
|
["{sky}"] = "N/A",
|
||||||
["{weather}"] = "N/A",
|
["{weather}"] = "N/A",
|
||||||
["{tempf}"] = "N/A",
|
["{tempf}"] = "N/A",
|
||||||
["{tempc}"] = "N/A",
|
["{tempc}"] = "N/A",
|
||||||
["{dewf}"] = "N/A",
|
["{dewf}"] = "N/A",
|
||||||
["{dewc}"] = "N/A",
|
["{dewc}"] = "N/A",
|
||||||
["{humid}"] = "N/A",
|
["{humid}"] = "N/A",
|
||||||
["{press}"] = "N/A"
|
["{press}"] = "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ Weather widget type
|
-- {{{ Weather widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Get weather forceast by the station ICAO code, from:
|
-- Get weather forceast by the station ICAO code, from:
|
||||||
-- * US National Oceanic and Atmospheric Administration
|
-- * US National Oceanic and Atmospheric Administration
|
||||||
local url = "http://weather.noaa.gov/pub/data/observations/metar/decoded/"..warg
|
local url = "http://weather.noaa.gov/pub/data/observations/metar/decoded/"..warg
|
||||||
local f = io.popen("curl --connect-timeout 1 -fsm 3 "..helpers.shellquote(url)..".TXT")
|
local f = io.popen("curl --connect-timeout 1 -fsm 3 "..helpers.shellquote(url)..".TXT")
|
||||||
local ws = f:read("*all")
|
local ws = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Check if there was a timeout or a problem with the station
|
-- Check if there was a timeout or a problem with the station
|
||||||
if ws == nil then return _weather end
|
if ws == nil then return _weather end
|
||||||
|
|
||||||
_weather["{city}"] = -- City and/or area
|
_weather["{city}"] = -- City and/or area
|
||||||
string.match(ws, "^(.+)%,.*%([%u]+%)") or _weather["{city}"]
|
string.match(ws, "^(.+)%,.*%([%u]+%)") or _weather["{city}"]
|
||||||
_weather["{wind}"] = -- Wind direction and degrees if available
|
_weather["{wind}"] = -- Wind direction and degrees if available
|
||||||
string.match(ws, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or _weather["{wind}"]
|
string.match(ws, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or _weather["{wind}"]
|
||||||
_weather["{windmph}"] = -- Wind speed in MPH if available
|
_weather["{windmph}"] = -- Wind speed in MPH if available
|
||||||
string.match(ws, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or _weather["{windmph}"]
|
string.match(ws, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or _weather["{windmph}"]
|
||||||
_weather["{sky}"] = -- Sky conditions if available
|
_weather["{sky}"] = -- Sky conditions if available
|
||||||
string.match(ws, "Sky[%s]conditions:[%s](.-)[%c]") or _weather["{sky}"]
|
string.match(ws, "Sky[%s]conditions:[%s](.-)[%c]") or _weather["{sky}"]
|
||||||
_weather["{weather}"] = -- Weather conditions if available
|
_weather["{weather}"] = -- Weather conditions if available
|
||||||
string.match(ws, "Weather:[%s](.-)[%c]") or _weather["{weather}"]
|
string.match(ws, "Weather:[%s](.-)[%c]") or _weather["{weather}"]
|
||||||
_weather["{tempf}"] = -- Temperature in fahrenheit
|
_weather["{tempf}"] = -- Temperature in fahrenheit
|
||||||
string.match(ws, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"]
|
string.match(ws, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"]
|
||||||
_weather["{dewf}"] = -- Dew Point in fahrenheit
|
_weather["{dewf}"] = -- Dew Point in fahrenheit
|
||||||
string.match(ws, "Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{dewf}"]
|
string.match(ws, "Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{dewf}"]
|
||||||
_weather["{humid}"] = -- Relative humidity in percent
|
_weather["{humid}"] = -- Relative humidity in percent
|
||||||
string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"]
|
string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"]
|
||||||
_weather["{press}"] = -- Pressure in hPa
|
_weather["{press}"] = -- Pressure in hPa
|
||||||
string.match(ws, "Pressure[%s].+%((.+)[%s]hPa%)") or _weather["{press}"]
|
string.match(ws, "Pressure[%s].+%((.+)[%s]hPa%)") or _weather["{press}"]
|
||||||
|
|
||||||
-- Wind speed in km/h if MPH was available
|
-- Wind speed in km/h if MPH was available
|
||||||
if _weather["{windmph}"] ~= "N/A" then
|
if _weather["{windmph}"] ~= "N/A" then
|
||||||
_weather["{windmph}"] = tonumber(_weather["{windmph}"])
|
_weather["{windmph}"] = tonumber(_weather["{windmph}"])
|
||||||
_weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6)
|
_weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6)
|
||||||
end -- Temperature in °C if °F was available
|
end -- Temperature in °C if °F was available
|
||||||
if _weather["{tempf}"] ~= "N/A" then
|
if _weather["{tempf}"] ~= "N/A" then
|
||||||
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
|
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
|
||||||
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
|
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
|
||||||
end -- Dew Point in °C if °F was available
|
end -- Dew Point in °C if °F was available
|
||||||
if _weather["{dewf}"] ~= "N/A" then
|
if _weather["{dewf}"] ~= "N/A" then
|
||||||
_weather["{dewf}"] = tonumber(_weather["{dewf}"])
|
_weather["{dewf}"] = tonumber(_weather["{dewf}"])
|
||||||
_weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
|
_weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
|
||||||
end -- Capitalize some stats so they don't look so out of place
|
end -- Capitalize some stats so they don't look so out of place
|
||||||
if _weather["{sky}"] ~= "N/A" then
|
if _weather["{sky}"] ~= "N/A" then
|
||||||
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])
|
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])
|
||||||
end
|
end
|
||||||
if _weather["{weather}"] ~= "N/A" then
|
if _weather["{weather}"] ~= "N/A" then
|
||||||
_weather["{weather}"] = helpers.capitalize(_weather["{weather}"])
|
_weather["{weather}"] = helpers.capitalize(_weather["{weather}"])
|
||||||
end
|
end
|
||||||
|
|
||||||
return _weather
|
return _weather
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ local math = { ceil = math.ceil }
|
|||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
local io = {
|
local io = {
|
||||||
open = io.open,
|
open = io.open,
|
||||||
popen = io.popen
|
popen = io.popen
|
||||||
}
|
}
|
||||||
local string = {
|
local string = {
|
||||||
find = string.find,
|
find = string.find,
|
||||||
match = string.match
|
match = string.match
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
@ -32,60 +32,60 @@ local iwcpaths = { "/sbin", "/usr/sbin", "/usr/local/sbin", "/usr/bin" }
|
|||||||
|
|
||||||
-- {{{ Wireless widget type
|
-- {{{ Wireless widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Default values
|
-- Default values
|
||||||
local winfo = {
|
local winfo = {
|
||||||
["{ssid}"] = "N/A",
|
["{ssid}"] = "N/A",
|
||||||
["{mode}"] = "N/A",
|
["{mode}"] = "N/A",
|
||||||
["{chan}"] = 0,
|
["{chan}"] = 0,
|
||||||
["{rate}"] = 0,
|
["{rate}"] = 0,
|
||||||
["{link}"] = 0,
|
["{link}"] = 0,
|
||||||
["{linp}"] = 0,
|
["{linp}"] = 0,
|
||||||
["{sign}"] = 0
|
["{sign}"] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Sbin paths aren't in user PATH, search for the binary
|
-- Sbin paths aren't in user PATH, search for the binary
|
||||||
if iwconfig == "iwconfig" then
|
if iwconfig == "iwconfig" then
|
||||||
for _, p in ipairs(iwcpaths) do
|
for _, p in ipairs(iwcpaths) do
|
||||||
local f = io.open(p .. "/iwconfig", "rb")
|
local f = io.open(p .. "/iwconfig", "rb")
|
||||||
if f then
|
if f then
|
||||||
iwconfig = p .. "/iwconfig"
|
iwconfig = p .. "/iwconfig"
|
||||||
f:close()
|
f:close()
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Get data from iwconfig where available
|
-- Get data from iwconfig where available
|
||||||
local f = io.popen(iwconfig .." ".. helpers.shellquote(warg) .. " 2>&1")
|
local f = io.popen(iwconfig .." ".. helpers.shellquote(warg) .. " 2>&1")
|
||||||
local iw = f:read("*all")
|
local iw = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- iwconfig wasn't found, isn't executable, or non-wireless interface
|
|
||||||
if iw == nil or string.find(iw, "No such device") then
|
|
||||||
return winfo
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Output differs from system to system, some stats can be
|
|
||||||
-- separated by =, and not all drivers report all stats
|
|
||||||
winfo["{ssid}"] = -- SSID can have almost anything in it
|
|
||||||
helpers.escape(string.match(iw, 'ESSID[=:]"(.-)"') or winfo["{ssid}"])
|
|
||||||
winfo["{mode}"] = -- Modes are simple, but also match the "-" in Ad-Hoc
|
|
||||||
string.match(iw, "Mode[=:]([%w%-]*)") or winfo["{mode}"]
|
|
||||||
winfo["{chan}"] = -- Channels are plain digits
|
|
||||||
tonumber(string.match(iw, "Channel[=:]([%d]+)") or winfo["{chan}"])
|
|
||||||
winfo["{rate}"] = -- Bitrate can start with a space, we don't want to display Mb/s
|
|
||||||
tonumber(string.match(iw, "Bit Rate[=:]([%s]?[%d%.]*)") or winfo["{rate}"])
|
|
||||||
winfo["{link}"] = -- Link quality can contain a slash (32/70), match only the first number
|
|
||||||
tonumber(string.match(iw, "Link Quality[=:]([%d]+)") or winfo["{link}"])
|
|
||||||
winfo["{sign}"] = -- Signal level can be a negative value, don't display decibel notation
|
|
||||||
tonumber(string.match(iw, "Signal level[=:]([%-]?[%d]+)") or winfo["{sign}"])
|
|
||||||
|
|
||||||
-- Link quality percentage if quality was available
|
|
||||||
if winfo["{link}"] ~= 0 then winfo["{linp}"] = math.ceil(winfo["{link}"] / 0.7) end
|
|
||||||
|
|
||||||
|
-- iwconfig wasn't found, isn't executable, or non-wireless interface
|
||||||
|
if iw == nil or string.find(iw, "No such device") then
|
||||||
return winfo
|
return winfo
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Output differs from system to system, some stats can be
|
||||||
|
-- separated by =, and not all drivers report all stats
|
||||||
|
winfo["{ssid}"] = -- SSID can have almost anything in it
|
||||||
|
helpers.escape(string.match(iw, 'ESSID[=:]"(.-)"') or winfo["{ssid}"])
|
||||||
|
winfo["{mode}"] = -- Modes are simple, but also match the "-" in Ad-Hoc
|
||||||
|
string.match(iw, "Mode[=:]([%w%-]*)") or winfo["{mode}"]
|
||||||
|
winfo["{chan}"] = -- Channels are plain digits
|
||||||
|
tonumber(string.match(iw, "Channel[=:]([%d]+)") or winfo["{chan}"])
|
||||||
|
winfo["{rate}"] = -- Bitrate can start with a space, we don't want to display Mb/s
|
||||||
|
tonumber(string.match(iw, "Bit Rate[=:]([%s]?[%d%.]*)") or winfo["{rate}"])
|
||||||
|
winfo["{link}"] = -- Link quality can contain a slash (32/70), match only the first number
|
||||||
|
tonumber(string.match(iw, "Link Quality[=:]([%d]+)") or winfo["{link}"])
|
||||||
|
winfo["{sign}"] = -- Signal level can be a negative value, don't display decibel notation
|
||||||
|
tonumber(string.match(iw, "Signal level[=:]([%-]?[%d]+)") or winfo["{sign}"])
|
||||||
|
|
||||||
|
-- Link quality percentage if quality was available
|
||||||
|
if winfo["{link}"] ~= 0 then winfo["{linp}"] = math.ceil(winfo["{link}"] / 0.7) end
|
||||||
|
|
||||||
|
return winfo
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
@ -22,32 +22,32 @@ baticon:set_image(beautiful.widget_batfull)
|
|||||||
-- Charge %
|
-- Charge %
|
||||||
batpct = wibox.widget.textbox()
|
batpct = wibox.widget.textbox()
|
||||||
vicious.register(batpct, vicious.widgets.bat, function(widget, args)
|
vicious.register(batpct, vicious.widgets.bat, function(widget, args)
|
||||||
bat_state = args[1]
|
bat_state = args[1]
|
||||||
bat_charge = args[2]
|
bat_charge = args[2]
|
||||||
bat_time = args[3]
|
bat_time = args[3]
|
||||||
|
|
||||||
if args[1] == "-" then
|
if args[1] == "-" then
|
||||||
if bat_charge > 70 then
|
if bat_charge > 70 then
|
||||||
baticon:set_image(beautiful.widget_batfull)
|
baticon:set_image(beautiful.widget_batfull)
|
||||||
elseif bat_charge > 30 then
|
elseif bat_charge > 30 then
|
||||||
baticon:set_image(beautiful.widget_batmed)
|
baticon:set_image(beautiful.widget_batmed)
|
||||||
elseif bat_charge > 10 then
|
elseif bat_charge > 10 then
|
||||||
baticon:set_image(beautiful.widget_batlow)
|
baticon:set_image(beautiful.widget_batlow)
|
||||||
else
|
else
|
||||||
baticon:set_image(beautiful.widget_batempty)
|
baticon:set_image(beautiful.widget_batempty)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
baticon:set_image(beautiful.widget_ac)
|
baticon:set_image(beautiful.widget_ac)
|
||||||
if args[1] == "+" then
|
if args[1] == "+" then
|
||||||
blink = not blink
|
blink = not blink
|
||||||
if blink then
|
if blink then
|
||||||
baticon:set_image(beautiful.widget_acblink)
|
baticon:set_image(beautiful.widget_acblink)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return args[2] .. "%"
|
return args[2] .. "%"
|
||||||
end, nil, "BAT1")
|
end, nil, "BAT1")
|
||||||
|
|
||||||
-- Buttons
|
-- Buttons
|
||||||
function popup_bat()
|
function popup_bat()
|
||||||
@ -67,7 +67,7 @@ function popup_bat()
|
|||||||
end
|
end
|
||||||
|
|
||||||
naughty.notify { text = "Charge : " .. bat_charge .. "%\nState : " .. state ..
|
naughty.notify { text = "Charge : " .. bat_charge .. "%\nState : " .. state ..
|
||||||
" (" .. bat_time .. ")", timeout = 5, hover_timeout = 0.5 }
|
" (" .. bat_time .. ")", timeout = 5, hover_timeout = 0.5 }
|
||||||
end
|
end
|
||||||
batpct:buttons(awful.util.table.join(awful.button({ }, 1, popup_bat)))
|
batpct:buttons(awful.util.table.join(awful.button({ }, 1, popup_bat)))
|
||||||
baticon:buttons(batpct:buttons())
|
baticon:buttons(batpct:buttons())
|
||||||
@ -81,30 +81,30 @@ pacicon:set_image(beautiful.widget_pac)
|
|||||||
-- Upgrades
|
-- Upgrades
|
||||||
pacwidget = wibox.widget.textbox()
|
pacwidget = wibox.widget.textbox()
|
||||||
vicious.register(pacwidget, vicious.widgets.pkg, function(widget, args)
|
vicious.register(pacwidget, vicious.widgets.pkg, function(widget, args)
|
||||||
if args[1] > 0 then
|
if args[1] > 0 then
|
||||||
pacicon:set_image(beautiful.widget_pacnew)
|
pacicon:set_image(beautiful.widget_pacnew)
|
||||||
else
|
else
|
||||||
pacicon:set_image(beautiful.widget_pac)
|
pacicon:set_image(beautiful.widget_pac)
|
||||||
end
|
end
|
||||||
|
|
||||||
return args[1]
|
return args[1]
|
||||||
end, 1801, "Arch S") -- Arch S for ignorepkg
|
end, 1801, "Arch S") -- Arch S for ignorepkg
|
||||||
--
|
--
|
||||||
-- Buttons
|
-- Buttons
|
||||||
function popup_pac()
|
function popup_pac()
|
||||||
local pac_updates = ""
|
local pac_updates = ""
|
||||||
local f = io.popen("pacman -Sup --dbpath /tmp/pacsync")
|
local f = io.popen("pacman -Sup --dbpath /tmp/pacsync")
|
||||||
if f then
|
if f then
|
||||||
pac_updates = f:read("*a"):match(".*/(.*)-.*\n$")
|
pac_updates = f:read("*a"):match(".*/(.*)-.*\n$")
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
if not pac_updates then
|
if not pac_updates then
|
||||||
pac_updates = "System is up to date"
|
pac_updates = "System is up to date"
|
||||||
end
|
end
|
||||||
naughty.notify { text = pac_updates }
|
naughty.notify { text = pac_updates }
|
||||||
end
|
end
|
||||||
pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac)))
|
pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac)))
|
||||||
pacicon:buttons(pacwidget:buttons())
|
pacicon:buttons(pacwidget:buttons())
|
||||||
-- End Pacman }}}
|
-- End Pacman }}}
|
||||||
--
|
--
|
||||||
-- {{{ VOLUME
|
-- {{{ VOLUME
|
||||||
@ -121,17 +121,17 @@ vicious.register(volpct, vicious.widgets.volume, "$1%", nil, "Master")
|
|||||||
--
|
--
|
||||||
-- Buttons
|
-- Buttons
|
||||||
volicon:buttons(awful.util.table.join(
|
volicon:buttons(awful.util.table.join(
|
||||||
awful.button({ }, 1,
|
awful.button({ }, 1,
|
||||||
function() awful.util.spawn_with_shell("amixer -q set Master toggle") end),
|
function() awful.util.spawn_with_shell("amixer -q set Master toggle") end),
|
||||||
awful.button({ }, 4,
|
awful.button({ }, 4,
|
||||||
function() awful.util.spawn_with_shell("amixer -q set Master 3+% unmute") end),
|
function() awful.util.spawn_with_shell("amixer -q set Master 3+% unmute") end),
|
||||||
awful.button({ }, 5,
|
awful.button({ }, 5,
|
||||||
function() awful.util.spawn_with_shell("amixer -q set Master 3-% unmute") end)
|
function() awful.util.spawn_with_shell("amixer -q set Master 3-% unmute") end)
|
||||||
))
|
))
|
||||||
volpct:buttons(volicon:buttons())
|
volpct:buttons(volicon:buttons())
|
||||||
volspace:buttons(volicon:buttons())
|
volspace:buttons(volicon:buttons())
|
||||||
-- End Volume }}}
|
-- End Volume }}}
|
||||||
--
|
--
|
||||||
-- {{{ Start CPU
|
-- {{{ Start CPU
|
||||||
cpuicon = wibox.widget.imagebox()
|
cpuicon = wibox.widget.imagebox()
|
||||||
cpuicon:set_image(beautiful.widget_cpu)
|
cpuicon:set_image(beautiful.widget_cpu)
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
-- {{{ init environment
|
-- {{{ init environment
|
||||||
local wakka = {}
|
local wakka = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ display
|
-- {{{ display
|
||||||
-- formats the lines for the notify
|
-- formats the lines for the notify
|
||||||
local function display()
|
local function display()
|
||||||
local lines = "<u>AUR Updates:</u>\n"
|
local lines = "<u>AUR Updates:</u>\n"
|
||||||
local f = io.popen("cower -u", "r")
|
local f = io.popen("cower -u", "r")
|
||||||
local s = f:read('*all')
|
local s = f:read('*all')
|
||||||
line = lines .. "\n" .. s .. "\n"
|
line = lines .. "\n" .. s .. "\n"
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
function wakka.addToWidget(mywidget)
|
function wakka.addToWidget(mywidget)
|
||||||
mywidget:add_signal('mouse::enter', function ()
|
mywidget:add_signal('mouse::enter', function ()
|
||||||
usage = naughty.notify({
|
usage = naughty.notify({
|
||||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
hover_timeout = 0.5,
|
hover_timeout = 0.5,
|
||||||
screen = capi.mouse.screen
|
screen = capi.mouse.screen
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wakka
|
return wakka
|
@ -1,39 +1,39 @@
|
|||||||
-- {{{ init environment
|
-- {{{ init environment
|
||||||
local wakka = {}
|
local wakka = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ display
|
-- {{{ display
|
||||||
-- formats the lines for the notify
|
-- formats the lines for the notify
|
||||||
local function display()
|
local function display()
|
||||||
local lines = "<u>Bitcoin:</u>\n"
|
local lines = "<u>Bitcoin:</u>\n"
|
||||||
local tick = "<u>Ask:</u>\n"
|
local tick = "<u>Ask:</u>\n"
|
||||||
local f = io.popen("bitcoind getbalance", "r")
|
local f = io.popen("bitcoind getbalance", "r")
|
||||||
local t = io.popen("curl -q -s https://api.bitcoinaverage.com/ticker/global/AUD/ask", "r")
|
local t = io.popen("curl -q -s https://api.bitcoinaverage.com/ticker/global/AUD/ask", "r")
|
||||||
local s = f:read('*all')
|
local s = f:read('*all')
|
||||||
local g = t:read('*all')
|
local g = t:read('*all')
|
||||||
line = lines .. "\n" .. s .. "\n"
|
line = lines .. "\n" .. s .. "\n"
|
||||||
ticker = tick .. "\n" .. g .. "\n"
|
ticker = tick .. "\n" .. g .. "\n"
|
||||||
f:close()
|
f:close()
|
||||||
t:close()
|
t:close()
|
||||||
-- return line, ticker
|
-- return line, ticker
|
||||||
return string.format('%s%s',line, ticker)
|
return string.format('%s%s',line, ticker)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function wakka.addToWidget(mywidget)
|
function wakka.addToWidget(mywidget)
|
||||||
mywidget:add_signal('mouse::enter', function ()
|
mywidget:add_signal('mouse::enter', function ()
|
||||||
run_display = display()
|
run_display = display()
|
||||||
usage = naughty.notify({
|
usage = naughty.notify({
|
||||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", run_display),
|
text = string.format('<span font_desc="%s">%s</span>', "monospace", run_display),
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
hover_timeout = 0.5,
|
hover_timeout = 0.5,
|
||||||
screen = capi.mouse.screen
|
screen = capi.mouse.screen
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wakka
|
return wakka
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
-- {{{ init environment
|
-- {{{ init environment
|
||||||
local wakka = {}
|
local wakka = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ display
|
-- {{{ display
|
||||||
-- formats the lines for the notify
|
-- formats the lines for the notify
|
||||||
local function display()
|
local function display()
|
||||||
local lines = "<u>GFX Temp:</u>\n"
|
local lines = "<u>GFX Temp:</u>\n"
|
||||||
local f = io.popen("/opt/bin/aticonfig --odgt | grep Temperature | cut -c 43-52", "r")
|
local f = io.popen("/opt/bin/aticonfig --odgt | grep Temperature | cut -c 43-52", "r")
|
||||||
local s = f:read('*all')
|
local s = f:read('*all')
|
||||||
line = lines .. "\n" .. s .. "\n"
|
line = lines .. "\n" .. s .. "\n"
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
function wakka.addToWidget(mywidget)
|
function wakka.addToWidget(mywidget)
|
||||||
mywidget:add_signal('mouse::enter', function ()
|
mywidget:add_signal('mouse::enter', function ()
|
||||||
usage = naughty.notify({
|
usage = naughty.notify({
|
||||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
hover_timeout = 0.5,
|
hover_timeout = 0.5,
|
||||||
screen = capi.mouse.screen
|
screen = capi.mouse.screen
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wakka
|
return wakka
|
||||||
|
@ -11,8 +11,8 @@ local modkey = "Mod4"
|
|||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local capi = {
|
local capi = {
|
||||||
root = root,
|
root = root,
|
||||||
client = client
|
client = client
|
||||||
}
|
}
|
||||||
|
|
||||||
module("keydoc")
|
module("keydoc")
|
||||||
@ -23,101 +23,101 @@ local orig = awful.key.new
|
|||||||
|
|
||||||
-- Replacement for awful.key.new
|
-- Replacement for awful.key.new
|
||||||
local function new(mod, key, press, release, docstring)
|
local function new(mod, key, press, release, docstring)
|
||||||
-- Usually, there is no use of release, let's just use it for doc
|
-- Usually, there is no use of release, let's just use it for doc
|
||||||
-- if it's a string.
|
-- if it's a string.
|
||||||
if press and release and not docstring and type(release) == "string" then
|
if press and release and not docstring and type(release) == "string" then
|
||||||
docstring = release
|
docstring = release
|
||||||
release = nil
|
release = nil
|
||||||
end
|
end
|
||||||
local k = orig(mod, key, press, release)
|
local k = orig(mod, key, press, release)
|
||||||
-- Remember documentation for this key (we take the first one)
|
-- Remember documentation for this key (we take the first one)
|
||||||
if k and #k > 0 and docstring then
|
if k and #k > 0 and docstring then
|
||||||
doc[k[1]] = { help = docstring,
|
doc[k[1]] = { help = docstring,
|
||||||
group = currentgroup }
|
group = currentgroup }
|
||||||
end
|
end
|
||||||
|
|
||||||
return k
|
return k
|
||||||
end
|
end
|
||||||
awful.key.new = new -- monkey patch
|
awful.key.new = new -- monkey patch
|
||||||
|
|
||||||
-- Turn a key to a string
|
-- Turn a key to a string
|
||||||
local function key2str(key)
|
local function key2str(key)
|
||||||
local sym = key.key or key.keysym
|
local sym = key.key or key.keysym
|
||||||
local translate = {
|
local translate = {
|
||||||
["#14"] = "#",
|
["#14"] = "#",
|
||||||
[" "] = "Space",
|
[" "] = "Space",
|
||||||
}
|
}
|
||||||
sym = translate[sym] or sym
|
sym = translate[sym] or sym
|
||||||
if not key.modifiers or #key.modifiers == 0 then return sym end
|
if not key.modifiers or #key.modifiers == 0 then return sym end
|
||||||
local result = ""
|
local result = ""
|
||||||
local translate = {
|
local translate = {
|
||||||
[modkey] = "⊞",
|
[modkey] = "⊞",
|
||||||
Shift = "⇧",
|
Shift = "⇧",
|
||||||
Control = "Ctrl",
|
Control = "Ctrl",
|
||||||
}
|
}
|
||||||
for _, mod in pairs(key.modifiers) do
|
for _, mod in pairs(key.modifiers) do
|
||||||
mod = translate[mod] or mod
|
mod = translate[mod] or mod
|
||||||
result = result .. mod .. " + "
|
result = result .. mod .. " + "
|
||||||
end
|
end
|
||||||
return result .. sym
|
return result .. sym
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Unicode "aware" length function (well, UTF8 aware)
|
-- Unicode "aware" length function (well, UTF8 aware)
|
||||||
-- See: http://lua-users.org/wiki/LuaUnicode
|
-- See: http://lua-users.org/wiki/LuaUnicode
|
||||||
local function unilen(str)
|
local function unilen(str)
|
||||||
local _, count = string.gsub(str, "[^\128-\193]", "")
|
local _, count = string.gsub(str, "[^\128-\193]", "")
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Start a new group
|
-- Start a new group
|
||||||
function group(name)
|
function group(name)
|
||||||
currentgroup = name
|
currentgroup = name
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function markup(keys)
|
local function markup(keys)
|
||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
-- Compute longest key combination
|
-- Compute longest key combination
|
||||||
local longest = 0
|
local longest = 0
|
||||||
for _, key in ipairs(keys) do
|
for _, key in ipairs(keys) do
|
||||||
if doc[key] then
|
if doc[key] then
|
||||||
longest = math.max(longest, unilen(key2str(key)))
|
longest = math.max(longest, unilen(key2str(key)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local curgroup = nil
|
local curgroup = nil
|
||||||
for _, key in ipairs(keys) do
|
for _, key in ipairs(keys) do
|
||||||
if doc[key] then
|
if doc[key] then
|
||||||
local help, group = doc[key].help, doc[key].group
|
local help, group = doc[key].help, doc[key].group
|
||||||
local skey = key2str(key)
|
local skey = key2str(key)
|
||||||
result[group] = (result[group] or "") ..
|
result[group] = (result[group] or "") ..
|
||||||
'<span font="DejaVu Sans Mono 10" color="' .. beautiful.fg_widget_clock .. '"> ' ..
|
'<span font="DejaVu Sans Mono 10" color="' .. beautiful.fg_widget_clock .. '"> ' ..
|
||||||
string.format("%" .. (longest - unilen(skey)) .. "s ", "") .. skey ..
|
string.format("%" .. (longest - unilen(skey)) .. "s ", "") .. skey ..
|
||||||
'</span> <span color="' .. beautiful.fg_widget_value .. '">' ..
|
'</span> <span color="' .. beautiful.fg_widget_value .. '">' ..
|
||||||
help .. '</span>\n'
|
help .. '</span>\n'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Display help in a naughty notification
|
-- Display help in a naughty notification
|
||||||
local nid = nil
|
local nid = nil
|
||||||
function display()
|
function display()
|
||||||
local strings = awful.util.table.join(
|
local strings = awful.util.table.join(
|
||||||
markup(capi.root.keys()),
|
markup(capi.root.keys()),
|
||||||
capi.client.focus and markup(capi.client.focus:keys()) or {})
|
capi.client.focus and markup(capi.client.focus:keys()) or {})
|
||||||
|
|
||||||
local result = ""
|
local result = ""
|
||||||
for group, res in pairs(strings) do
|
for group, res in pairs(strings) do
|
||||||
if #result > 0 then result = result .. "\n" end
|
if #result > 0 then result = result .. "\n" end
|
||||||
result = result ..
|
result = result ..
|
||||||
'<span weight="bold" color="' .. beautiful.fg_widget_value_important .. '">' ..
|
'<span weight="bold" color="' .. beautiful.fg_widget_value_important .. '">' ..
|
||||||
group .. "</span>\n" .. res
|
group .. "</span>\n" .. res
|
||||||
end
|
end
|
||||||
nid = naughty.notify({ text = result,
|
nid = naughty.notify({ text = result,
|
||||||
replaces_id = nid,
|
replaces_id = nid,
|
||||||
hover_timeout = 0.1,
|
hover_timeout = 0.1,
|
||||||
timeout = 30 }).id
|
timeout = 30 }).id
|
||||||
end
|
end
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
-- {{{ init environment
|
-- {{{ init environment
|
||||||
local wakka = {}
|
local wakka = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ display
|
-- {{{ display
|
||||||
-- formats the lines for the notify
|
-- formats the lines for the notify
|
||||||
local function display()
|
local function display()
|
||||||
local lines = "<u>Namecoin:</u>\n"
|
local lines = "<u>Namecoin:</u>\n"
|
||||||
local f = io.popen("namecoind getbalance", "r")
|
local f = io.popen("namecoind getbalance", "r")
|
||||||
local s = f:read('*all')
|
local s = f:read('*all')
|
||||||
line = lines .. "\n" .. s .. "\n"
|
line = lines .. "\n" .. s .. "\n"
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
function wakka.addToWidget(mywidget)
|
function wakka.addToWidget(mywidget)
|
||||||
mywidget:add_signal('mouse::enter', function ()
|
mywidget:add_signal('mouse::enter', function ()
|
||||||
usage = naughty.notify({
|
usage = naughty.notify({
|
||||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
hover_timeout = 0.5,
|
hover_timeout = 0.5,
|
||||||
screen = capi.mouse.screen
|
screen = capi.mouse.screen
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wakka
|
return wakka
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
-- {{{ init environment
|
-- {{{ init environment
|
||||||
local wakka = {}
|
local wakka = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ display
|
-- {{{ display
|
||||||
-- formats the lines for the notify
|
-- formats the lines for the notify
|
||||||
local function display()
|
local function display()
|
||||||
local lines = "<u>Pacman Updates:</u>\n"
|
local lines = "<u>Pacman Updates:</u>\n"
|
||||||
local f = io.popen("pacman -Qqu", "r")
|
local f = io.popen("pacman -Qqu", "r")
|
||||||
local s = f:read('*all')
|
local s = f:read('*all')
|
||||||
line = lines .. "\n" .. s .. "\n"
|
line = lines .. "\n" .. s .. "\n"
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
function wakka.addToWidget(mywidget)
|
function wakka.addToWidget(mywidget)
|
||||||
mywidget:add_signal('mouse::enter', function ()
|
mywidget:add_signal('mouse::enter', function ()
|
||||||
usage = naughty.notify({
|
usage = naughty.notify({
|
||||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
hover_timeout = 0.5,
|
hover_timeout = 0.5,
|
||||||
screen = capi.mouse.screen
|
screen = capi.mouse.screen
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wakka
|
return wakka
|
@ -1,33 +1,33 @@
|
|||||||
-- {{{ init environment
|
-- {{{ init environment
|
||||||
local wakka = {}
|
local wakka = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
mouse = mouse,
|
mouse = mouse,
|
||||||
screen = screen
|
screen = screen
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ display
|
-- {{{ display
|
||||||
-- formats the lines for the notify
|
-- formats the lines for the notify
|
||||||
local function display()
|
local function display()
|
||||||
local lines = "<u>AUR Updates:</u>\n"
|
local lines = "<u>AUR Updates:</u>\n"
|
||||||
local f = io.popen("archey", "r")
|
local f = io.popen("archey", "r")
|
||||||
local s = f:read('*all')
|
local s = f:read('*all')
|
||||||
line = lines .. "\n" .. s .. "\n"
|
line = lines .. "\n" .. s .. "\n"
|
||||||
f:close()
|
f:close()
|
||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
function wakka.addToWidget(mywidget)
|
function wakka.addToWidget(mywidget)
|
||||||
mywidget:add_signal('mouse::enter', function ()
|
mywidget:add_signal('mouse::enter', function ()
|
||||||
usage = naughty.notify({
|
usage = naughty.notify({
|
||||||
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
text = string.format('<span font_desc="%s">%s</span>', "monospace", display()),
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
hover_timeout = 0.5,
|
hover_timeout = 0.5,
|
||||||
screen = capi.mouse.screen
|
screen = capi.mouse.screen
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return wakka
|
return wakka
|
||||||
|
@ -16,13 +16,11 @@ al-compositor --start &
|
|||||||
lxpolkit &
|
lxpolkit &
|
||||||
|
|
||||||
# panel
|
# panel
|
||||||
al-tint2-session &
|
sleep 1; al-polybar-session &
|
||||||
sleep 1; start-polybar &
|
|
||||||
|
|
||||||
|
|
||||||
|
# Set some bsp specific stuff
|
||||||
bspc monitor -d I II III IV V VI VII VIII IX X
|
bspc monitor -d I II III IV V VI VII VIII IX X
|
||||||
|
|
||||||
|
|
||||||
bspc config border_width 3
|
bspc config border_width 3
|
||||||
bspc config window_gap 12
|
bspc config window_gap 12
|
||||||
bspc config top_padding 18
|
bspc config top_padding 18
|
||||||
@ -37,7 +35,7 @@ bspc config paddingless_monocle true
|
|||||||
|
|
||||||
bspc config pointer_modifier mod1
|
bspc config pointer_modifier mod1
|
||||||
bspc config click_to_focus true
|
bspc config click_to_focus true
|
||||||
bspc config pointer_action1 move
|
bspc config pointer_action1 move
|
||||||
bspc config pointer_action2 resize_side
|
bspc config pointer_action2 resize_side
|
||||||
bspc config pointer_action3 resize_corner
|
bspc config pointer_action3 resize_corner
|
||||||
|
|
||||||
|
@ -1,81 +1,81 @@
|
|||||||
conky.config = {
|
conky.config = {
|
||||||
|
|
||||||
--Various settings
|
--Various settings
|
||||||
|
|
||||||
background = true,
|
background = true,
|
||||||
cpu_avg_samples = 2,
|
cpu_avg_samples = 2,
|
||||||
diskio_avg_samples = 10,
|
diskio_avg_samples = 10,
|
||||||
double_buffer = true,
|
double_buffer = true,
|
||||||
if_up_strictness = 'address',
|
if_up_strictness = 'address',
|
||||||
net_avg_samples = 2,
|
net_avg_samples = 2,
|
||||||
no_buffers = true,
|
no_buffers = true,
|
||||||
temperature_unit = 'celsius',
|
temperature_unit = 'celsius',
|
||||||
text_buffer_size = 2048,
|
text_buffer_size = 2048,
|
||||||
update_interval = 1,
|
update_interval = 1,
|
||||||
imlib_cache_size = 0,
|
imlib_cache_size = 0,
|
||||||
|
|
||||||
|
|
||||||
--Placement
|
--Placement
|
||||||
|
|
||||||
alignment = 'top_right',
|
alignment = 'top_right',
|
||||||
gap_x = 20,
|
gap_x = 20,
|
||||||
gap_y = 45,
|
gap_y = 45,
|
||||||
minimum_height = 200,
|
minimum_height = 200,
|
||||||
minimum_width = 230,
|
minimum_width = 230,
|
||||||
maximum_width = 230,
|
maximum_width = 230,
|
||||||
|
|
||||||
|
|
||||||
--Graphical
|
--Graphical
|
||||||
|
|
||||||
border_inner_margin = 5,
|
border_inner_margin = 5,
|
||||||
border_outer_margin = 5,
|
border_outer_margin = 5,
|
||||||
border_width = 0,
|
border_width = 0,
|
||||||
default_bar_width = 280,
|
default_bar_width = 280,
|
||||||
default_bar_height = 10,
|
default_bar_height = 10,
|
||||||
default_gauge_height = 25,
|
default_gauge_height = 25,
|
||||||
default_gauge_width =40,
|
default_gauge_width =40,
|
||||||
default_graph_height = 40,
|
default_graph_height = 40,
|
||||||
default_graph_width = 153,
|
default_graph_width = 153,
|
||||||
default_shade_color = '#000000',
|
default_shade_color = '#000000',
|
||||||
default_outline_color = '#000000',
|
default_outline_color = '#000000',
|
||||||
draw_borders = false,
|
draw_borders = false,
|
||||||
draw_graph_borders = true,
|
draw_graph_borders = true,
|
||||||
draw_shades = false,
|
draw_shades = false,
|
||||||
draw_outline = false,
|
draw_outline = false,
|
||||||
|
|
||||||
--Textual
|
--Textual
|
||||||
|
|
||||||
extra_newline = false,
|
extra_newline = false,
|
||||||
format_human_readable = true,
|
format_human_readable = true,
|
||||||
font = 'Ubuntu Mono:size=11:regular',
|
font = 'Ubuntu Mono:size=11:regular',
|
||||||
max_text_width = 0,
|
max_text_width = 0,
|
||||||
max_user_text = 16384,
|
max_user_text = 16384,
|
||||||
override_utf8_locale = true,
|
override_utf8_locale = true,
|
||||||
short_units = true,
|
short_units = true,
|
||||||
top_name_width = 21,
|
top_name_width = 21,
|
||||||
top_name_verbose = false,
|
top_name_verbose = false,
|
||||||
uppercase = false,
|
uppercase = false,
|
||||||
use_spacer = 'none',
|
use_spacer = 'none',
|
||||||
use_xft = true,
|
use_xft = true,
|
||||||
xftalpha = 1,
|
xftalpha = 1,
|
||||||
|
|
||||||
--Windows
|
--Windows
|
||||||
|
|
||||||
own_window = true,
|
own_window = true,
|
||||||
own_window_argb_value = 50,
|
own_window_argb_value = 50,
|
||||||
own_window_argb_visual = true,
|
own_window_argb_visual = true,
|
||||||
own_window_class = 'Conky',
|
own_window_class = 'Conky',
|
||||||
own_window_colour = '#2B303B',
|
own_window_colour = '#2B303B',
|
||||||
own_window_hints = 'undecorated,below,above,sticky,skip_taskbar,skip_pager',
|
own_window_hints = 'undecorated,below,above,sticky,skip_taskbar,skip_pager',
|
||||||
own_window_transparent = false,
|
own_window_transparent = false,
|
||||||
own_window_title = 'system_conky',
|
own_window_title = 'system_conky',
|
||||||
own_window_type = 'desktop',
|
own_window_type = 'desktop',
|
||||||
|
|
||||||
|
|
||||||
--Colours
|
--Colours
|
||||||
|
|
||||||
default_color = '#888888',
|
default_color = '#888888',
|
||||||
color1 = '#888888',
|
color1 = '#888888',
|
||||||
|
|
||||||
};
|
};
|
||||||
conky.text = [[
|
conky.text = [[
|
||||||
|
@ -1,81 +1,81 @@
|
|||||||
conky.config = {
|
conky.config = {
|
||||||
|
|
||||||
--Various settings
|
--Various settings
|
||||||
|
|
||||||
background = true,
|
background = true,
|
||||||
cpu_avg_samples = 2,
|
cpu_avg_samples = 2,
|
||||||
diskio_avg_samples = 10,
|
diskio_avg_samples = 10,
|
||||||
double_buffer = true,
|
double_buffer = true,
|
||||||
if_up_strictness = 'address',
|
if_up_strictness = 'address',
|
||||||
net_avg_samples = 2,
|
net_avg_samples = 2,
|
||||||
no_buffers = true,
|
no_buffers = true,
|
||||||
temperature_unit = 'celsius',
|
temperature_unit = 'celsius',
|
||||||
text_buffer_size = 2048,
|
text_buffer_size = 2048,
|
||||||
update_interval = 1,
|
update_interval = 1,
|
||||||
imlib_cache_size = 0,
|
imlib_cache_size = 0,
|
||||||
|
|
||||||
|
|
||||||
--Placement
|
--Placement
|
||||||
|
|
||||||
alignment = 'top_right',
|
alignment = 'top_right',
|
||||||
gap_x = 20,
|
gap_x = 20,
|
||||||
gap_y = 45,
|
gap_y = 45,
|
||||||
minimum_height = 200,
|
minimum_height = 200,
|
||||||
minimum_width = 230,
|
minimum_width = 230,
|
||||||
maximum_width = 230,
|
maximum_width = 230,
|
||||||
|
|
||||||
|
|
||||||
--Graphical
|
--Graphical
|
||||||
|
|
||||||
border_inner_margin = 5,
|
border_inner_margin = 5,
|
||||||
border_outer_margin = 5,
|
border_outer_margin = 5,
|
||||||
border_width = 0,
|
border_width = 0,
|
||||||
default_bar_width = 280,
|
default_bar_width = 280,
|
||||||
default_bar_height = 10,
|
default_bar_height = 10,
|
||||||
default_gauge_height = 25,
|
default_gauge_height = 25,
|
||||||
default_gauge_width =40,
|
default_gauge_width =40,
|
||||||
default_graph_height = 40,
|
default_graph_height = 40,
|
||||||
default_graph_width = 153,
|
default_graph_width = 153,
|
||||||
default_shade_color = '#000000',
|
default_shade_color = '#000000',
|
||||||
default_outline_color = '#000000',
|
default_outline_color = '#000000',
|
||||||
draw_borders = false,
|
draw_borders = false,
|
||||||
draw_graph_borders = true,
|
draw_graph_borders = true,
|
||||||
draw_shades = false,
|
draw_shades = false,
|
||||||
draw_outline = false,
|
draw_outline = false,
|
||||||
|
|
||||||
--Textual
|
--Textual
|
||||||
|
|
||||||
extra_newline = false,
|
extra_newline = false,
|
||||||
format_human_readable = true,
|
format_human_readable = true,
|
||||||
font = 'Ubuntu Mono:size=11:regular',
|
font = 'Ubuntu Mono:size=11:regular',
|
||||||
max_text_width = 0,
|
max_text_width = 0,
|
||||||
max_user_text = 16384,
|
max_user_text = 16384,
|
||||||
override_utf8_locale = true,
|
override_utf8_locale = true,
|
||||||
short_units = true,
|
short_units = true,
|
||||||
top_name_width = 21,
|
top_name_width = 21,
|
||||||
top_name_verbose = false,
|
top_name_verbose = false,
|
||||||
uppercase = false,
|
uppercase = false,
|
||||||
use_spacer = 'none',
|
use_spacer = 'none',
|
||||||
use_xft = true,
|
use_xft = true,
|
||||||
xftalpha = 1,
|
xftalpha = 1,
|
||||||
|
|
||||||
--Windows
|
--Windows
|
||||||
|
|
||||||
own_window = true,
|
own_window = true,
|
||||||
own_window_argb_value = 50,
|
own_window_argb_value = 50,
|
||||||
own_window_argb_visual = true,
|
own_window_argb_visual = true,
|
||||||
own_window_class = 'Conky',
|
own_window_class = 'Conky',
|
||||||
own_window_colour = '#2B303B',
|
own_window_colour = '#2B303B',
|
||||||
own_window_hints = 'undecorated,below,above,sticky,skip_taskbar,skip_pager',
|
own_window_hints = 'undecorated,below,above,sticky,skip_taskbar,skip_pager',
|
||||||
own_window_transparent = false,
|
own_window_transparent = false,
|
||||||
own_window_title = 'system_conky',
|
own_window_title = 'system_conky',
|
||||||
own_window_type = 'desktop',
|
own_window_type = 'desktop',
|
||||||
|
|
||||||
|
|
||||||
--Colours
|
--Colours
|
||||||
|
|
||||||
default_color = '#888888',
|
default_color = '#888888',
|
||||||
color1 = '#888888',
|
color1 = '#888888',
|
||||||
|
|
||||||
};
|
};
|
||||||
conky.text = [[
|
conky.text = [[
|
||||||
|
@ -1 +0,0 @@
|
|||||||
|
|
@ -1 +0,0 @@
|
|||||||
/home/smoke/.config/conky/conky-sessionfile
|
|
@ -1,57 +1,56 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||||
<fontconfig>
|
<fontconfig>
|
||||||
<match target="font">
|
<match target="font">
|
||||||
<edit mode="assign" name="hinting" >
|
<edit mode="assign" name="hinting" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</edit>
|
</edit>
|
||||||
<edit mode="assign" name="autohint" >
|
<edit mode="assign" name="autohint" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</edit>
|
</edit>
|
||||||
<edit mode="assign" name="hintstyle" >
|
<edit mode="assign" name="hintstyle" >
|
||||||
<const>hintslight</const>
|
<const>hintslight</const>
|
||||||
</edit>
|
</edit>
|
||||||
<edit mode="assign" name="rgba" >
|
<edit mode="assign" name="rgba" >
|
||||||
<const>rgb</const>
|
<const>rgb</const>
|
||||||
</edit>
|
</edit>
|
||||||
<edit mode="assign" name="antialias" >
|
<edit mode="assign" name="antialias" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</edit>
|
</edit>
|
||||||
<edit mode="assign" name="lcdfilter">
|
<edit mode="assign" name="lcdfilter">
|
||||||
<const>lcddefault</const>
|
<const>lcddefault</const>
|
||||||
</edit>
|
</edit>
|
||||||
</match>
|
</match>
|
||||||
|
<!-- Set preferred serif, sans serif, and monospace fonts. -->
|
||||||
<!-- Set preferred serif, sans serif, and monospace fonts. -->
|
<alias>
|
||||||
<alias>
|
<family>serif</family>
|
||||||
<family>serif</family>
|
<prefer>
|
||||||
<prefer>
|
<family>Ubuntu</family>
|
||||||
<family>Ubuntu</family>
|
</prefer>
|
||||||
</prefer>
|
</alias>
|
||||||
</alias>
|
<alias>
|
||||||
<alias>
|
<family>sans-serif</family>
|
||||||
<family>sans-serif</family>
|
<prefer>
|
||||||
<prefer>
|
<family>Ubuntu</family>
|
||||||
<family>Ubuntu</family>
|
</prefer>
|
||||||
</prefer>
|
</alias>
|
||||||
</alias>
|
<alias>
|
||||||
<alias>
|
<family>sans</family>
|
||||||
<family>sans</family>
|
<prefer>
|
||||||
<prefer>
|
<family>Ubuntu</family>
|
||||||
<family>Ubuntu</family>
|
</prefer>
|
||||||
</prefer>
|
</alias>
|
||||||
</alias>
|
<alias>
|
||||||
<alias>
|
<family>monospace</family>
|
||||||
<family>monospace</family>
|
<prefer>
|
||||||
<prefer>
|
<family>Ubuntu Mono</family>
|
||||||
<family>Ubuntu Mono</family>
|
</prefer>
|
||||||
</prefer>
|
</alias>
|
||||||
</alias>
|
<alias>
|
||||||
<alias>
|
<family>mono</family>
|
||||||
<family>mono</family>
|
<prefer>
|
||||||
<prefer>
|
<family>Ubuntu Mono</family>
|
||||||
<family>Ubuntu Mono</family>
|
</prefer>
|
||||||
</prefer>
|
</alias>
|
||||||
</alias>
|
|
||||||
|
|
||||||
</fontconfig>
|
</fontconfig>
|
||||||
|
@ -76,11 +76,12 @@ set $Mon2 HDMI2
|
|||||||
|
|
||||||
# run with reload
|
# run with reload
|
||||||
exec_always --no-startup-id start-compton
|
exec_always --no-startup-id start-compton
|
||||||
exec_always --no-startup-id start-polybar
|
exec_always --no-startup-id al-polybar-session
|
||||||
exec_always --no-startup-id numlockx on
|
exec_always --no-startup-id numlockx on
|
||||||
exec_always --no-startup-id nitrogen --restore
|
exec_always --no-startup-id nitrogen --restore
|
||||||
exec_always --no-startup-id xrdb -load ~/.Xresources
|
exec_always --no-startup-id xrdb -load ~/.Xresources
|
||||||
exec_always --no-startup-id pkill trayer; trayer --edge bottom --align left --heighttype pixel --height 18 --widthtype request --SetDockType false --expand true --transparent true --alpha 255
|
exec_always --no-startup-id pkill trayer; trayer --edge bottom --align left --heighttype pixel \
|
||||||
|
--height 18 --widthtype request --SetDockType false --expand true --transparent true --alpha 255
|
||||||
|
|
||||||
# run once
|
# run once
|
||||||
exec --no-startup-id xfsettingsd
|
exec --no-startup-id xfsettingsd
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# this script will setup the keyring
|
||||||
sed -i '/keypack/d' $HOME/.config/openbox/autostart
|
# for any user being created from /etc/skel
|
||||||
|
# only after a valid internet connection is made
|
||||||
|
|
||||||
do_setup() {
|
do_setup() {
|
||||||
KEYS=('AEFB411B072836CD48FF0381AE252C284B5DBA5D'
|
keys=('AEFB411B072836CD48FF0381AE252C284B5DBA5D'
|
||||||
'9E4F11C6A072942A7B3FD3B0B81EB14A09A25EB0'
|
'9E4F11C6A072942A7B3FD3B0B81EB14A09A25EB0'
|
||||||
'35F52A02854DCCAEC9DD5CC410443C7F54B00041')
|
'35F52A02854DCCAEC9DD5CC410443C7F54B00041')
|
||||||
sudo dirmngr </dev/null # sometimes prevents failure to connect to keyserver
|
sudo dirmngr </dev/null
|
||||||
sudo pacman-key --init
|
sudo pacman-key --init
|
||||||
sudo pacman-key --populate archlinux
|
sudo pacman-key --populate archlinux
|
||||||
for key in "${KEYS[@]}"; do
|
for k in ${keys[@]}; do
|
||||||
if ! sudo pacman-key --list-keys | grep $key >/dev/null 2>&1; then
|
if ! sudo pacman-key --list-keys | grep -q $k; then
|
||||||
gpg --receive-keys $key
|
gpg --receive-keys $k
|
||||||
sudo pacman-key -r $key
|
sudo pacman-key -r $k
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
sudo pacman-key --populate archlabs
|
sudo pacman-key --populate archlabs
|
||||||
}
|
}
|
||||||
|
|
||||||
net=$(ping -c1 8.8.8.8 2>&1)
|
while ! [[ $(ping -c1 8.8.8.8) ]]; do
|
||||||
while ! [[ $net >/dev/null ]]; do
|
sleep 1
|
||||||
net=$(ping -c1 8.8.8.8 2>&1)
|
|
||||||
sleep 1
|
|
||||||
done
|
done
|
||||||
|
|
||||||
do_setup
|
do_setup
|
||||||
|
sed -i '/keypack/d' $HOME/.config/openbox/autostart
|
||||||
rm -f $HOME/.config/keypack
|
rm -f $HOME/.config/keypack
|
||||||
|
@ -38,7 +38,7 @@ print_info() {
|
|||||||
# info "Disk" disk
|
# info "Disk" disk
|
||||||
# info "Battery" battery
|
# info "Battery" battery
|
||||||
# info "Font" font
|
# info "Font" font
|
||||||
info "Song" song
|
info "Song" song
|
||||||
# info "Local IP" local_ip
|
# info "Local IP" local_ip
|
||||||
# info "Public IP" public_ip
|
# info "Public IP" public_ip
|
||||||
# info "Users" users
|
# info "Users" users
|
||||||
|
@ -73,30 +73,30 @@
|
|||||||
=cut
|
=cut
|
||||||
|
|
||||||
our $CONFIG = {
|
our $CONFIG = {
|
||||||
"editor" => "exo-open",
|
"editor" => "exo-open",
|
||||||
"Linux::DesktopFiles" => {
|
"Linux::DesktopFiles" => {
|
||||||
desktop_files_paths => [
|
desktop_files_paths => [
|
||||||
"/usr/share/applications",
|
"/usr/share/applications",
|
||||||
"/usr/local/share/applications",
|
"/usr/local/share/applications",
|
||||||
"/usr/share/applications/kde4",
|
"/usr/share/applications/kde4",
|
||||||
"$ENV{HOME}/.local/share/applications",
|
"$ENV{HOME}/.local/share/applications",
|
||||||
],
|
],
|
||||||
gtk_rc_filename => "$ENV{HOME}/.gtkrc-2.0",
|
gtk_rc_filename => "$ENV{HOME}/.gtkrc-2.0",
|
||||||
icon_dirs_first => undef,
|
icon_dirs_first => undef,
|
||||||
icon_dirs_last => undef,
|
icon_dirs_last => undef,
|
||||||
icon_dirs_second => undef,
|
icon_dirs_second => undef,
|
||||||
keep_unknown_categories => 1,
|
keep_unknown_categories => 1,
|
||||||
skip_entry => undef,
|
skip_entry => undef,
|
||||||
skip_filename_re => undef,
|
skip_filename_re => undef,
|
||||||
skip_svg_icons => 0,
|
skip_svg_icons => 0,
|
||||||
strict_icon_dirs => undef,
|
strict_icon_dirs => undef,
|
||||||
substitutions => undef,
|
substitutions => undef,
|
||||||
terminalization_format => "%s -e '%s'",
|
terminalization_format => "%s -e '%s'",
|
||||||
terminalize => 1,
|
terminalize => 1,
|
||||||
unknown_category_key => "other",
|
unknown_category_key => "other",
|
||||||
},
|
},
|
||||||
"missing_icon" => "gtk-missing-image",
|
"missing_icon" => "gtk-missing-image",
|
||||||
"name_keys" => ["Name"],
|
"name_keys" => ["Name"],
|
||||||
"terminal" => "termite",
|
"terminal" => "termite",
|
||||||
"VERSION" => 0.71,
|
"VERSION" => 0.71,
|
||||||
}
|
}
|
||||||
|
@ -23,66 +23,66 @@ require "$ENV{HOME}/.config/obmenu-generator/config.pl";
|
|||||||
my $editor = $CONFIG->{editor};
|
my $editor = $CONFIG->{editor};
|
||||||
|
|
||||||
our $SCHEMA = [
|
our $SCHEMA = [
|
||||||
# NAME LABEL ICON
|
# Format: NAME, LABEL, ICON
|
||||||
{sep => "ArchLabs"},
|
{sep => "ArchLabs"},
|
||||||
{item => ['exo-open --launch TerminalEmulator', 'Terminal', 'terminal']},
|
{item => ['exo-open --launch TerminalEmulator', 'Terminal', 'terminal']},
|
||||||
{item => ['exo-open --launch WebBrowser ', 'Web Browser', 'firefox']},
|
{item => ['exo-open --launch WebBrowser ', 'Web Browser', 'firefox']},
|
||||||
{item => ['exo-open --launch FileManager', 'File Manager', 'file-manager']},
|
{item => ['exo-open --launch FileManager', 'File Manager', 'file-manager']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{cat => ['utility', 'Accessories', 'applications-utilities']},
|
{cat => ['utility', 'Accessories', 'applications-utilities']},
|
||||||
{cat => ['development', 'Development', 'applications-development']},
|
{cat => ['development', 'Development', 'applications-development']},
|
||||||
{cat => ['education', 'Education', 'applications-science']},
|
{cat => ['education', 'Education', 'applications-science']},
|
||||||
{cat => ['game', 'Games', 'applications-games']},
|
{cat => ['game', 'Games', 'applications-games']},
|
||||||
{cat => ['graphics', 'Graphics', 'applications-graphics']},
|
{cat => ['graphics', 'Graphics', 'applications-graphics']},
|
||||||
{cat => ['audiovideo', 'Multimedia', 'applications-multimedia']},
|
{cat => ['audiovideo', 'Multimedia', 'applications-multimedia']},
|
||||||
{cat => ['network', 'Network', 'applications-internet']},
|
{cat => ['network', 'Network', 'applications-internet']},
|
||||||
{cat => ['office', 'Office', 'applications-office']},
|
{cat => ['office', 'Office', 'applications-office']},
|
||||||
{cat => ['other', 'Other', 'applications-other']},
|
{cat => ['other', 'Other', 'applications-other']},
|
||||||
{cat => ['settings', 'Settings', 'gnome-settings']},
|
{cat => ['settings', 'Settings', 'gnome-settings']},
|
||||||
{cat => ['system', 'System', 'applications-system']},
|
{cat => ['system', 'System', 'applications-system']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{pipe => ['al-places-pipemenu --recent ~/', 'Places', 'folder']},
|
{pipe => ['al-places-pipemenu --recent ~/', 'Places', 'folder']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{begin_cat => ['Preferences', 'theme']},
|
{begin_cat => ['Preferences', 'theme']},
|
||||||
{begin_cat => ['Openbox', 'openbox']},
|
{begin_cat => ['Openbox', 'openbox']},
|
||||||
{item => ['obconf', 'Settings Editor', 'theme']},
|
{item => ['obconf', 'Settings Editor', 'theme']},
|
||||||
{item => ['kickshaw', 'Menu Editor', 'openbox']},
|
{item => ['kickshaw', 'Menu Editor', 'openbox']},
|
||||||
{item => ['obkey', 'Keybind Editor', 'openbox']},
|
{item => ['obkey', 'Keybind Editor', 'openbox']},
|
||||||
{item => ['ob-autostart', 'Autostart Editor', 'openbox']},
|
{item => ['ob-autostart', 'Autostart Editor', 'openbox']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{item => ["exo-open ~/.config/openbox/menu.xml", 'Edit menu.xml', 'text-xml']},
|
{item => ["exo-open ~/.config/openbox/menu.xml", 'Edit menu.xml', 'text-xml']},
|
||||||
{item => ["exo-open ~/.config/openbox/rc.xml", 'Edit rc.xml', 'text-xml']},
|
{item => ["exo-open ~/.config/openbox/rc.xml", 'Edit rc.xml', 'text-xml']},
|
||||||
{item => ["exo-open ~/.config/openbox/autostart", 'Edit autostart', 'text-xml']},
|
{item => ["exo-open ~/.config/openbox/autostart", 'Edit autostart', 'text-xml']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{item => ['openbox --restart', 'Openbox Restart', 'openbox']},
|
{item => ['openbox --restart', 'Openbox Restart', 'openbox']},
|
||||||
{item => ['openbox --reconfigure', 'Openbox Reconfigure', 'openbox']},
|
{item => ['openbox --reconfigure', 'Openbox Reconfigure', 'openbox']},
|
||||||
{end_cat => undef},
|
{end_cat => undef},
|
||||||
{item => ['xfce4-appearance-settings', 'GTK Appearance', 'preferences-desktop-theme']},
|
{item => ['xfce4-appearance-settings', 'GTK Appearance', 'preferences-desktop-theme']},
|
||||||
{item => ['nitrogen', 'Change Wallpaper', 'nitrogen']},
|
{item => ['nitrogen', 'Change Wallpaper', 'nitrogen']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{pipe => ['al-compositor', 'Compositor', 'compton']},
|
{pipe => ['al-compositor', 'Compositor', 'compton']},
|
||||||
{pipe => ['al-polybar-pipemenu', 'Polybar', 'polybar']},
|
{pipe => ['al-polybar-pipemenu', 'Polybar', 'polybar']},
|
||||||
{pipe => ['al-conky-pipemenu', 'Conky', 'conky']},
|
{pipe => ['al-conky-pipemenu', 'Conky', 'conky']},
|
||||||
{pipe => ['al-tint2-pipemenu', 'Tint2', 'tint2']},
|
{pipe => ['al-tint2-pipemenu', 'Tint2', 'tint2']},
|
||||||
{item => ['rofi-theme-selector', 'Rofi Theme', 'theme']},
|
{item => ['rofi-theme-selector', 'Rofi Theme', 'theme']},
|
||||||
{item => ['al-panel-chooser', 'Panel Chooser', 'panel']},
|
{item => ['al-panel-chooser', 'Panel Chooser', 'panel']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{item => ['xfce4-settings-manager', 'Xfce4 Settings Manager', 'preferences-desktop']},
|
{item => ['xfce4-settings-manager', 'Xfce4 Settings Manager', 'preferences-desktop']},
|
||||||
{item => ['pavucontrol', 'Pulseaudio Preferences', 'multimedia-volume-control']},
|
{item => ['pavucontrol', 'Pulseaudio Preferences', 'multimedia-volume-control']},
|
||||||
{item => ['exo-preferred-applications', 'Preferred Applications', 'preferred-applications']},
|
{item => ['exo-preferred-applications', 'Preferred Applications', 'preferred-applications']},
|
||||||
{item => ['arandr', 'Screen Layout Editor', 'display']},
|
{item => ['arandr', 'Screen Layout Editor', 'display']},
|
||||||
{end_cat => undef},
|
{end_cat => undef},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{begin_cat => ['Menu Generator', 'menu-editor']},
|
{begin_cat => ['Menu Generator', 'menu-editor']},
|
||||||
{item => ["$editor ~/.config/obmenu-generator/schema.pl", 'Menu Layout', 'text-x-source']},
|
{item => ["$editor ~/.config/obmenu-generator/schema.pl", 'Menu Layout', 'text-x-source']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{item => ['obmenu-generator -p', 'Generate a pipe menu', 'menu-editor']},
|
{item => ['obmenu-generator -p', 'Generate a pipe menu', 'menu-editor']},
|
||||||
{item => ['obmenu-generator -s -c', 'Generate a static menu', 'menu-editor']},
|
{item => ['obmenu-generator -s -c', 'Generate a static menu', 'menu-editor']},
|
||||||
{end_cat => undef},
|
{end_cat => undef},
|
||||||
{item => ["switchmenu -static", 'Switch Menu', 'menu-editor']},
|
{item => ["switchmenu -static", 'Switch Menu', 'menu-editor']},
|
||||||
{pipe => ['al-kb-pipemenu', 'Display Keybinds', 'cs-keyboard']},
|
{pipe => ['al-kb-pipemenu', 'Display Keybinds', 'cs-keyboard']},
|
||||||
{pipe => ['al-help-pipemenu', 'Help and Info', 'info']},
|
{pipe => ['al-help-pipemenu', 'Help and Info', 'info']},
|
||||||
{sep => undef},
|
{sep => undef},
|
||||||
{item => ['i3lock-fancy -p', 'Lock Screen', 'lock']},
|
{item => ['i3lock-fancy -p', 'Lock Screen', 'lock']},
|
||||||
{item => ['oblogout', 'Exit Openbox', 'exit']},
|
{item => ['oblogout', 'Exit Openbox', 'exit']},
|
||||||
]
|
]
|
||||||
|
@ -8,11 +8,8 @@ numlockx on &
|
|||||||
# restore wallpaper
|
# restore wallpaper
|
||||||
nitrogen --restore &
|
nitrogen --restore &
|
||||||
|
|
||||||
# start tint2 if enabled
|
# start polybar
|
||||||
al-tint2-session &
|
sleep 1; al-polybar-session &
|
||||||
|
|
||||||
# start polybar if tint2 not enabled (start after al-tint-session)
|
|
||||||
sleep 1; start-polybar &
|
|
||||||
|
|
||||||
# system tray
|
# system tray
|
||||||
sleep 1; trayer --edge bottom --align left --widthtype request --SetDockType false --expand true &
|
sleep 1; trayer --edge bottom --align left --widthtype request --SetDockType false --expand true &
|
||||||
@ -26,10 +23,7 @@ lxpolkit &
|
|||||||
# Required for xfce settings to work
|
# Required for xfce settings to work
|
||||||
xfsettingsd &
|
xfsettingsd &
|
||||||
|
|
||||||
# Launch conky if session exists
|
# set user shortcuts for file managers
|
||||||
sleep 2; al-conky-session &
|
|
||||||
|
|
||||||
# set side user dirs shortcuts for file managers
|
|
||||||
xdg-user-dirs-gtk-update &
|
xdg-user-dirs-gtk-update &
|
||||||
|
|
||||||
$HOME/.config/keypack &
|
$HOME/.config/keypack &
|
||||||
|
@ -6,27 +6,27 @@
|
|||||||
<focus>
|
<focus>
|
||||||
<focusNew>yes</focusNew>
|
<focusNew>yes</focusNew>
|
||||||
<!-- always try to focus new windows when they appear. other rules do
|
<!-- always try to focus new windows when they appear. other rules do
|
||||||
apply -->
|
apply -->
|
||||||
<followMouse>no</followMouse>
|
<followMouse>no</followMouse>
|
||||||
<!-- move focus to a window when you move the mouse into it -->
|
<!-- move focus to a window when you move the mouse into it -->
|
||||||
<focusLast>yes</focusLast>
|
<focusLast>yes</focusLast>
|
||||||
<!-- focus the last used window when changing desktops, instead of the one
|
<!-- focus the last used window when changing desktops, instead of the one
|
||||||
under the mouse pointer. when followMouse is enabled -->
|
under the mouse pointer. when followMouse is enabled -->
|
||||||
<underMouse>no</underMouse>
|
<underMouse>no</underMouse>
|
||||||
<!-- move focus under the mouse, even when the mouse is not moving -->
|
<!-- move focus under the mouse, even when the mouse is not moving -->
|
||||||
<focusDelay>200</focusDelay>
|
<focusDelay>200</focusDelay>
|
||||||
<!-- when followMouse is enabled, the mouse must be inside the window for
|
<!-- when followMouse is enabled, the mouse must be inside the window for
|
||||||
this many milliseconds (1000 = 1 sec) before moving focus to it -->
|
this many milliseconds (1000 = 1 sec) before moving focus to it -->
|
||||||
<raiseOnFocus>no</raiseOnFocus>
|
<raiseOnFocus>no</raiseOnFocus>
|
||||||
<!-- when followMouse is enabled, and a window is given focus by moving the
|
<!-- when followMouse is enabled, and a window is given focus by moving the
|
||||||
mouse into it, also raise the window -->
|
mouse into it, also raise the window -->
|
||||||
</focus>
|
</focus>
|
||||||
<placement>
|
<placement>
|
||||||
<policy>Smart</policy>
|
<policy>Smart</policy>
|
||||||
<!-- 'Smart' or 'UnderMouse' -->
|
<!-- 'Smart' or 'UnderMouse' -->
|
||||||
<center>yes</center>
|
<center>yes</center>
|
||||||
<!-- whether to place windows in the center of the free area found or
|
<!-- whether to place windows in the center of the free area found or
|
||||||
the top left corner -->
|
the top left corner -->
|
||||||
<monitor>Mouse</monitor>
|
<monitor>Mouse</monitor>
|
||||||
<!-- with Smart placement on a multi-monitor system, try to place new windows
|
<!-- with Smart placement on a multi-monitor system, try to place new windows
|
||||||
on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
|
on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
|
||||||
@ -36,21 +36,21 @@
|
|||||||
focus cycling popup, or the desktop switch popup. It can be an index
|
focus cycling popup, or the desktop switch popup. It can be an index
|
||||||
from 1, specifying a particular monitor. Or it can be one of the
|
from 1, specifying a particular monitor. Or it can be one of the
|
||||||
following: 'Mouse' - where the mouse is, or
|
following: 'Mouse' - where the mouse is, or
|
||||||
'Active' - where the active window is -->
|
'Active' - where the active window is -->
|
||||||
</placement>
|
</placement>
|
||||||
<theme>
|
<theme>
|
||||||
<name>gorice</name>
|
<name>gorice</name>
|
||||||
<titleLayout>NLIMC</titleLayout>
|
<titleLayout>NLIMC</titleLayout>
|
||||||
<!--
|
<!--
|
||||||
available characters are NDSLIMC, each can occur at most once.
|
available characters are NDSLIMC, each can occur at most once.
|
||||||
N: window icon
|
N: window icon
|
||||||
L: window label (AKA title).
|
L: window label (AKA title).
|
||||||
I: iconify
|
I: iconify
|
||||||
M: maximize
|
M: maximize
|
||||||
C: close
|
C: close
|
||||||
S: shade (roll up/down)
|
S: shade (roll up/down)
|
||||||
D: omnipresent (on all desktops).
|
D: omnipresent (on all desktops).
|
||||||
-->
|
-->
|
||||||
<keepBorder>yes</keepBorder>
|
<keepBorder>yes</keepBorder>
|
||||||
<animateIconify>yes</animateIconify>
|
<animateIconify>yes</animateIconify>
|
||||||
<font place="ActiveWindow">
|
<font place="ActiveWindow">
|
||||||
@ -110,13 +110,11 @@
|
|||||||
</theme>
|
</theme>
|
||||||
<desktops>
|
<desktops>
|
||||||
<!-- this stuff is only used at startup, pagers allow you to change them
|
<!-- this stuff is only used at startup, pagers allow you to change them
|
||||||
during a session
|
during a session
|
||||||
|
these are default values to use when other ones are not already set
|
||||||
these are default values to use when other ones are not already set
|
by other applications, or saved in your session
|
||||||
by other applications, or saved in your session
|
use obconf if you want to change these without having to log out
|
||||||
|
and back in -->
|
||||||
use obconf if you want to change these without having to log out
|
|
||||||
and back in -->
|
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
<firstdesk>0</firstdesk>
|
<firstdesk>0</firstdesk>
|
||||||
<names>
|
<names>
|
||||||
@ -175,7 +173,6 @@
|
|||||||
</dock>
|
</dock>
|
||||||
<keyboard>
|
<keyboard>
|
||||||
<chainQuitKey/>
|
<chainQuitKey/>
|
||||||
|
|
||||||
<!-- Window & Desktop Control -->
|
<!-- Window & Desktop Control -->
|
||||||
<keybind key="W-1">
|
<keybind key="W-1">
|
||||||
<action name="GoToDesktop">
|
<action name="GoToDesktop">
|
||||||
@ -229,7 +226,7 @@
|
|||||||
</keybind>
|
</keybind>
|
||||||
<keybind key="A-Tab">
|
<keybind key="A-Tab">
|
||||||
<action name="NextWindow">
|
<action name="NextWindow">
|
||||||
<allDesktops>yes</allDesktops>
|
<allDesktops>yes</allDesktops>
|
||||||
<raise>yes</raise>
|
<raise>yes</raise>
|
||||||
<finalactions>
|
<finalactions>
|
||||||
<action name="Focus"/>
|
<action name="Focus"/>
|
||||||
@ -264,7 +261,6 @@
|
|||||||
<action name="FocusToBottom"/>
|
<action name="FocusToBottom"/>
|
||||||
<action name="Unfocus"/>
|
<action name="Unfocus"/>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<!-- Media & Backlight -->
|
<!-- Media & Backlight -->
|
||||||
<keybind key="XF86AudioRaiseVolume">
|
<keybind key="XF86AudioRaiseVolume">
|
||||||
<action name="Execute">
|
<action name="Execute">
|
||||||
@ -311,7 +307,6 @@
|
|||||||
<command>xbacklight -10</command>
|
<command>xbacklight -10</command>
|
||||||
</action>
|
</action>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<!-- Applications -->
|
<!-- Applications -->
|
||||||
<keybind key="Print">
|
<keybind key="Print">
|
||||||
<action name="Execute">
|
<action name="Execute">
|
||||||
@ -358,7 +353,6 @@
|
|||||||
<command>pavucontrol</command>
|
<command>pavucontrol</command>
|
||||||
</action>
|
</action>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<!-- Launchers -->
|
<!-- Launchers -->
|
||||||
<keybind key="W-s">
|
<keybind key="W-s">
|
||||||
<action name="Execute">
|
<action name="Execute">
|
||||||
@ -375,7 +369,6 @@
|
|||||||
<command>rofi-gorice</command>
|
<command>rofi-gorice</command>
|
||||||
</action>
|
</action>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<!-- Logout & Reload -->
|
<!-- Logout & Reload -->
|
||||||
<keybind key="W-x">
|
<keybind key="W-x">
|
||||||
<action name="Execute">
|
<action name="Execute">
|
||||||
@ -401,7 +394,6 @@
|
|||||||
<keybind key="C-S-Enter">
|
<keybind key="C-S-Enter">
|
||||||
<action name="Reconfigure"/>
|
<action name="Reconfigure"/>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<!-- Window Control -->
|
<!-- Window Control -->
|
||||||
<keybind key="W-Escape">
|
<keybind key="W-Escape">
|
||||||
<action name="Execute">
|
<action name="Execute">
|
||||||
@ -435,7 +427,6 @@
|
|||||||
<keybind key="S-W-q">
|
<keybind key="S-W-q">
|
||||||
<action name="Close"/>
|
<action name="Close"/>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<keybind key="W-space">
|
<keybind key="W-space">
|
||||||
<action name="ShowMenu">
|
<action name="ShowMenu">
|
||||||
<menu>root-menu</menu>
|
<menu>root-menu</menu>
|
||||||
@ -446,7 +437,6 @@
|
|||||||
<menu>client-menu</menu>
|
<menu>client-menu</menu>
|
||||||
</action>
|
</action>
|
||||||
</keybind>
|
</keybind>
|
||||||
|
|
||||||
<!-- Tiling Bindings -->
|
<!-- Tiling Bindings -->
|
||||||
<keybind key="W-KP_1">
|
<keybind key="W-KP_1">
|
||||||
<action name="UnmaximizeFull"/>
|
<action name="UnmaximizeFull"/>
|
||||||
@ -576,11 +566,11 @@
|
|||||||
<!-- in milliseconds (1000 = 1 second) -->
|
<!-- in milliseconds (1000 = 1 second) -->
|
||||||
<screenEdgeWarpTime>600</screenEdgeWarpTime>
|
<screenEdgeWarpTime>600</screenEdgeWarpTime>
|
||||||
<!-- Time before changing desktops when the pointer touches the edge of the
|
<!-- Time before changing desktops when the pointer touches the edge of the
|
||||||
screen while moving a window, in milliseconds (1000 = 1 second).
|
screen while moving a window, in milliseconds (1000 = 1 second).
|
||||||
Set this to 0 to disable warping -->
|
Set this to 0 to disable warping -->
|
||||||
<screenEdgeWarpMouse>false</screenEdgeWarpMouse>
|
<screenEdgeWarpMouse>false</screenEdgeWarpMouse>
|
||||||
<!-- Set this to TRUE to move the mouse pointer across the desktop when
|
<!-- Set this to TRUE to move the mouse pointer across the desktop when
|
||||||
switching due to hitting the edge of the screen -->
|
switching due to hitting the edge of the screen -->
|
||||||
<context name="Frame">
|
<context name="Frame">
|
||||||
<mousebind action="Press" button="A-Left">
|
<mousebind action="Press" button="A-Left">
|
||||||
<action name="Focus"/>
|
<action name="Focus"/>
|
||||||
@ -615,7 +605,7 @@
|
|||||||
<maximizedvertical>yes</maximizedvertical>
|
<maximizedvertical>yes</maximizedvertical>
|
||||||
<then>
|
<then>
|
||||||
<action name="Unmaximize"/>
|
<action name="Unmaximize"/>
|
||||||
<direction>vertical</direction>
|
<direction>vertical</direction>
|
||||||
<action name="MoveResizeTo">
|
<action name="MoveResizeTo">
|
||||||
<x>center</x>
|
<x>center</x>
|
||||||
<y>current</y>
|
<y>current</y>
|
||||||
@ -830,27 +820,27 @@
|
|||||||
</mouse>
|
</mouse>
|
||||||
<menu>
|
<menu>
|
||||||
<!-- You can specify more than one menu file in here and they are all loaded,
|
<!-- You can specify more than one menu file in here and they are all loaded,
|
||||||
just don't make menu ids clash or, well, it'll be kind of pointless -->
|
just don't make menu ids clash or, well, it'll be kind of pointless -->
|
||||||
<!-- default menu file (or custom one in $HOME/.config/openbox/) -->
|
<!-- default menu file (or custom one in $HOME/.config/openbox/) -->
|
||||||
<!-- system menu files on Debian systems
|
<!-- system menu files on Debian systems
|
||||||
<file>/var/lib/openbox/debian-menu.xml</file>
|
<file>/var/lib/openbox/debian-menu.xml</file>
|
||||||
<file>debian-menu.xml</file> -->
|
<file>debian-menu.xml</file> -->
|
||||||
<file>menu.xml</file>
|
<file>menu.xml</file>
|
||||||
<hideDelay>200</hideDelay>
|
<hideDelay>200</hideDelay>
|
||||||
<!-- if a press-release lasts longer than this setting (in milliseconds), the
|
<!-- if a press-release lasts longer than this setting (in milliseconds), the
|
||||||
menu is hidden again -->
|
menu is hidden again -->
|
||||||
<middle>no</middle>
|
<middle>no</middle>
|
||||||
<!-- center submenus vertically about the parent entry -->
|
<!-- center submenus vertically about the parent entry -->
|
||||||
<submenuShowDelay>100</submenuShowDelay>
|
<submenuShowDelay>100</submenuShowDelay>
|
||||||
<!-- time to delay before showing a submenu after hovering over the parent
|
<!-- time to delay before showing a submenu after hovering over the parent
|
||||||
entry.
|
entry.
|
||||||
if this is a negative value, then the delay is infinite and the
|
if this is a negative value, then the delay is infinite and the
|
||||||
submenu will not be shown until it is clicked on -->
|
submenu will not be shown until it is clicked on -->
|
||||||
<submenuHideDelay>200</submenuHideDelay>
|
<submenuHideDelay>200</submenuHideDelay>
|
||||||
<!-- time to delay before hiding a submenu when selecting another
|
<!-- time to delay before hiding a submenu when selecting another
|
||||||
entry in parent menu
|
entry in parent menu
|
||||||
if this is a negative value, then the delay is infinite and the
|
if this is a negative value, then the delay is infinite and the
|
||||||
submenu will not be hidden until a different submenu is opened -->
|
submenu will not be hidden until a different submenu is opened -->
|
||||||
<applicationIcons>no</applicationIcons>
|
<applicationIcons>no</applicationIcons>
|
||||||
<!-- controls if icons appear in the client-list-(combined-)menu -->
|
<!-- controls if icons appear in the client-list-(combined-)menu -->
|
||||||
<manageDesktops>yes</manageDesktops>
|
<manageDesktops>yes</manageDesktops>
|
||||||
@ -864,127 +854,127 @@
|
|||||||
<fullscreen>yes</fullscreen>
|
<fullscreen>yes</fullscreen>
|
||||||
</application>
|
</application>
|
||||||
<!-- Set applications to open on a specific desktop
|
<!-- Set applications to open on a specific desktop
|
||||||
<application class="obconf">
|
<application class="obconf">
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
<position force="no">
|
<position force="no">
|
||||||
<x>center</x>
|
<x>center</x>
|
||||||
<y>center</y>
|
<y>center</y>
|
||||||
</position>
|
</position>
|
||||||
</application>
|
</application>
|
||||||
<application class="tint2conf">
|
<application class="tint2conf">
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
<position force="no">
|
<position force="no">
|
||||||
<x>center</x>
|
<x>center</x>
|
||||||
<y>center</y>
|
<y>center</y>
|
||||||
</position>
|
</position>
|
||||||
</application>
|
</application>
|
||||||
<application class="nitrogen">
|
<application class="nitrogen">
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
<position force="no">
|
<position force="no">
|
||||||
<x>center</x>
|
<x>center</x>
|
||||||
<y>center</y>
|
<y>center</y>
|
||||||
</position>
|
</position>
|
||||||
</application>
|
</application>
|
||||||
<application class="lollypop">
|
<application class="lollypop">
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="spotify">
|
<application class="spotify">
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="rhythmbox">
|
<application class="rhythmbox">
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="vlc*">
|
<application class="vlc*">
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="mpv*">
|
<application class="mpv*">
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="audacious">
|
<application class="audacious">
|
||||||
<desktop>1</desktop>
|
<desktop>1</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="chromium">
|
<application class="chromium">
|
||||||
<desktop>2</desktop>
|
<desktop>2</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="google-chrome">
|
<application class="google-chrome">
|
||||||
<desktop>2</desktop>
|
<desktop>2</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="opera">
|
<application class="opera">
|
||||||
<desktop>2</desktop>
|
<desktop>2</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="Firefox">
|
<application class="Firefox">
|
||||||
<desktop>2</desktop>
|
<desktop>2</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="Navigator">
|
<application class="Navigator">
|
||||||
<desktop>2</desktop>
|
<desktop>2</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="pcmanfm">
|
<application class="pcmanfm">
|
||||||
<desktop>3</desktop>
|
<desktop>3</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="dolphin*">
|
<application class="dolphin*">
|
||||||
<desktop>3</desktop>
|
<desktop>3</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="nautilus">
|
<application class="nautilus">
|
||||||
<desktop>3</desktop>
|
<desktop>3</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="Thunar">
|
<application class="Thunar">
|
||||||
<desktop>3</desktop>
|
<desktop>3</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="gimp*">
|
<application class="gimp*">
|
||||||
<desktop>4</desktop>
|
<desktop>4</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="inkscape">
|
<application class="inkscape">
|
||||||
<desktop>4</desktop>
|
<desktop>4</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="pinta">
|
<application class="pinta">
|
||||||
<desktop>4</desktop>
|
<desktop>4</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="gpick">
|
<application class="gpick">
|
||||||
<desktop>4</desktop>
|
<desktop>4</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="gcolor2">
|
<application class="gcolor2">
|
||||||
<desktop>4</desktop>
|
<desktop>4</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="mousepad">
|
<application class="mousepad">
|
||||||
<desktop>5</desktop>
|
<desktop>5</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="Geany">
|
<application class="Geany">
|
||||||
<desktop>5</desktop>
|
<desktop>5</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="subl3">
|
<application class="subl3">
|
||||||
<desktop>5</desktop>
|
<desktop>5</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="atom">
|
<application class="atom">
|
||||||
<desktop>5</desktop>
|
<desktop>5</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
<application class="mousepad">
|
<application class="mousepad">
|
||||||
<desktop>5</desktop>
|
<desktop>5</desktop>
|
||||||
<focus>yes</focus>
|
<focus>yes</focus>
|
||||||
</application>
|
</application>
|
||||||
-->
|
-->
|
||||||
</applications>
|
</applications>
|
||||||
</openbox_config>
|
</openbox_config>
|
||||||
|
@ -369,15 +369,6 @@ menu-3-3 = " |"
|
|||||||
menu-3-3-exec = systemctl poweroff
|
menu-3-3-exec = systemctl poweroff
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; Extra Modules ;;
|
|
||||||
;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Compton Toggle ;;
|
;; Compton Toggle ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -385,7 +376,7 @@ menu-3-3-exec = systemctl poweroff
|
|||||||
type = custom/script
|
type = custom/script
|
||||||
tail = true
|
tail = true
|
||||||
label = %output%
|
label = %output%
|
||||||
click-left = toggle-compton --toggle
|
click-left = toggle-compton --toggle &
|
||||||
exec = toggle-compton
|
exec = toggle-compton
|
||||||
format = <label>
|
format = <label>
|
||||||
|
|
||||||
@ -422,7 +413,7 @@ type = custom/script
|
|||||||
tail = true
|
tail = true
|
||||||
exec = toggle-redshift
|
exec = toggle-redshift
|
||||||
label = %output%
|
label = %output%
|
||||||
click-left = toggle-redshift --toggle
|
click-left = toggle-redshift --toggle &
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;
|
||||||
@ -470,7 +461,6 @@ bar-progress-empty-foreground = #44
|
|||||||
bar-progress-indicator-foreground = #A85659
|
bar-progress-indicator-foreground = #A85659
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;
|
;;;;;;;;;;
|
||||||
;; WIFI ;;
|
;; WIFI ;;
|
||||||
;;;;;;;;;;
|
;;;;;;;;;;
|
||||||
|
11
home/.config/polybar/sessions/bspwm-sessionfile
Normal file
11
home/.config/polybar/sessions/bspwm-sessionfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Polybar bspwm Sessionfile
|
||||||
|
|
||||||
|
# DO NO edit this file, it will be overwritten by al-polyzen
|
||||||
|
# Instead make a custom sessionfile and use the -z FILE or --session FILE option
|
||||||
|
|
||||||
|
# To load session at startup use the following line
|
||||||
|
|
||||||
|
# sleep 1; al-polybar-session &
|
||||||
|
|
||||||
|
|
||||||
|
~/.config/polybar/config bspwm-bar
|
11
home/.config/polybar/sessions/i3-sessionfile
Normal file
11
home/.config/polybar/sessions/i3-sessionfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Polybar i3 Sessionfile
|
||||||
|
|
||||||
|
# DO NO edit this file, it will be overwritten by al-polyzen
|
||||||
|
# Instead make a custom sessionfile and use the -z FILE or --session FILE option
|
||||||
|
|
||||||
|
# To load session at startup use the following line
|
||||||
|
|
||||||
|
# sleep 1; al-polybar-session &
|
||||||
|
|
||||||
|
|
||||||
|
~/.config/polybar/config i3-bar
|
11
home/.config/polybar/sessions/openbox-sessionfile
Normal file
11
home/.config/polybar/sessions/openbox-sessionfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Polybar openbox Sessionfile
|
||||||
|
|
||||||
|
# DO NO edit this file, it will be overwritten by al-polyzen
|
||||||
|
# Instead make a custom sessionfile and use the -z FILE or --session FILE option
|
||||||
|
|
||||||
|
# To load session at startup use the following line
|
||||||
|
|
||||||
|
# sleep 1; al-polybar-session &
|
||||||
|
|
||||||
|
|
||||||
|
~/.config/polybar/config openbox-bar
|
@ -1,15 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# this script will setup configs for any user created from /etc/skel
|
||||||
|
# if this is not run immediately at startup, polybar WILL fail to load
|
||||||
|
|
||||||
sed -i '/base/{n;N;N;d}' $HOME/.config/polybar/config
|
files=($HOME/.config/polybar/config
|
||||||
sed -i "/base/ a\
|
$HOME/.config/gtk-3.0/bookmarks
|
||||||
include-file = ${HOME}/.config/polybar/master.conf" $HOME/.config/polybar/config
|
$HOME/.gorice/templates/i3/data.json
|
||||||
sed -i "/base/ a\
|
$HOME/.mozilla/firefox/archlabs.default/prefs.js
|
||||||
include-file = ${HOME}/.config/polybar/modules.conf" $HOME/.config/polybar/config
|
$HOME/.mozilla/firefox/archlabs.default/sessionstore.js)
|
||||||
sed -i "s/liveuser/${USER}/g" $HOME/.mozilla/firefox/archlabs.default/prefs.js
|
|
||||||
sed -i "s/liveuser/${USER}/g" $HOME/.mozilla/firefox/archlabs.default/sessionstore.js
|
for f in ${files[@]}; do
|
||||||
sed -i "s/liveuser/${USER}/g" $HOME/.gorice/templates/i3/data.json
|
sed -i "s/liveuser/${USER}/g" $f
|
||||||
sed -i "s/liveuser/${USER}/g" $HOME/.config/gtk-3.0/bookmarks
|
done
|
||||||
|
|
||||||
sed -i '/setup/d' $HOME/.config/openbox/autostart
|
sed -i '/setup/d' $HOME/.config/openbox/autostart
|
||||||
rm -f $HOME/.config/setup
|
rm -f $HOME/.config/setup
|
||||||
|
@ -4,7 +4,7 @@ connected=""
|
|||||||
disconnected=""
|
disconnected=""
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if ping -c1 8.8.8.8 >/dev/null; then
|
if [[ $(ping -c1 8.8.8.8) ]]; then
|
||||||
echo "$connected"; sleep 10
|
echo "$connected"; sleep 10
|
||||||
else
|
else
|
||||||
echo "$disconnected"; sleep 1
|
echo "$disconnected"; sleep 1
|
||||||
|
@ -5,7 +5,7 @@ ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
count=$(checkupdates | wc -l)
|
count=$(checkupdates | wc -l)
|
||||||
if hash notify-send >/dev/null 2>&1; then
|
if hash notify-send &>/dev/null; then
|
||||||
if [[ $count > 50 ]]; then
|
if [[ $count > 50 ]]; then
|
||||||
notify-send -u critical -i $ICON \
|
notify-send -u critical -i $ICON \
|
||||||
"You really need to update soon!!" "$count New package updates"
|
"You really need to update soon!!" "$count New package updates"
|
||||||
|
@ -23,8 +23,6 @@ class Selection(Gtk.EventBox):
|
|||||||
self.background = background
|
self.background = background
|
||||||
self.selected_colour = selected
|
self.selected_colour = selected
|
||||||
|
|
||||||
if not working:
|
|
||||||
name = 'x ' + name
|
|
||||||
text = Gtk.Label(name)
|
text = Gtk.Label(name)
|
||||||
hbox = Gtk.HBox()
|
hbox = Gtk.HBox()
|
||||||
hbox.set_size_request(0, 30)
|
hbox.set_size_request(0, 30)
|
||||||
@ -45,38 +43,36 @@ class Selection(Gtk.EventBox):
|
|||||||
|
|
||||||
hbox.pack_end(colour_widgets, False, True, 20)
|
hbox.pack_end(colour_widgets, False, True, 20)
|
||||||
self.hbox = hbox
|
self.hbox = hbox
|
||||||
self.connect('enter-notify-event', self.selected)
|
#self.connect('enter-notify-event', self.selected)
|
||||||
self.connect('leave-notify-event', self.unselected)
|
#self.connect('leave-notify-event', self.unselected)
|
||||||
self.connect('button-press-event', self.clicked)
|
self.connect('button-press-event', self.clicked)
|
||||||
self.add(self.hbox)
|
self.add(self.hbox)
|
||||||
|
|
||||||
def clicked(self, widget, button):
|
def clicked(self, button):
|
||||||
_, index = button.get_button()
|
_, index = button.get_button()
|
||||||
if index == 1:
|
if index == 1:
|
||||||
proc = subprocess.run([PATH, 'load', self.name])
|
subprocess.run([PATH, 'load', self.name])
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def selected(self, *args):
|
#def selected(self, *args):
|
||||||
# self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected))
|
# return None
|
||||||
return None
|
|
||||||
|
|
||||||
def unselected(self, *args):
|
#def unselected(self, *args):
|
||||||
# self.hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(*self.selected))
|
# return None
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def load_configs():
|
def load_configs():
|
||||||
broken = subprocess.check_output([PATH, 'check', GROUP])
|
broken = subprocess.check_output([PATH, 'check', GROUP])
|
||||||
broken = broken.decode('utf-8').split('\n')
|
broken = broken.decode('utf-8').split('\n')
|
||||||
|
|
||||||
output = []
|
|
||||||
path = '{}/.gorice/output.yaml'.format(os.environ['HOME'])
|
path = '{}/.gorice/output.yaml'.format(os.environ['HOME'])
|
||||||
|
output = []
|
||||||
|
|
||||||
with open(path, 'r') as f:
|
with open(path, 'r') as f:
|
||||||
data = yaml.load(f.read())
|
data = yaml.load(f.read())
|
||||||
|
|
||||||
names = sorted(data['configs'])
|
names = sorted(data['configs'])
|
||||||
|
|
||||||
for config in names:
|
for config in names:
|
||||||
info = data['configs'][config]
|
info = data['configs'][config]
|
||||||
config, ext = os.path.splitext(config)
|
config, ext = os.path.splitext(config)
|
||||||
@ -111,18 +107,18 @@ def main():
|
|||||||
configs = load_configs()
|
configs = load_configs()
|
||||||
window = Gtk.Window()
|
window = Gtk.Window()
|
||||||
|
|
||||||
window.modify_font(Pango.FontDescription('Ubuntu 11'))
|
window.modify_font(Pango.FontDescription('Ubuntu 10'))
|
||||||
window.set_property('type-hint', Gdk.WindowTypeHint.SPLASHSCREEN)
|
window.set_property('type-hint', Gdk.WindowTypeHint.SPLASHSCREEN)
|
||||||
window.set_decorated(False)
|
window.set_decorated(False)
|
||||||
window.set_resizable(False)
|
window.set_resizable(False)
|
||||||
|
|
||||||
window.connect('leave-notify-event', Gtk.main_quit)
|
window.connect('leave-notify-event', Gtk.main_quit)
|
||||||
# window.set_property('skip-taskbar-hint', False)
|
|
||||||
# window.set_title('bar-dropdown')
|
|
||||||
# window.set_border_width(0)
|
|
||||||
# window.stick()
|
|
||||||
|
|
||||||
window.connect('delete-event', Gtk.main_quit)
|
window.connect('delete-event', Gtk.main_quit)
|
||||||
|
#window.set_property('skip-taskbar-hint', False)
|
||||||
|
#window.set_title('bar-dropdown')
|
||||||
|
#window.set_border_width(0)
|
||||||
|
#window.stick()
|
||||||
|
|
||||||
|
|
||||||
scrolled = Gtk.ScrolledWindow()
|
scrolled = Gtk.ScrolledWindow()
|
||||||
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||||
|
@ -20,7 +20,6 @@ case $question in
|
|||||||
systemctl poweroff
|
systemctl poweroff
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
: # do nothing on wrong response
|
exit 0 # do nothing on wrong response
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ case $question in
|
|||||||
systemctl poweroff
|
systemctl poweroff
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
: # do nothing on wrong response
|
exit 0 # do nothing on wrong response
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
|
|
||||||
# check which wm were using, case insensitive
|
|
||||||
WMS=(bspwm i3 openbox)
|
|
||||||
for i in ${WMS[@]}; do
|
|
||||||
if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then
|
|
||||||
WM=$i && break
|
|
||||||
elif [[ "$(xprop -root -notype | grep "WM_NAME =" | tr -d '"' | awk '{print tolower($3)}')" == "$i" ]]; then
|
|
||||||
WM=$i && break
|
|
||||||
elif [[ "$(awk '{print tolower($0)}' <<< $XDG_CURRENT_DESKTOP)" == "$i" ]]; then
|
|
||||||
WM=$i && break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# do the logout
|
|
||||||
case $WM in
|
|
||||||
i3)
|
|
||||||
i3-msg exit
|
|
||||||
;;
|
|
||||||
bspwm)
|
|
||||||
for window_id in $(bspc query -W); do
|
|
||||||
bspc window $window_id -c
|
|
||||||
done
|
|
||||||
killall sxhkd
|
|
||||||
bspc quit
|
|
||||||
;;
|
|
||||||
openbox)
|
|
||||||
openbox --exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "WM not yet supported.. Exiting"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# this script will run polybar at boot
|
||||||
|
# and allow toggling via polybar or other means
|
||||||
|
# if it is not running and not enabled, enable it then start
|
||||||
if [ -e "$HOME/.config/.composite_enabled" ] && [ "$(pidof compton)" ]; then
|
if [ -e "$HOME/.config/.composite_enabled" ] && [ "$(pidof compton)" ]; then
|
||||||
al-compositor --restart
|
al-compositor --restart
|
||||||
elif [ -e "$HOME/.config/.composite_enabled" ]; then
|
elif [ -e "$HOME/.config/.composite_enabled" ]; then
|
||||||
|
@ -4,13 +4,20 @@
|
|||||||
# Will launch bars depending on WM
|
# Will launch bars depending on WM
|
||||||
# Can also be used to reload openbox session with [--reload] or [-r]
|
# Can also be used to reload openbox session with [--reload] or [-r]
|
||||||
|
|
||||||
|
# I reccomend using al-polyzen to set up a session for each wm
|
||||||
|
# then ditching this method and adding the following line to your autostart
|
||||||
|
# sleep 1; al-polybar-session &
|
||||||
|
|
||||||
# Enter your bar names here (seperated by spaces) eg. BARS=(bar bar1 my-bar)
|
|
||||||
# This will be combined with CUR_WM in WMS below eg. openbox-bar, bspwm-bar1, i3-my-bar etc.
|
# Enter your bar names here (seperated by spaces) eg. BARS=(bar1 bar2...)
|
||||||
# by default it is set up in WM-BAR naming format
|
# This will be combined with window manager from WMS below eg. openbox-bar1, openbox-bar2...
|
||||||
|
# by default it is set up in WM-BAR naming format eg. i3-bar, openbox-bar, bspwm-bar....
|
||||||
BARS=(bar)
|
BARS=(bar)
|
||||||
CONFIG=$HOME/.config/polybar/config
|
CONFIG=$HOME/.config/polybar/config
|
||||||
WMS=(bspwm i3 openbox)
|
WMS=(bspwm i3 openbox xfce awesome)
|
||||||
|
|
||||||
|
############################################################################################
|
||||||
|
|
||||||
|
|
||||||
HELP="\nUSAGE:\n\tstart-polybar [OPTIONS]
|
HELP="\nUSAGE:\n\tstart-polybar [OPTIONS]
|
||||||
\nOPTIONS:\n\t--reload, -r\tIf running in openbox, will reload the session
|
\nOPTIONS:\n\t--reload, -r\tIf running in openbox, will reload the session
|
||||||
@ -41,17 +48,11 @@ case "$@" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
# bail if tint2 is running
|
|
||||||
if [ "$(pidof tint2)" ]; then exit 0; fi
|
|
||||||
|
|
||||||
|
|
||||||
# kill running bars
|
# kill running bars
|
||||||
while [ "$(pidof polybar)" ]; do
|
while [ "$(pidof polybar)" ]; do
|
||||||
pkill polybar && sleep 0.5
|
pkill polybar && sleep 0.5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
# launch bars
|
# launch bars
|
||||||
for bar in "${BARS[@]}"; do
|
for bar in "${BARS[@]}"; do
|
||||||
polybar -r --config=$CONFIG ${WM}-$bar &
|
polybar -r --config=$CONFIG ${WM}-$bar &
|
||||||
@ -62,4 +63,3 @@ if [ "$(pidof polybar)" ]; then
|
|||||||
else
|
else
|
||||||
echo "Bars Failed to Launch"
|
echo "Bars Failed to Launch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# will stop any running polybar instances
|
||||||
while [ "$(pidof polybar)" ]; do
|
while [ "$(pidof polybar)" ]; do
|
||||||
pkill polybar && sleep 0.5
|
pkill polybar && sleep 0.5
|
||||||
echo "Bars stopped..."
|
echo "Bars stopped..."
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
on=""
|
||||||
|
off=""
|
||||||
|
|
||||||
# if the script is passed --toggle
|
# if the script is passed --toggle
|
||||||
if [[ $1 == *toggle* ]] && pgrep caffeine >/dev/null; then
|
if [[ $1 == *toggle* ]] && pgrep caffeine &>/dev/null; then
|
||||||
killall caffeine && exit 0
|
killall caffeine && exit 0
|
||||||
elif [[ $1 == *toggle* ]]; then
|
elif [[ $1 == *toggle* ]]; then
|
||||||
caffeine &>/dev/null && exit 0
|
caffeine && exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
# caffeine is running
|
# caffeine is running
|
||||||
if pgrep caffeine >/dev/null; then
|
if pgrep caffeine &>/dev/null; then
|
||||||
echo "%{F#0000FF}"
|
echo "%{F#0000FF}$on"
|
||||||
else
|
else
|
||||||
echo "%{F#FF0000}"
|
echo "%{F#FF0000}$off"
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
@ -3,18 +3,17 @@
|
|||||||
on=""
|
on=""
|
||||||
off=""
|
off=""
|
||||||
|
|
||||||
if [[ $1 == *toggle* ]] && [ "$(pidof compton)" ]; then
|
if [[ $1 == *toggle* ]] && [[ $(pidof compton) ]]; then
|
||||||
al-compositor --stop && exit 0
|
al-compositor --stop && exit 0
|
||||||
elif [[ $1 == *toggle* ]]; then
|
elif [[ $1 == *toggle* ]]; then
|
||||||
al-compositor --start && exit 0
|
al-compositor --start && exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if [ "$(pidof compton)" ]; then
|
if [[ $(pidof compton) ]]; then
|
||||||
echo "$on"
|
echo "$on"
|
||||||
else
|
else
|
||||||
echo "%{F#888888}$off"
|
echo "%{F#888888}$off"
|
||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ "$(pidof polybar)" ]; then
|
# small script to kill polybar if it is running
|
||||||
|
# if it isnt running then start it the default session
|
||||||
|
if [[ $(pidof polybar) ]]; then
|
||||||
pkill polybar
|
pkill polybar
|
||||||
else
|
else
|
||||||
start-polybar
|
al-polybar-session
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ $1 = "--toggle" ]] || [[ $1 = "-t" ]]; then
|
|
||||||
if pgrep redshift >/dev/null; then
|
|
||||||
pkill redshift
|
|
||||||
else
|
|
||||||
redshift-gtk &
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
icon=""
|
icon=""
|
||||||
|
|
||||||
|
if [[ $1 = "--toggle" ]] || [[ $1 = "-t" ]]; then
|
||||||
|
if pgrep redshift >/dev/null; then
|
||||||
|
pkill redshift
|
||||||
|
else
|
||||||
|
redshift-gtk &
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
pgrep -x redshift &> /dev/null
|
pgrep -x redshift &> /dev/null
|
||||||
if [[ $? -eq 0 ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
@ -29,4 +30,3 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if pgrep --full 'termite --title=work-term' >/dev/null; then
|
# will check if precisely this termite instance is running
|
||||||
|
# if it is, then kill it, otherwise launch a new termite with these settings
|
||||||
|
# This allows a "Toggle-able" terminal, by simply binding a key to
|
||||||
|
# "toggle-termite"
|
||||||
|
|
||||||
|
if pgrep --full 'termite --title=work-term' &>/dev/null; then
|
||||||
pkill --full 'termite --title=work-term'
|
pkill --full 'termite --title=work-term'
|
||||||
else
|
else
|
||||||
termite --title=work-term --class=work-term &
|
termite --title=work-term --class=work-term &
|
||||||
|
@ -46,9 +46,7 @@ for i in ${WMS[@]}; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Loop until network connected
|
# Loop until network connected
|
||||||
net=$(ping -c1 8.8.8.8 2>&1)
|
while ! [[ $(ping -c1 8.8.8.8) ]]; do
|
||||||
while ! [[ $net >/dev/null ]]; do
|
|
||||||
net=$(ping -c1 8.8.8.8 2>&1)
|
|
||||||
echo -e "Please Connect to a Network Before Continuing"
|
echo -e "Please Connect to a Network Before Continuing"
|
||||||
clear; sleep 1
|
clear; sleep 1
|
||||||
done
|
done
|
||||||
@ -120,7 +118,7 @@ if [ "${answer,,}" = "${yes,,}" ]; then
|
|||||||
if [[ "$WM" == "i3" ]]; then
|
if [[ "$WM" == "i3" ]]; then
|
||||||
i3-msg restart
|
i3-msg restart
|
||||||
elif [[ "$WM" == "openbox" ]]; then
|
elif [[ "$WM" == "openbox" ]]; then
|
||||||
start-polybar --reload > /dev/null 2>&1
|
al-polybar-session -r
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user