From 96592eb4885c0062de6ee1f948f2ad980464d585 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sun, 26 Apr 2020 21:23:27 -0400 Subject: [PATCH] cpu widget rockspec --- cpu-widget/cpu-widget-0.0.1.tar.gz | Bin 2529 -> 0 bytes cpu-widget/cpu-widget-0.0.1/cpu-widget.lua | 274 ------------------ cpu-widget/cpu-widget-0.1.tar.gz | Bin 0 -> 2496 bytes ...1-1.rockspec => cpu-widget-0.1-1.rockspec} | 6 +- cpu-widget/rockspec/cpu_widget.rockspec | 26 -- 5 files changed, 3 insertions(+), 303 deletions(-) delete mode 100644 cpu-widget/cpu-widget-0.0.1.tar.gz delete mode 100644 cpu-widget/cpu-widget-0.0.1/cpu-widget.lua create mode 100644 cpu-widget/cpu-widget-0.1.tar.gz rename cpu-widget/rockspec/{cpu_widget-0.0.1-1.rockspec => cpu-widget-0.1-1.rockspec} (82%) delete mode 100644 cpu-widget/rockspec/cpu_widget.rockspec diff --git a/cpu-widget/cpu-widget-0.0.1.tar.gz b/cpu-widget/cpu-widget-0.0.1.tar.gz deleted file mode 100644 index 5f9a320299ff419aef5306895df5037c7d47f77f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2529 zcmV<72_E(ziwFR(Fs5Dr1MOOEZ`(K$&gc9J!i8b`Vk>eICkx+tal6|qa36Xoa5&tD zG!wv|evN>XvNP5%4MQ17y2$w}`Pi`9cRrpO`Zg+p?Nk{yJTowM37H8Bm-n4X_} zf0%%qn;HI2Z)RrxH^IsD@_IJCx->7$%M)`tyPnNX$n1Y0%N|0hs37D-D#4gip-?WX zqHAjZgTgM)e^z0*A^k2qaDuO|uWIK1;_7O8Q=I<`^XkexA?A1C-he;({7;U>>10BF z{qS${AMGP#%?0^+$0YX{RQW5uBk!qCH%uVmzqWiQiP|z^he9x4>8_!2T<15c9PT60 zdoCDRF-09$5}SwaiYyrn9QrG=WrEF-Xsc8p=jZ1eM{UEUVRP?1KO^Tfl3}v*V(*pb z*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g>l^H5HFs85JdG zT2uImRD}ZSia%OeEQl}I9I1;X)VGPp%2}^1J<=i?Z~|=o&|5OS#Bf?}2iRZ*f;|k< zdBat0V){}=RKE}9m?qjqzg28?OC#SrRV&7!q#IOs2w9Rz{z8U1aVD8TM&vv%=oy(| z&D5;7XpP{JhRwYSR@Reoa3MKpl4JWYi@_K#Sr_q zMF(@9`f-Hy0tK>OuTi3WgM>3_#`j2X-kLw$+{9N%zr4GiUjLk3Ayr()y>ux-@CY%Z zl%UeMelJBdET|(g>B`X$9$5NjDvG_JRDa&!i3Dfhek6%FnDgLKm8Ft#V177EM5H&S zp{LhNbaNiZnooyuA2te|H+#_ja36+_R<^|@%(2ZH;o%VnD`kS651T(#oj<&~M; zwK2f{8Qo%gZl-8YbsQxkJ`iE*nipOkFE|48c=>UdN5e|a<3(0M@9fO-QffqE$RIq< z5QtaW67hZPi8#Whh!EeQrM zEquV^E6fcCuvVnAVlA@eK(I9v0ye0CO9wU9H^GC*!3QmPD#wEiCH)p*(dKPM9`QF1 z5YipBHO)8pg~XsQ`;!4g!5{sPYBCt1n+C9Nz^V#8a2#+#pHSknoxZz#35WT4GX6&e zWzFKAK2T!2RLX$Dt`43f$sF(f<1a@TPzc$`4P582eH+$f{*C(WeUi5v?1ER|_qEAO zEL8OnRqsuz>Y_I_uw=qIXRluZNfuUbmcz>jP6n8D8hhd(J1H8LLivVdIy+4N(uBPF zBu~FLs!v?&hb?~Y&`fvOyzRfaXenZL%kx7u!Ldi9$efv#jhzTl6ti z^3fGj9s}3G_p|A{rfI&|pJp+kob9XfRA(4j+z4oBg?;ze)w08jt`iACqS diff --git a/cpu-widget/cpu-widget-0.0.1/cpu-widget.lua b/cpu-widget/cpu-widget-0.0.1/cpu-widget.lua deleted file mode 100644 index e0dea4d..0000000 --- a/cpu-widget/cpu-widget-0.0.1/cpu-widget.lua +++ /dev/null @@ -1,274 +0,0 @@ -------------------------------------------------- --- CPU Widget for Awesome Window Manager --- Shows the current CPU utilization --- More details could be found here: --- https://github.com/streetturtle/awesome-wm-widgets/tree/master/cpu-widget - --- @author Pavel Makhov --- @copyright 2020 Pavel Makhov -------------------------------------------------- - -local awful = require("awful") -local watch = require("awful.widget.watch") -local wibox = require("wibox") -local beautiful = require("beautiful") -local gears = require("gears") - -local widget = {} - -local function split(string_to_split, separator) - if separator == nil then separator = "%s" end - local t={} - - for str in string.gmatch(string_to_split, "([^".. separator .."]+)") do - table.insert(t, str) - end - - return t -end - -local function starts_with(str, start) - return str:sub(1, #start) == start -end - -local function worker(args) - - local args = args or {} - - local width = args.width or 50 - local step_width = args.step_width or 2 - local step_spacing = args.step_spacing or 1 - local color= args.color or beautiful.fg_normal - - local cpugraph_widget = wibox.widget { - max_value = 100, - background_color = "#00000000", - forced_width = width, - step_width = step_width, - step_spacing = step_spacing, - widget = wibox.widget.graph, - color = "linear:0,0:0,20:0,#FF0000:0.3,#FFFF00:0.6," .. color - } - - local cpu_rows = { - spacing = 4, - layout = wibox.layout.fixed.vertical, - } - - local is_update = true - local process_rows = { - -- spacing = 8, - layout = wibox.layout.fixed.vertical, - } - - local process_header = { - { - markup = 'PID', - forced_width = 40, - widget = wibox.widget.textbox - }, - { - markup = 'Name', - forced_width = 40, - widget = wibox.widget.textbox - }, - { - { - markup = '%CPU', - forced_width = 40, - widget = wibox.widget.textbox - }, - { - markup = '%MEM', - forced_width = 40, - widget = wibox.widget.textbox - }, - layout = wibox.layout.fixed.horizontal - }, - layout = wibox.layout.align.horizontal - } - - local popup = awful.popup{ - ontop = true, - visible = false, - shape = gears.shape.rounded_rect, - border_width = 1, - border_color = beautiful.bg_normal, - maximum_width = 300, - offset = { y = 5 }, - widget = {} - } - - popup:connect_signal("mouse::enter", function(c) is_update = false end) - popup:connect_signal("mouse::leave", function(c) is_update = true end) - - cpugraph_widget:buttons( - awful.util.table.join( - awful.button({}, 1, function() - if popup.visible then - --rows = nil - popup.visible = not popup.visible - else - --init_popup() - popup:move_next_to(mouse.current_widget_geometry) - end - end) - ) - ) - - --- By default graph widget goes from left to right, so we mirror it and push up a bit - local cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget, { horizontal = true }), 0, 0, 0, 2) - - local cpus = {} - watch([[bash -c "cat /proc/stat | grep '^cpu.' ; ps -eo '%p|%c|%C|' -o "%mem" -o '|%a' --sort=-%cpu | head -11 | tail -n +2"]], 1, - function(widget, stdout) - local i = 1 - local j = 1 - for line in stdout:gmatch("[^\r\n]+") do - if starts_with(line, 'cpu') then - - if cpus[i] == nil then cpus[i] = {} end - - local name, user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice = - line:match('(%w+)%s+(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)') - - local total = user + nice + system + idle + iowait + irq + softirq + steal - - local diff_idle = idle - tonumber(cpus[i]['idle_prev'] == nil and 0 or cpus[i]['idle_prev']) - local diff_total = total - tonumber(cpus[i]['total_prev'] == nil and 0 or cpus[i]['total_prev']) - local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10 - - cpus[i]['total_prev'] = total - cpus[i]['idle_prev'] = idle - - if i == 1 then - widget:add_value(diff_usage) - end - - local row = wibox.widget - { - { - text = name, - forced_width = 40, - widget = wibox.widget.textbox - }, - { - text = math.floor(diff_usage) .. '%', - forced_width = 40, - widget = wibox.widget.textbox - }, - { - max_value = 100, - value = diff_usage, - forced_height = 20, - forced_width = 150, - paddings = 1, - margins = 4, - border_width = 1, - border_color = beautiful.bg_focus, - background_color = beautiful.bg_normal, - bar_border_width = 1, - bar_border_color = beautiful.bg_focus, - color = "linear:150,0:0,0:0,#D08770:0.3,#BF616A:0.6," .. beautiful.fg_normal, - widget = wibox.widget.progressbar, - - }, - layout = wibox.layout.align.horizontal - } - - cpu_rows[i] = row - i = i + 1 - else - if is_update == true then - - local columns = split(line, '|') - - local pid = columns[1] - local comm = columns[2] - local cpu = columns[3] - local mem = columns[4] - local cmd = columns[5] - - local row = wibox.widget { - { - { - { - text = pid, - forced_width = 40, - widget = wibox.widget.textbox - }, - { - text = comm, - forced_width = 40, - widget = wibox.widget.textbox - }, - { - { - text = cpu, - forced_width = 40, - widget = wibox.widget.textbox - }, - { - text = mem, - forced_width = 40, - widget = wibox.widget.textbox - }, - layout = wibox.layout.align.horizontal - }, - layout = wibox.layout.align.horizontal - }, - top = 4, - bottom = 4, - widget = wibox.container.margin - }, - widget = wibox.container.background - } - - -- Do not update process rows when mouse cursor is over the widget - row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end) - row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end) - - awful.tooltip { - objects = { row }, - mode = 'outside', - preferred_positions = {'bottom'}, - timer_function = function() - return cmd - :gsub('%s%-', '\n\t-') -- put arguments on a new line - :gsub(':/', '\n\t\t:/') -- java classpath uses : to separate jars - end, - } - - process_rows[j] = row - - j = j + 1 - end - - end - end - popup:setup { - { - cpu_rows, - { - orientation = 'horizontal', - forced_height = 15, - color = beautiful.bg_focus, - widget = wibox.widget.separator - }, - process_header, - process_rows, - layout = wibox.layout.fixed.vertical, - }, - margins = 8, - widget = wibox.container.margin - } - end, - cpugraph_widget - ) - - return cpu_widget -end - -return setmetatable(widget, { __call = function(_, ...) - return worker(...) -end }) diff --git a/cpu-widget/cpu-widget-0.1.tar.gz b/cpu-widget/cpu-widget-0.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..9600f4944aa17392aba43615ee4f7f68264c850b GIT binary patch literal 2496 zcmV;x2|xB9iwFSwGp1eu1MOOEZ`(K$?&tgp!i8b`V#{`#m%_JR-0t=Y+=m_t91iy( zO$Az}ZKjf_l2qJmlmC7*l&m-FEy?aJ7N-YoOp(Lk%y3A~P;!EBvghk9)0P|3SHBBp zfXmBs{GDH2%(B0Lv-9)$)vNiN%ZvH>+4<$=)vMY3;_Bk+6`B1$;^Yx3O(h|(l$MNX z9ZK!8GPPq$1W;lFlbuZZ3; z;)GH%Uz@I><}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wXRZ1`aG!R0 z)20ig37IbEtw!;(%3R#EF~IQ|-C}!grf5&~G)hE#Ai~r&FT5{60hB zZKopQj!E;$Mng)B04`6t+;1!ce z&4U)Zk67J;Wa{vUZ%HtCY2gE&SYvKDfVHCdnzhK51Iac_O4y(Rp*U)6Zh{AqgAZDa zsksLkO7bnjvd!CyEaGn-Af$WJ*0k8-7ZQWM>Q4p`1%L8C>B(S(ZW_S80jnzXz;VC{ zeL{)P_U7*LIU_8l2mYTll+6&g^o|n8rAh@9c6IO^MHYDPAAdQ*fI_Oq(ZF@;?c1;> zvv1U|Zx4A(Z5O-(zpYGOVxh`el)X18tBc;$z>*28oV|Jp9I~)#v(zsiI2mBpY3zxE z^rUE53dI|e`9(eba})CNlRWv}s5)`2W}E-qp_#7UyzRfaXenZP%k#FJ;HgLBW3J|C z2^HRjnYK~xv#j(*Tl6v2;iD_2JqE6W?`M;DP2Y)agT`)lTeHW+vaH+(Tk!{2rW$yX z$I;0j{W)fb4jnpl=+L1I&|pJp+kob9XfRA(4j+z4jnqQ#(x1U KTTILVPyhfc+uK0^ literal 0 HcmV?d00001 diff --git a/cpu-widget/rockspec/cpu_widget-0.0.1-1.rockspec b/cpu-widget/rockspec/cpu-widget-0.1-1.rockspec similarity index 82% rename from cpu-widget/rockspec/cpu_widget-0.0.1-1.rockspec rename to cpu-widget/rockspec/cpu-widget-0.1-1.rockspec index 95c7cab..dcd2ec4 100644 --- a/cpu-widget/rockspec/cpu_widget-0.0.1-1.rockspec +++ b/cpu-widget/rockspec/cpu-widget-0.1-1.rockspec @@ -1,7 +1,7 @@ package = "cpu-widget" -version = "0.0.1" +version = "0.1-1" source = { - url = "https://github.com/streetturtle/awesome-wm-widgets/tree/rocks/cpu-widget/cpu-widget-0.0.1.tar.gz", + url = "https://github.com/streetturtle/awesome-wm-widgets/tree/rocks/cpu-widget/cpu-widget-0.1.tar.gz", } description = { summary = "CPU widget for Awesome Window Manager", @@ -20,6 +20,6 @@ dependencies = { build = { type = "builtin", modules = { - cpu-wodget = "cpu-widget.lua" + ["cpu-widget"] = "cpu-widget.lua" } } \ No newline at end of file diff --git a/cpu-widget/rockspec/cpu_widget.rockspec b/cpu-widget/rockspec/cpu_widget.rockspec deleted file mode 100644 index 6b201df..0000000 --- a/cpu-widget/rockspec/cpu_widget.rockspec +++ /dev/null @@ -1,26 +0,0 @@ -package = "cpu-widget" -version = "0.0.1" -source = { - url = "https://github.com/streetturtle/awesome-wm-widgets/tree/rocks/cpu-widget/cpu-widget-0.0.1.tar.gz" -} -description = { - summary = "CPU widget for Awesome Window Manager", - detailed = [[ - CPU widget for Awesome - Window Manager. - ]], - homepage = "https://github.com/streetturtle/awesome-wm-widgets/tree/master/cpu-widget", - license = "MIT" -} -supported_platforms = { - "linux" -} -dependencies = { - "lua >= 5.2" -} -build = { - type = "builtin", - modules = { - ["cpu-widget"] = "cpu-widget.lua" - } -} \ No newline at end of file