diff --git a/diskusage.lua b/diskusage.lua deleted file mode 100644 index 9bcfc1b..0000000 --- a/diskusage.lua +++ /dev/null @@ -1,133 +0,0 @@ --- @author Peter J. Kranz (Absurd-Mind, peter@myref.net) --- Any questions, criticism or praise just drop me an email - --- {{{ init environment -local M = {} -local capi = { - mouse = mouse, - screen = screen -} -units = {"KB", "MB", "GB", "TB", "PB", "EB"} -local usage = {} --- }}} - --- {{{ local functions --- {{{ Unit formatter --- formats a value to the corresponding unit -local function uformat(value) - local ret = tonumber(value) - for i, u in pairs(units) do - if ret < 1024 then - return string.format("%.1f" .. u, ret) - end - ret = ret / 1024; - end - return "N/A" -end --- }}} - --- {{{ getData --- gets the required data from df -local function getData(onlyLocal) - -- Fallback to listing local filesystems - local warg = "" - if onlyLocal == true then - warg = "-l" - end - - local fs_info = {} -- Get data from df - local f = io.popen("LC_ALL=C df -kP " .. warg) - - for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount) - local s = string.match(line, "^.-[%s]([%d]+)") - local u,a,p = string.match(line, "([%d]+)[%D]+([%d]+)[%D]+([%d]+)%%") - local m = string.match(line, "%%[%s]([%p%w]+)") - - if u and m then -- Handle 1st line and broken regexp - fs_info[m] = {} - fs_info[m]["size"] = s - fs_info[m]["used"] = u - fs_info[m]["avail"] = a - fs_info[m]["used_p"] = tonumber(p) - fs_info[m]["avail_p"] = 100 - tonumber(p) - end - end - f:close() - return fs_info -end --- }}} - --- {{{ display --- formats the lines for the notify -local function display(orange, red, onlyLocal) - data = getData(onlyLocal) - local lines = "diskusage:\n" - - local longest = 0 - local longestSize = 0; - local longestUsed = 0; - for i, m in pairs(data) do - if i:len() > longest then - longest = i:len() - end - - local s = uformat(m["size"]) - if s:len() > longestSize then - longestSize = s:len() - end - - local u = uformat(m["used"]) - if u:len() > longestUsed then - longestUsed = u:len() - end - end - longest = longest + 8 - - for i, m in pairs(data) do - local u = uformat(m["used"]) - local s = uformat(m["size"]) - - if m["used_p"] >= red then - lines = lines .. "" - elseif m["used_p"] >= orange then - lines = lines .. "" - else - lines = lines .. "" - end - - lines = lines - .. "\n" - .. i - .. string.rep(" ", longest + longestSize - i:len() - u:len()) - .. u - .. " / " - .. s - .. string.rep(" ", longestUsed - s:len()) - .. " (" - .. m["used_p"] - .. "%)" - end - - return lines -end --- }}} --- }}} - --- {{{ global functions -function M.addToWidget(mywidget, orange, red, onlyLocal) - - mywidget:add_signal('mouse::enter', function () - - usage = naughty.notify({ - text = string.format('%s', "monospace", display(orange, red, onlyLocal)), - timeout = 0, - hover_timeout = 0.5, - screen = capi.mouse.screen - }) - - end) - mywidget:add_signal('mouse::leave', function () naughty.destroy(usage) end) -end --- }}} - -return M \ No newline at end of file diff --git a/wi.lua b/wi.lua index 635c328..52e052b 100644 --- a/wi.lua +++ b/wi.lua @@ -3,16 +3,13 @@ local wibox = require("wibox") local beautiful = require("beautiful") local vicious = require("vicious") local naughty = require("naughty") ---local disk = require("diskusage") --- {{{ BATTERY --- Battery attributes +----< Battery >------------------------------------------------------- +-- local bat_state = "" local bat_charge = 0 local bat_time = 0 local blink = true - --- Icon baticon = wibox.widget.imagebox() baticon:set_image(beautiful.widget_batfull) @@ -46,7 +43,6 @@ vicious.register(batpct, vicious.widgets.bat, function(widget, args) return args[2] .. "% " end, nil, "BAT0") --- Buttons function popup_bat() local state = "" if bat_state == "↯" then @@ -68,164 +64,39 @@ function popup_bat() end batpct:buttons(awful.util.table.join(awful.button({ }, 1, popup_bat))) baticon:buttons(batpct:buttons()) --- End Battery}}} + +----< Volume >-------------------------------------------------------- -- --- {{{ PACMAN --- Icon -pacicon = wibox.widget.imagebox() -pacicon:set_image(beautiful.widget_pac) --- --- Upgrades -pacwidget = wibox.widget.textbox() -vicious.register(pacwidget, vicious.widgets.pkg, function(widget, args) - if args[1] > 0 then - pacicon:set_image(beautiful.widget_pacnew) - else - pacicon:set_image(beautiful.widget_pac) - end - return args[1] - end, 1801, "Arch S") -- Arch S for ignorepkg --- --- Buttons --- function popup_pac() --- local pac_updates = "" --- local f = io.popen("pacman -Sup --dbpath /tmp/pacsync") --- if f then --- pac_updates = f:read("*a"):match(".*/(.*)-.*\n$") --- end --- f:close() --- if not pac_updates then --- pac_updates = "System is up to date" --- end --- naughty.notify { text = pac_updates } --- end --- pacwidget:buttons(awful.util.table.join(awful.button({ }, 1, popup_pac))) --- pacicon:buttons(pacwidget:buttons()) --- End Pacman }}} --- --- {{{ VOLUME --- Cache vicious.cache(vicious.widgets.volume) --- --- Icon volicon = wibox.widget.imagebox() volicon:set_image(beautiful.widget_vol) --- - --- Volume % volpct = wibox.widget.textbox() vicious.register(volpct, vicious.widgets.volume, "$1% ", nil, "Master") + +----< CPU >----------------------------------------------------------- -- --- Buttons ---volicon:buttons(awful.util.table.join( - --awful.button({ }, 1, - --function() awful.util.spawn_with_shell("amixer -c 0 -q set Master toggle") end), - --awful.button({ }, 4, - --function() awful.util.spawn_with_shell("amixer -c 0 -q set Master 3%+ unmute") end), - --awful.button({ }, 5, - -- function() awful.util.spawn_with_shell("amixer --c 0 q set Master 3%- unmute") end) - -- )) - -- volpct:buttons(volicon:buttons()) --- volspace:buttons(volicon:buttons()) - -- End Volume }}} - -- - ---Weather Image-- ---weatheric = wibox.widget.textbox() ---weatheric:set_text("☂ ") - ----Weather Widget ---weather = wibox.widget.textbox() ---weather_box = awful.tooltip({ objects = { weather },}) ---vicious.register(weather, vicious.widgets.weather, --- function(widgets, args) --- weather_box:set_text("City: ".. args["{city}"] .. "\nSky: " .. args["{sky}"] .. "\nHumidity: " .. args["{humid}"] .. "%" .. "\nWind: " .. args["{windmph}"] .. " MP/h") return args["{tempf}"].." ℉" end, --- 1200, "KIND") - ---Change KLOU to yours - --- {{{ Start CPU cpuicon = wibox.widget.imagebox() cpuicon:set_image(beautiful.widget_cpu) --- cpu = wibox.widget.textbox() cpu.fit = function (box,w,h) return 30,0 end vicious.register(cpu, vicious.widgets.cpu, ' $1%', 2) --- End CPU }}} ---{{ Disk Usage --- Disk usage widget + +----< Disk Usage >---------------------------------------------------- +-- diskwidget = wibox.widget.textbox() ---diskwidget.set_image("/home/rat/.config/awesome/du.png") diskwidget:set_text("test") disk = require("diskusage") --- the first argument is the widget to trigger the diskusage --- the second/third is the percentage at which a line gets orange/red --- true = show only local filesystems disk.addToWidget(diskwidget, 75, 90, false) --- - --- --- {{{ Start Mem -memicon = wibox.widget.imagebox() -memicon:set_image(beautiful.widget_ram) --- -mem = wibox.widget.textbox() -vicious.register(mem, vicious.widgets.mem, ' $1/$5% ', 2) --- End Mem }}} - --- {{{ Start Mem diskicon = wibox.widget.imagebox() diskicon:set_image(beautiful.widget_disk) --- disk = wibox.widget.textbox() vicious.register(disk, vicious.widgets.fs, '${/home avail_gb}Gb ', 15) --- End Mem }}} +----< Memory Usage >-------------------------------------------------- -- --- {{{ Start Gmail ---mailicon = wibox.widget.imagebox(beautiful.widget_mail) ---mailwidget = wibox.widget.textbox() ---gmail_t = awful.tooltip({ objects = { mailwidget },}) ---vicious.register(mailwidget, vicious.widgets.gmail, --- function (widget, args) --- gmail_t:set_text(args["{subject}"]) --- gmail_t:add_to_object(mailicon) --- return args["{count}"] --- end, 120) --- --- mailicon:buttons(awful.util.table.join( --- awful.button({ }, 1, function () awful.util.spawn("urxvt -e mutt", false) end) --- )) --- End Gmail }}} --- ---- {{{ Start Network Monitor ---Network Icon ↑ ---netwidgeticon = wibox.widget.textbox() ---netwidgeticon:set_text("Network ↑: ") ----- Network widget ---netwidget = awful.widget.graph() ---netwidget:set_width(15) ---netwidget:set_height(3) ---netwidget:set_background_color("#494B4F") ---netwidget:set_color("#FF5656") -----netwidget:set_colors({type = "linear" , from = {0, 0}, stops = ({0, "} , (0.5, "} , {1, } }}) ---netwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 0, 20 }, stops = { { 0, "#FF5656"}, { 0.5, "#88A175" }, { 1, "#AECF96" } }}) ---netwidget_t = awful.tooltip({ objects = { netwidget.widget },}) ---vicious.register(netwidget, vicious.widgets.net, --- function (widget, args) --- netwidget_t:set_text("Network download: " .. args["{eth0 down_kb}"] .. "mb/s") --- return args["{eth0 down_kb}"] --- end) --- --- End Network Monitor }} ---- - - --- {{{ Start Wifi ---wifiicon = wibox.widget.imagebox() ---wifiicon:set_image(beautiful.widget_wifi) ----- ---wifi = wibox.widget.textbox() ---vicious.register(wifi, vicious.widgets.wifi, "${ssid} Rate: ${rate}MB/s Link: ${link}%", 3, "wlan0") --- End Wifi }}} +memicon = wibox.widget.imagebox() +memicon:set_image(beautiful.widget_ram) +mem = wibox.widget.textbox() +vicious.register(mem, vicious.widgets.mem, ' $1/$5% ', 2)