summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--batteryarc-widget/README.md2
-rw-r--r--cpu-widget/cpu-pngbin0 -> 90688 bytes
-rw-r--r--cpu-widget/cpu-widget.lua136
-rw-r--r--cpu-widget/cpu.gifbin4913 -> 261200 bytes
-rw-r--r--cpu-widget/out.gifbin3505 -> 0 bytes
-rw-r--r--jira-widget/jira.lua4
-rw-r--r--storage-widget/README.md24
-rw-r--r--storage-widget/out.gifbin0 -> 103946 bytes
-rw-r--r--storage-widget/storage-widget.lua156
-rw-r--r--volume-widget/volume.lua2
-rw-r--r--weather-widget/weather.lua4
11 files changed, 281 insertions, 47 deletions
diff --git a/batteryarc-widget/README.md b/batteryarc-widget/README.md
index 97f5bcc..de83f6e 100644
--- a/batteryarc-widget/README.md
+++ b/batteryarc-widget/README.md
@@ -50,7 +50,7 @@ s.mytasklist, -- Middle widget
--[[or customized]]
batteryarc_widget({
show_current_level = true,
- arc_thickness = '1',
+ arc_thickness = 1,
}),
}
...
diff --git a/cpu-widget/cpu-png b/cpu-widget/cpu-png
new file mode 100644
index 0000000..96ba29f
--- /dev/null
+++ b/cpu-widget/cpu-png
Binary files differ
diff --git a/cpu-widget/cpu-widget.lua b/cpu-widget/cpu-widget.lua
index d256147..7dfc5a7 100644
--- a/cpu-widget/cpu-widget.lua
+++ b/cpu-widget/cpu-widget.lua
@@ -16,6 +16,21 @@ 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 {}
@@ -36,17 +51,41 @@ local function worker(args)
}
local cpu_rows = {
- { widget = wibox.widget.textbox },
spacing = 4,
layout = wibox.layout.fixed.vertical,
-
}
+ local is_update = true
local process_rows = {
- { widget = wibox.widget.textbox },
- spacing = 4,
+ spacing = 8,
layout = wibox.layout.fixed.vertical,
+ }
+ local process_header = {
+ {
+ markup = '<b>PID</b>',
+ forced_width = 40,
+ widget = wibox.widget.textbox
+ },
+ {
+ markup = '<b>Name</b>',
+ forced_width = 40,
+ widget = wibox.widget.textbox
+ },
+ {
+ {
+ markup = '<b>%CPU</b>',
+ forced_width = 40,
+ widget = wibox.widget.textbox
+ },
+ {
+ markup = '<b>%MEM</b>',
+ forced_width = 40,
+ widget = wibox.widget.textbox
+ },
+ layout = wibox.layout.fixed.horizontal
+ },
+ layout = wibox.layout.align.horizontal
}
local popup = awful.popup{
@@ -60,6 +99,9 @@ local function worker(args)
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()
@@ -77,12 +119,8 @@ local function worker(args)
--- 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 function starts_with(str, start)
- return str:sub(1, #start) == start
- end
-
local cpus = {}
- watch([[bash -c "cat /proc/stat | grep '^cpu.' ; ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head"]], 1,
+ 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
@@ -141,56 +179,67 @@ local function worker(args)
cpu_rows[i] = row
i = i + 1
else
- local pid, cmd, cpu, mem = line:match('(%d+)%s+(%w+)%s+([%d.]+)%s+([%d.]+)')
-
- if pid == nil then
- pid = 'PID'
- cmd = 'Name'
- cpu = '%CPU'
- mem = '%MEM'
+ if is_update == true then
- end
+ 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 = cmd,
- forced_width = 40,
- widget = wibox.widget.textbox
- },
+ local row = wibox.widget {
{
{
- text = cpu,
+ text = pid,
forced_width = 40,
widget = wibox.widget.textbox
},
{
- text = mem,
+ 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
},
- layout = wibox.layout.align.horizontal
- },
- widget = wibox.container.background
- }
-
- 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)
-
-
- process_rows[j] = row
+ 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
- j = j + 1
end
-
end
popup:setup {
{
@@ -201,6 +250,7 @@ local function worker(args)
color = beautiful.bg_focus,
widget = wibox.widget.separator
},
+ process_header,
process_rows,
layout = wibox.layout.fixed.vertical,
},
diff --git a/cpu-widget/cpu.gif b/cpu-widget/cpu.gif
index 086e618..cb97262 100644
--- a/cpu-widget/cpu.gif
+++ b/cpu-widget/cpu.gif
Binary files differ
diff --git a/cpu-widget/out.gif b/cpu-widget/out.gif
deleted file mode 100644
index ac7542d..0000000
--- a/cpu-widget/out.gif
+++ /dev/null
Binary files differ
diff --git a/jira-widget/jira.lua b/jira-widget/jira.lua
index 652767a..b876c0b 100644
--- a/jira-widget/jira.lua
+++ b/jira-widget/jira.lua
@@ -97,13 +97,13 @@ local function worker(args)
for i = 0, #rows do rows[i]=nil end
for _, issue in ipairs(result.issues) do
- local path_to_avatar = os.getenv("HOME") ..'/.cache/awmw/jira-widget/avatars/' .. issue.fields.assignee.key
+ local path_to_avatar = os.getenv("HOME") ..'/.cache/awmw/jira-widget/avatars/' .. issue.fields.assignee.accountId
if not gfs.file_readable(path_to_avatar) then
spawn.easy_async(string.format(
DOWNLOAD_AVATAR_CMD,
HOME_DIR,
- issue.fields.assignee.key,
+ issue.fields.assignee.accountId,
issue.fields.assignee.avatarUrls['48x48']))
end
diff --git a/storage-widget/README.md b/storage-widget/README.md
new file mode 100644
index 0000000..48d2ffe
--- /dev/null
+++ b/storage-widget/README.md
@@ -0,0 +1,24 @@
+# Storage Widget
+
+This widget shows disk usage. When clicked another widget appears with more detailed information. By default it monitors the "/" mount. It can be configured with a
+list of mounts to monitor though only the first will show in the wibar. To have
+multiple mounts displayed on the wibar simply define multiple `storage_widgets`
+with different mounts as arguments.
+
+
+```lua
+ local storage_widget = require("awesome-wm-widgets.storage-widget.storage-widget")
+ ...
+ s.mywibox:setup {
+ s.mytasklist, -- Middle widget
+ { -- Right widgets
+ storage_widget(), --default
+ wibox.widget.textbox(':'),
+ storage_widget({ mounts = { '/', '/mnt/musicj' } }), -- multiple mounts
+ ...
+
+```
+
+## Installation
+
+Please refer to the [installation](https://github.com/streetturtle/awesome-wm-widgets#installation) section of the repo.
diff --git a/storage-widget/out.gif b/storage-widget/out.gif
new file mode 100644
index 0000000..736f894
--- /dev/null
+++ b/storage-widget/out.gif
Binary files differ
diff --git a/storage-widget/storage-widget.lua b/storage-widget/storage-widget.lua
new file mode 100644
index 0000000..d719f60
--- /dev/null
+++ b/storage-widget/storage-widget.lua
@@ -0,0 +1,156 @@
+local awful = require("awful")
+local watch = require("awful.widget.watch")
+local wibox = require("wibox")
+local beautiful = require("beautiful")
+local gears = require("gears")
+
+local storage_graph_widget = {}
+
+local function worker(args)
+ local args = args or {}
+ local mounts = args.mounts or {'/'}
+
+ storage_graph_widget = wibox.widget {
+ max_value = 100,
+ forced_height = 20,
+ forced_width = 35,
+ paddings = 1,
+ margins = 4,
+ border_width = 0.5,
+ border_color = beautiful.fg_normal,
+ background_color = beautiful.bg_normal,
+ bar_border_width = 1,
+ bar_border_color = beautiful.bg_focus,
+ color = "linear:150,0:0,0:0,"
+ .. beautiful.fg_normal
+ .. ":0.3," .. beautiful.bg_urgent .. ":0.6,"
+ .. beautiful.fg_normal,
+ widget = wibox.widget.progressbar,
+ }
+
+ local disk_rows = {
+ { widget = wibox.widget.textbox },
+ spacing = 4,
+ layout = wibox.layout.fixed.vertical,
+ }
+
+ local disk_header = {
+ {
+ markup = '<b>Mount</b>',
+ forced_width = 150,
+ align = 'left',
+ widget = wibox.widget.textbox,
+ },
+ {
+ markup = '<b>Used</b>',
+ align = 'left',
+ widget = wibox.widget.textbox,
+ },
+ 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,
+ bg = beautiful.bg_focus,
+ maximum_width = 400,
+ 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)
+
+ storage_graph_widget:buttons(
+ awful.util.table.join(
+ awful.button({}, 1, function()
+ if popup.visible then
+ popup.visible = not popup.visible
+ else
+ popup:move_next_to(mouse.current_widget_geometry)
+ end
+ end)
+ )
+ )
+
+ local disk_widget = wibox.container.margin(wibox.container.mirror(storage_graph_widget, { horizontal = true }), 0, 0, 0, 2)
+
+ local disks = {}
+ watch([[bash -c "df | tail -n +2"]], 60,
+ function(widget, stdout)
+ for line in stdout:gmatch("[^\r\n$]+") do
+ local filesystem, size, used, avail, perc, mount =
+ line:match('([%p%w]+)%s+([%d%w]+)%s+([%d%w]+)%s+([%d%w]+)%s+([%d]+)%%%s+([%p%w]+)')
+
+ disks[mount] = {}
+ disks[mount].filesystem = filesystem
+ disks[mount].size = size
+ disks[mount].used = used
+ disks[mount].avail = avail
+ disks[mount].perc = perc
+ disks[mount].mount = mount
+
+ if disks[mount].mount == mounts[1] then
+ widget.value = tonumber(disks[mount].perc)
+ end
+ end
+
+ for k,v in ipairs(mounts) do
+
+ local row = wibox.widget{
+ {
+ text = disks[v].mount,
+ forced_width = 150,
+ widget = wibox.widget.textbox
+ },
+ {
+ max_value = 100,
+ value = tonumber(disks[v].perc),
+ forced_height = 20,
+ 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,"
+ .. beautiful.fg_normal
+ .. ":0.3," .. beautiful.bg_urgent .. ":0.6,"
+ .. beautiful.fg_normal,
+ widget = wibox.widget.progressbar,
+
+ },
+ {
+ text = math.floor(disks[v].used/1024/1024)
+ .. '/'
+ .. math.floor(disks[v].size/1024/1024) .. 'GB('
+ .. math.floor(disks[v].perc) .. '%)',
+ widget = wibox.widget.textbox
+ },
+ layout = wibox.layout.align.horizontal
+ }
+
+ disk_rows[k] = row
+ end
+ popup:setup {
+ {
+ disk_header,
+ disk_rows,
+ layout = wibox.layout.fixed.vertical,
+ },
+ margins = 8,
+ widget = wibox.container.margin
+ }
+ end,
+ storage_graph_widget
+ )
+
+ return disk_widget
+end
+
+return setmetatable(storage_graph_widget, { __call = function(_, ...)
+ return worker(...)
+end })
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index b2748e1..749f1f6 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -57,7 +57,7 @@ local function worker(args)
end
}
- local notification = {}
+ local notification
local volume_icon_name="audio-volume-high-symbolic"
local function get_notification_text(txt)
diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua
index a1075f6..6fafa97 100644
--- a/weather-widget/weather.lua
+++ b/weather-widget/weather.lua
@@ -144,6 +144,8 @@ local function worker(args)
end
local function error_display(resp_json)
+ weather_timer.timeout = math.min(15 * 60, weather_timer.timeout * 2)
+ weather_timer:again()
local err_resp = json.decode(resp_json)
naughty.notify{
title = 'Weather Widget Error',
@@ -185,6 +187,8 @@ local function worker(args)
resp = json.decode(resp_json)
icon_widget.image = path_to_icons .. icon_map[resp.weather[1].icon]
temp_widget:set_text(gen_temperature_str(resp.main.temp, '%.0f', both_units_widget))
+ weather_timer.timeout = 60
+ weather_timer:again()
end
end)
weather_timer:start()