2019-09-14 05:33:40 +02:00
|
|
|
-- uptime widget type for GNU/Linux
|
|
|
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
|
|
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
|
|
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
|
|
|
--
|
|
|
|
-- This file is part of Vicious.
|
|
|
|
--
|
|
|
|
-- Vicious is free software: you can redistribute it and/or modify
|
|
|
|
-- it under the terms of the GNU General Public License as
|
|
|
|
-- published by the Free Software Foundation, either version 2 of the
|
|
|
|
-- License, or (at your option) any later version.
|
|
|
|
--
|
|
|
|
-- Vicious is distributed in the hope that it will be useful,
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
-- GNU General Public License for more details.
|
|
|
|
--
|
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
|
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
-- {{{ Grab environment
|
|
|
|
local math = { floor = math.floor }
|
2009-10-05 00:10:47 +02:00
|
|
|
local string = { match = string.match }
|
2009-11-11 03:55:03 +01:00
|
|
|
local helpers = require("vicious.helpers")
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- {{{ Uptime widget type
|
2019-10-16 09:42:31 +02:00
|
|
|
return helpers.setcall(function ()
|
2009-11-11 14:32:37 +01:00
|
|
|
local proc = helpers.pathtotable("/proc")
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
2009-11-11 03:55:03 +01:00
|
|
|
-- Get system uptime
|
|
|
|
local up_t = math.floor(string.match(proc.uptime, "[%d]+"))
|
2009-10-05 00:10:47 +02:00
|
|
|
local up_d = math.floor(up_t / (3600 * 24))
|
|
|
|
local up_h = math.floor((up_t % (3600 * 24)) / 3600)
|
|
|
|
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
2010-03-15 17:55:25 +01:00
|
|
|
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
|
2019-09-14 05:33:40 +02:00
|
|
|
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
|
2009-11-11 03:55:03 +01:00
|
|
|
return {up_d, up_h, up_m, l1, l5, l15}
|
2019-10-16 09:42:31 +02:00
|
|
|
end)
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
-- }}}
|