From 8be78d4fddfc2c88352b25f5d8d89c6dc14df37c Mon Sep 17 00:00:00 2001 From: streetturtle Date: Wed, 2 Dec 2020 09:18:16 -0500 Subject: fix few issues --- todo-widget/todo.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'todo-widget') diff --git a/todo-widget/todo.lua b/todo-widget/todo.lua index 71484b2..71bf832 100644 --- a/todo-widget/todo.lua +++ b/todo-widget/todo.lua @@ -200,7 +200,7 @@ local function worker(args) widget = wibox.container.background } - trash_button:connect_signal("button::press", function(c) + trash_button:connect_signal("button::press", function() table.remove(result.todo_items, i) spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function () spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end) @@ -214,7 +214,7 @@ local function worker(args) widget = wibox.widget.imagebox } - move_up:connect_signal("button::press", function(c) + move_up:connect_signal("button::press", function() local temp = result.todo_items[i] result.todo_items[i] = result.todo_items[i-1] result.todo_items[i-1] = temp -- cgit v1.2.3 From e3d3e07af3a18331711e897d9928701d9ac21839 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Wed, 2 Dec 2020 09:24:05 -0500 Subject: trigger build action on a branch --- todo-widget/todo.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'todo-widget') diff --git a/todo-widget/todo.lua b/todo-widget/todo.lua index 71bf832..ecbb464 100644 --- a/todo-widget/todo.lua +++ b/todo-widget/todo.lua @@ -89,7 +89,7 @@ local add_button = wibox.widget { widget = wibox.container.background } -add_button:connect_signal("button::press", function(c) +add_button:connect_signal("button::press", function() local pr = awful.widget.prompt() table.insert(rows, wibox.widget { -- cgit v1.2.3 From d9eb3885eea90e06b79ff8fc4b2d1c1b8f5e4cfd Mon Sep 17 00:00:00 2001 From: streetturtle Date: Wed, 2 Dec 2020 09:24:05 -0500 Subject: trigger build action on a branch --- bitbucket-widget/bitbucket.lua | 44 ++++++++++++++++++---------------- cpu-widget/cpu-widget.lua | 13 ++++++---- jira-widget/jira.lua | 12 +++++----- run-shell-3/run-shell.lua | 2 +- spotify-widget/spotify.lua | 7 +++--- stackoverflow-widget/stackoverflow.lua | 14 ++++++----- todo-widget/todo.lua | 10 ++++---- translate-widget/translate.lua | 13 ++++++---- volume-widget/volume.lua | 18 +++++++++----- volumearc-widget/volumearc.lua | 6 ++--- volumebar-widget/volumebar.lua | 6 ++--- weather-widget/weather.lua | 18 ++++++++------ 12 files changed, 92 insertions(+), 71 deletions(-) (limited to 'todo-widget') diff --git a/bitbucket-widget/bitbucket.lua b/bitbucket-widget/bitbucket.lua index 8d47f2f..b85e653 100644 --- a/bitbucket-widget/bitbucket.lua +++ b/bitbucket-widget/bitbucket.lua @@ -21,7 +21,12 @@ local gfs = require("gears.filesystem") local HOME_DIR = os.getenv("HOME") local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/bitbucket-widget/' -local GET_PRS_CMD= [[bash -c "curl -s --show-error -n '%s/2.0/repositories/%s/%s/pullrequests?fields=values.participants.approved,values.title,values.links.html,values.author.display_name,values.author.uuid,values.author.links.avatar,values.source.branch,values.destination.branch,values.comment_count,values.created_on&q=reviewers.uuid+%%3D+%%22%s%%22+AND+state+%%3D+%%22OPEN%%22' | jq '.[] '"]] +local GET_PRS_CMD= [[bash -c "curl -s --show-error -n ]] + .. [['%s/2.0/repositories/%s/%s/pullrequests]] + .. [[?fields=values.participants.approved,values.title,values.links.html,values.author.display_name,]] + .. [[values.author.uuid,values.author.links.avatar,values.source.branch,values.destination.branch,]] + .. [[values.comment_count,values.created_on&q=reviewers.uuid+%%3D+%%22%s%%22+AND+state+%%3D+%%22OPEN%%22']] + .. [[ | jq '.[] '"]] local DOWNLOAD_AVATAR_CMD = [[bash -c "curl -L -n --create-dirs -o %s/.cache/awmw/bitbucket-widget/avatars/%s %s"]] local bitbucket_widget = wibox.widget { @@ -71,7 +76,7 @@ local popup = awful.popup{ --- Converts string representation of date (2020-06-02T11:25:27Z) to date local function parse_date(date_str) local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)%Z" - local y, m, d, h, min, sec, mil = date_str:match(pattern) + local y, m, d, h, min, sec, _ = date_str:match(pattern) return os.time{year = y, month = m, day = d, hour = h, min = min, sec = sec} end @@ -111,9 +116,9 @@ local function count_approves(participants) return res end -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icon or WIDGET_DIR .. '/bitbucket-icon-gradient-blue.svg' local host = args.host or show_warning('Bitbucket host is not set') @@ -279,11 +284,8 @@ local function worker(args) } if not gfs.file_readable(path_to_avatar) then - spawn.easy_async(string.format( - DOWNLOAD_AVATAR_CMD, - HOME_DIR, - pr.author.uuid, - pr.author.links.avatar.href), function() row:get_children_by_id('avatar')[1]:set_image(path_to_avatar) end) + local cmd = string.format(DOWNLOAD_AVATAR_CMD, HOME_DIR, pr.author.uuid, pr.author.links.avatar.href) + spawn.easy_async(cmd, function() row:get_children_by_id('avatar')[1]:set_image(path_to_avatar) end) end @@ -299,34 +301,36 @@ local function worker(args) ) ) row:get_children_by_id('avatar')[1]:buttons( - awful.util.table.join( - awful.button({}, 1, function() - spawn.with_shell(string.format('xdg-open "https://bitbucket.org/%s/%s/pull-requests?state=OPEN&author=%s"', workspace, repo_slug, pr.author.uuid)) - popup.visible = false - end) - ) + awful.util.table.join( + awful.button({}, 1, function() + spawn.with_shell( + string.format('xdg-open "https://bitbucket.org/%s/%s/pull-requests?state=OPEN&author=%s"', + workspace, repo_slug, pr.author.uuid) + ) + popup.visible = false + end) + ) ) local old_cursor, old_wibox - row:get_children_by_id('title')[1]:connect_signal("mouse::enter", function(c) + row:get_children_by_id('title')[1]:connect_signal("mouse::enter", function() local wb = mouse.current_wibox old_cursor, old_wibox = wb.cursor, wb wb.cursor = "hand1" end) - row:get_children_by_id('title')[1]:connect_signal("mouse::leave", function(c) + row:get_children_by_id('title')[1]:connect_signal("mouse::leave", function() if old_wibox then old_wibox.cursor = old_cursor old_wibox = nil end end) - local old_cursor, old_wibox - row:get_children_by_id('avatar')[1]:connect_signal("mouse::enter", function(c) + row:get_children_by_id('avatar')[1]:connect_signal("mouse::enter", function() local wb = mouse.current_wibox old_cursor, old_wibox = wb.cursor, wb wb.cursor = "hand1" end) - row:get_children_by_id('avatar')[1]:connect_signal("mouse::leave", function(c) + row:get_children_by_id('avatar')[1]:connect_signal("mouse::leave", function() if old_wibox then old_wibox.cursor = old_cursor old_wibox = nil diff --git a/cpu-widget/cpu-widget.lua b/cpu-widget/cpu-widget.lua index 54547ae..f58f960 100644 --- a/cpu-widget/cpu-widget.lua +++ b/cpu-widget/cpu-widget.lua @@ -14,6 +14,9 @@ local wibox = require("wibox") local beautiful = require("beautiful") local gears = require("gears") +local CMD = [[sh -c "grep '^cpu.' /proc/stat; ps -eo '%p|%c|%C|' -o "%mem" -o '|%a' --sort=-%cpu ]] + .. [[| head -11 | tail -n +2"]] + local HOME_DIR = os.getenv("HOME") local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/cpu-widget' @@ -86,9 +89,9 @@ local function create_kill_process_button() } end -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local width = args.width or 50 local step_width = args.step_width or 2 @@ -120,8 +123,8 @@ local function worker(args) } -- Do not update process rows when mouse cursor is over the widget - popup:connect_signal("mouse::enter", function(c) is_update = false end) - popup:connect_signal("mouse::leave", function(c) is_update = true end) + popup:connect_signal("mouse::enter", function() is_update = false end) + popup:connect_signal("mouse::leave", function() is_update = true end) cpugraph_widget:buttons( awful.util.table.join( @@ -139,7 +142,7 @@ local function worker(args) local cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget, { horizontal = true }), 0, 0, 0, 2) local cpus = {} - watch([[sh -c "grep '^cpu.' /proc/stat; ps -eo '%p|%c|%C|' -o "%mem" -o '|%a' --sort=-%cpu | head -11 | tail -n +2"]], timeout, + watch(CMD, timeout, function(widget, stdout) local i = 1 local j = 1 diff --git a/jira-widget/jira.lua b/jira-widget/jira.lua index 7f0ceb6..9a89a0d 100644 --- a/jira-widget/jira.lua +++ b/jira-widget/jira.lua @@ -17,12 +17,12 @@ local naughty = require("naughty") local gears = require("gears") local beautiful = require("beautiful") local gfs = require("gears.filesystem") -local gs = require("gears.string") local color = require("gears.color") local HOME_DIR = os.getenv("HOME") -local GET_ISSUES_CMD = [[bash -c "curl -s --show-error -X GET -n '%s/rest/api/2/search?%s&fields=id,assignee,summary,status'"]] +local GET_ISSUES_CMD = + [[bash -c "curl -s --show-error -X GET -n '%s/rest/api/2/search?%s&fields=id,assignee,summary,status'"]] local DOWNLOAD_AVATAR_CMD = [[bash -c "curl -n --create-dirs -o %s/.cache/awmw/jira-widget/avatars/%s %s"]] local function show_warning(message) @@ -41,7 +41,7 @@ local jira_widget = wibox.widget { }, { id = 'd', - draw = function(self, context, cr, width, height) + draw = function(_, _, cr, _, height) cr:set_source(color(beautiful.fg_urgent)) cr:arc(height/4, height/4, height/4, 0, math.pi*2) cr:fill() @@ -100,9 +100,9 @@ local tooltip = awful.tooltip { preferred_positions = {'bottom'}, } -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icon or HOME_DIR .. '/.config/awesome/awesome-wm-widgets/jira-widget/jira-mark-gradient-blue.svg' local host = args.host or show_warning('Jira host is unknown') @@ -149,7 +149,7 @@ 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.accountId + local path_to_avatar = HOME_DIR ..'/.cache/awmw/jira-widget/avatars/' .. issue.fields.assignee.accountId if not gfs.file_readable(path_to_avatar) then spawn.easy_async(string.format( diff --git a/run-shell-3/run-shell.lua b/run-shell-3/run-shell.lua index 9bd575b..51feaf4 100644 --- a/run-shell-3/run-shell.lua +++ b/run-shell-3/run-shell.lua @@ -89,7 +89,7 @@ function widget.new() local w = self._cached_wiboxes[s][1] local rnd = math.random() awful.spawn.with_line_callback(string.format(self._cmd_blur, tostring(awful.screen.focused().geometry.x), rnd), { - stdout = function(line) + stdout = function() w.visible = true w.bgimage = '/tmp/i3lock-' .. rnd ..'.png' awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() }) diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua index fb903e8..bd2309f 100644 --- a/spotify-widget/spotify.lua +++ b/spotify-widget/spotify.lua @@ -11,7 +11,6 @@ local awful = require("awful") local wibox = require("wibox") local watch = require("awful.widget.watch") -local naughty = require("naughty") local GET_SPOTIFY_STATUS_CMD = 'sp status' local GET_CURRENT_SONG_CMD = 'sp current' @@ -24,9 +23,9 @@ end local spotify_widget = {} -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local play_icon = args.play_icon or '/usr/share/icons/Arc/actions/24/player_play.png' local pause_icon = args.pause_icon or '/usr/share/icons/Arc/actions/24/player_pause.png' @@ -100,7 +99,7 @@ local function worker(args) end local escaped = string.gsub(stdout, "&", '&') - local album, album_artist, artist, title = + local album, _, artist, title = string.match(escaped, 'Album%s*(.*)\nAlbumArtist%s*(.*)\nArtist%s*(.*)\nTitle%s*(.*)\n') if album ~= nil and title ~=nil and artist ~= nil then diff --git a/stackoverflow-widget/stackoverflow.lua b/stackoverflow-widget/stackoverflow.lua index af89105..15d2837 100644 --- a/stackoverflow-widget/stackoverflow.lua +++ b/stackoverflow-widget/stackoverflow.lua @@ -18,13 +18,15 @@ local beautiful = require("beautiful") local HOME_DIR = os.getenv("HOME") -local GET_QUESTIONS_CMD = [[bash -c "curl --compressed -s -X GET 'http://api.stackexchange.com/2.2/questions/no-answers?page=1&pagesize=%s&order=desc&sort=activity&tagged=%s&site=stackoverflow'"]] +local GET_QUESTIONS_CMD = [[bash -c "curl --compressed -s -X GET]] + .. [[ 'http://api.stackexchange.com/2.2/questions/no-answers]] + .. [[?page=1&pagesize=%s&order=desc&sort=activity&tagged=%s&site=stackoverflow'"]] local stackoverflow_widget = {} -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icon or HOME_DIR .. '/.config/awesome/awesome-wm-widgets/stackoverflow-widget/so-icon.svg' local limit = args.limit or 5 @@ -43,7 +45,7 @@ local function worker(args) border_width = 1, border_color = beautiful.bg_focus, maximum_width = 400, - preferred_positions = top, + preferred_positions = 'top', offset = { y = 5 }, widget = {} } @@ -63,7 +65,7 @@ local function worker(args) end, } - local update_widget = function(widget, stdout, stderr, _, _) + local update_widget = function(_, stdout, _, _, _) local result = json.decode(stdout) @@ -91,7 +93,7 @@ local function worker(args) widget = wibox.container.background } - row:connect_signal("button::release", function(_, _, _, button) + row:connect_signal("button::release", function() spawn.with_shell("xdg-open " .. item.link) popup.visible = false end) diff --git a/todo-widget/todo.lua b/todo-widget/todo.lua index ecbb464..14e3dc2 100644 --- a/todo-widget/todo.lua +++ b/todo-widget/todo.lua @@ -11,7 +11,6 @@ local awful = require("awful") local wibox = require("wibox") local json = require("json") local spawn = require("awful.spawn") -local naughty = require("naughty") local gears = require("gears") local beautiful = require("beautiful") local gfs = require("gears.filesystem") @@ -126,9 +125,9 @@ end) add_button:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end) add_button:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end) -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icon or WIDGET_DIR .. '/checkbox-checked-symbolic.svg' @@ -229,7 +228,7 @@ local function worker(args) widget = wibox.widget.imagebox } - move_down:connect_signal("button::press", function(c) + move_down:connect_signal("button::press", function() local temp = result.todo_items[i] result.todo_items[i] = result.todo_items[i+1] result.todo_items[i+1] = temp @@ -322,7 +321,8 @@ local function worker(args) end if not gfs.file_readable(STORAGE) then - spawn.easy_async(string.format([[bash -c "dirname %s | xargs mkdir -p && echo '{\"todo_items\":{}}' > %s"]], STORAGE, STORAGE)) + spawn.easy_async(string.format([[bash -c "dirname %s | xargs mkdir -p && echo '{\"todo_items\":{}}' > %s"]], + STORAGE, STORAGE)) end return setmetatable(todo_widget, { __call = function(_, ...) return worker(...) end }) diff --git a/translate-widget/translate.lua b/translate-widget/translate.lua index 811e136..1499333 100644 --- a/translate-widget/translate.lua +++ b/translate-widget/translate.lua @@ -16,7 +16,8 @@ local wibox = require("wibox") local gears = require("gears") local gfs = require("gears.filesystem") -local TRANSLATE_CMD = [[bash -c 'curl -s -u "apikey:%s" -H "Content-Type: application/json" -d '\''{"text": ["%s"], "model_id":"%s"}'\'' "%s/v3/translate?version=2018-05-01"']] +local TRANSLATE_CMD = [[bash -c 'curl -s -u "apikey:%s" -H "Content-Type: application/json"]] + ..[[ -d '\''{"text": ["%s"], "model_id":"%s"}'\'' "%s/v3/translate?version=2018-05-01"']] local ICON = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/translate-widget/gnome-translate.svg' --- Returns two values - string to translate and direction: @@ -82,12 +83,14 @@ local function translate(to_translate, lang, api_key, url) { { id = 'src', - markup = '' .. lang:sub(1,2) .. ': ' .. to_translate .. '', + markup = '' .. lang:sub(1,2) .. ': ' + .. to_translate .. '', widget = wibox.widget.textbox }, { id = 'res', - markup = '' .. lang:sub(4) .. ': ' .. resp.translations[1].translation .. '', + markup = '' .. lang:sub(4) .. ': ' + .. resp.translations[1].translation .. '', widget = wibox.widget.textbox }, id = 'text', @@ -110,11 +113,11 @@ local function translate(to_translate, lang, api_key, url) w:buttons( awful.util.table.join( awful.button({}, 1, function() - awful.spawn.with_shell("echo '" .. resp.translations[1].translation .. "' | xclip -selection clipboard") + spawn.with_shell("echo '" .. resp.translations[1].translation .. "' | xclip -selection clipboard") w.visible = false end), awful.button({}, 3, function() - awful.spawn.with_shell("echo '" .. to_translate .."' | xclip -selection clipboard") + spawn.with_shell("echo '" .. to_translate .."' | xclip -selection clipboard") w.visible = false end) ) diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 86d2e4c..cb8c21d 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -9,7 +9,6 @@ ------------------------------------------------- local wibox = require("wibox") -local watch = require("awful.widget.watch") local spawn = require("awful.spawn") local naughty = require("naughty") local gfs = require("gears.filesystem") @@ -19,7 +18,13 @@ local PATH_TO_ICONS = "/usr/share/icons/Arc/status/symbolic/" local volume_icon_name="audio-volume-high-symbolic" local GET_VOLUME_CMD = 'amixer sget Master' -local volume = {device = '', display_notification = false, display_notification_onClick = true, notification = nil, delta = 5} +local volume = { + device = '', + display_notification = false, + display_notification_onClick = true, + notification = nil, + delta = 5 +} function volume:toggle() volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle') @@ -88,9 +93,9 @@ end --}}} -local function worker(args) +local function worker(user_args) --{{{ Args - local args = args or {} + local args = user_args or {} local volume_audio_controller = args.volume_audio_controller or 'pulse' volume.display_notification = args.display_notification or false @@ -120,7 +125,8 @@ local function worker(args) resize = false, widget = wibox.widget.imagebox, }, - layout = wibox.container.margin(_, _, _, 3), + margins = 3, + layout = wibox.container.margin, set_image = function(self, path) self.icon.image = path end @@ -136,7 +142,7 @@ local function worker(args) local function show() spawn.easy_async(GET_VOLUME_CMD, function(stdout, _, _, _) - txt = parse_output(stdout) + local txt = parse_output(stdout) notif(txt, true) end ) diff --git a/volumearc-widget/volumearc.lua b/volumearc-widget/volumearc.lua index 91ae763..323a750 100644 --- a/volumearc-widget/volumearc.lua +++ b/volumearc-widget/volumearc.lua @@ -23,9 +23,9 @@ local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/audio-volume-muted-sy local widget = {} -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local main_color = args.main_color or beautiful.fg_color local bg_color = args.bg_color or '#ffffff11' @@ -59,7 +59,7 @@ local function worker(args) widget = wibox.container.arcchart } - local update_graphic = function(widget, stdout, _, _, _) + local update_graphic = function(_, stdout, _, _, _) local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off] local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%) volume = tonumber(string.format("% 3d", volume)) diff --git a/volumebar-widget/volumebar.lua b/volumebar-widget/volumebar.lua index 19238de..e7ee64d 100644 --- a/volumebar-widget/volumebar.lua +++ b/volumebar-widget/volumebar.lua @@ -22,9 +22,9 @@ local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle' local widget = {} -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local main_color = args.main_color or beautiful.fg_normal local mute_color = args.mute_color or beautiful.fg_urgent @@ -52,7 +52,7 @@ local function worker(args) widget = wibox.widget.progressbar } - local update_graphic = function(widget, stdout, _, _, _) + local update_graphic = function(_, stdout, _, _, _) local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off] local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%) volume = tonumber(string.format("% 3d", volume)) diff --git a/weather-widget/weather.lua b/weather-widget/weather.lua index 681e122..e58efb1 100644 --- a/weather-widget/weather.lua +++ b/weather-widget/weather.lua @@ -138,6 +138,7 @@ local function worker(user_args) local icons_extension = args.icons_extension or '.png' local timeout = args.timeout or 120 + local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' local owm_one_cal_api = ('https://api.openweathermap.org/data/2.5/onecall' .. '?lat=' .. coordinates[1] .. '&lon=' .. coordinates[2] .. '&appid=' .. api_key .. @@ -240,11 +241,14 @@ local function worker(user_args) forced_width = 300, layout = wibox.layout.flex.horizontal, update = function(self, weather) - self:get_children_by_id('icon')[1]:set_image(WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' .. icon_map[weather.weather[1].icon] .. icons_extension) + self:get_children_by_id('icon')[1]:set_image( + ICONS_DIR .. icon_map[weather.weather[1].icon] .. icons_extension) self:get_children_by_id('temp')[1]:set_text(gen_temperature_str(weather.temp, '%.0f', false, units)) - self:get_children_by_id('feels_like_temp')[1]:set_text('Feels like ' .. gen_temperature_str(weather.feels_like, '%.0f', false, units)) + self:get_children_by_id('feels_like_temp')[1]:set_text( + 'Feels like ' .. gen_temperature_str(weather.feels_like, '%.0f', false, units)) self:get_children_by_id('description')[1]:set_text(weather.weather[1].description) - self:get_children_by_id('wind')[1]:set_markup('Wind: ' .. weather.wind_speed .. 'm/s (' .. to_direction(weather.wind_deg) .. ')') + self:get_children_by_id('wind')[1]:set_markup( + 'Wind: ' .. weather.wind_speed .. 'm/s (' .. to_direction(weather.wind_deg) .. ')') self:get_children_by_id('humidity')[1]:set_markup('Humidity: ' .. weather.humidity .. '%') self:get_children_by_id('uv')[1]:set_markup('UV: ' .. uvi_index_color(weather.uvi)) end @@ -269,7 +273,7 @@ local function worker(user_args) { { { - image = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' .. icon_map[day.weather[1].icon] .. icons_extension, + image = ICONS_DIR .. icon_map[day.weather[1].icon] .. icons_extension, resize = true, forced_width = 48, forced_height = 48, @@ -470,8 +474,8 @@ local function worker(user_args) if stderr ~= '' then if not warning_shown then if (stderr ~= 'curl: (52) Empty reply from server' - and stderr ~= 'curl: (28) Failed to connect to api.openweathermap.org port 443: Connection timed out' - and stderr:find('^curl: %(18%) transfer closed with %d+ bytes remaining to read$') ~= nil + and stderr ~= 'curl: (28) Failed to connect to api.openweathermap.org port 443: Connection timed out' + and stderr:find('^curl: %(18%) transfer closed with %d+ bytes remaining to read$') ~= nil ) then show_warning(stderr) end @@ -490,7 +494,7 @@ local function worker(user_args) local result = json.decode(stdout) - widget:set_image(WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/' .. icon_map[result.current.weather[1].icon] .. icons_extension) + widget:set_image(ICONS_DIR .. icon_map[result.current.weather[1].icon] .. icons_extension) widget:set_text(gen_temperature_str(result.current.temp, '%.0f', both_units_widget, units)) current_weather_widget:update(result.current) -- cgit v1.2.3 From a0cd854a4d36167456bb28d255bf96a32321bf2a Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 5 Dec 2020 20:57:04 -0500 Subject: fix more warnings --- docker-widget/docker.lua | 35 ++++++++++++---------- experiments/volume/widgets/icon-widget.lua | 2 +- fs-widget/fs-widget.lua | 4 +-- gerrit-widget/gerrit.lua | 4 +-- .../github-contributions-widget.lua | 17 ++++++----- gitlab-widget/gitlab.lua | 26 ++++++++-------- logout-widget/logout.lua | 7 +++-- mpdarc-widget/mpdarc.lua | 6 ++-- mpris-widget/init.lua | 4 +-- net-speed-widget/net-speed.lua | 20 ++++--------- pomodoroarc-widget/pomodoroarc.lua | 4 +-- ram-widget/ram-widget.lua | 9 +++--- rhythmbox-widget/rhythmbox.lua | 16 ---------- run-shell-3/run-shell.lua | 21 +++++-------- run-shell/run-shell.lua | 1 + todo-widget/todo.lua | 18 +++++------ 16 files changed, 87 insertions(+), 107 deletions(-) delete mode 100644 rhythmbox-widget/rhythmbox.lua (limited to 'todo-widget') diff --git a/docker-widget/docker.lua b/docker-widget/docker.lua index 5bd5746..6dd2e61 100644 --- a/docker-widget/docker.lua +++ b/docker-widget/docker.lua @@ -19,7 +19,8 @@ local HOME_DIR = os.getenv("HOME") local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/docker-widget' local ICONS_DIR = WIDGET_DIR .. '/icons/' -local LIST_CONTAINERS_CMD = [[bash -c "docker container ls -a -s -n %s --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}::{{.Size}}'"]] +local LIST_CONTAINERS_CMD = [[bash -c "docker container ls -a -s -n %s]] + .. [[ --format '{{.Names}}::{{.ID}}::{{.Image}}::{{.Status}}::{{.Size}}'"]] --- Utility function to show warning messages local function show_warning(message) @@ -83,9 +84,9 @@ local status_to_icon_name = { Paused = ICONS_DIR .. 'pause.svg' } -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icon or ICONS_DIR .. 'docker.svg' local number_of_containers = args.number_of_containers or -1 @@ -163,10 +164,12 @@ local function worker(args) status_icon:set_opacity(0.2) status_icon:emit_signal('widget::redraw_needed') - spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function(stdout, stderr) + spawn.easy_async('docker ' .. command .. ' ' .. container['name'], function() if stderr ~= '' then show_warning(stderr) end - spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr) - rebuild_widget(stdout, stderr) end) + spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), + function(stdout, stderr) + rebuild_widget(stdout, stderr) + end) end) end) ) ) else @@ -250,11 +253,12 @@ local function worker(args) } delete_button:buttons( awful.util.table.join( awful.button({}, 1, function() - awful.spawn.easy_async('docker rm ' .. container['name'], function(stdout, stderr) - if stderr ~= '' then show_warning(stderr) end - spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr) - rebuild_widget(stdout, stderr) end) - end) + awful.spawn.easy_async('docker rm ' .. container['name'], function(_, rm_stderr) + if rm_stderr ~= '' then show_warning(rm_stderr) end + spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), + function(lc_stdout, lc_stderr) + rebuild_widget(lc_stdout, lc_stderr) end) + end) end))) local old_cursor, old_wibox @@ -350,10 +354,11 @@ local function worker(args) if popup.visible then popup.visible = not popup.visible else - spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), function(stdout, stderr) - rebuild_widget(stdout, stderr) - popup:move_next_to(mouse.current_widget_geometry) - end) + spawn.easy_async(string.format(LIST_CONTAINERS_CMD, number_of_containers), + function(stdout, stderr) + rebuild_widget(stdout, stderr) + popup:move_next_to(mouse.current_widget_geometry) + end) end end) ) diff --git a/experiments/volume/widgets/icon-widget.lua b/experiments/volume/widgets/icon-widget.lua index 2a20dde..ac4122c 100644 --- a/experiments/volume/widgets/icon-widget.lua +++ b/experiments/volume/widgets/icon-widget.lua @@ -15,7 +15,7 @@ function widget.get_widget() valign = 'center', layout = wibox.container.place, set_volume_level = function(self, new_value) - local volume_icon_name = '' + local volume_icon_name if self.is_muted then volume_icon_name = 'audio-volume-muted-symbolic.svg' else diff --git a/fs-widget/fs-widget.lua b/fs-widget/fs-widget.lua index e920e47..0c12a3a 100644 --- a/fs-widget/fs-widget.lua +++ b/fs-widget/fs-widget.lua @@ -6,8 +6,8 @@ local gears = require("gears") local storage_bar_widget = {} -local function worker(args) - local args = args or {} +local function worker(user_args) + local args = user_args or {} local mounts = args.mounts or {'/'} local timeout = args.timeout or 60 diff --git a/gerrit-widget/gerrit.lua b/gerrit-widget/gerrit.lua index ad5d7a6..cb1a460 100644 --- a/gerrit-widget/gerrit.lua +++ b/gerrit-widget/gerrit.lua @@ -27,9 +27,9 @@ local DOWNLOAD_AVATAR_CMD = [[bash -c "curl --create-dirs -o %s %s"]] local gerrit_widget = {} -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icons or HOME_DIR .. '/.config/awesome/awesome-wm-widgets/gerrit-widget/gerrit_icon.svg' local host = args.host or naughty.notify{ diff --git a/github-contributions-widget/github-contributions-widget.lua b/github-contributions-widget/github-contributions-widget.lua index b462299..5a45fcb 100644 --- a/github-contributions-widget/github-contributions-widget.lua +++ b/github-contributions-widget/github-contributions-widget.lua @@ -13,7 +13,8 @@ local naughty = require("naughty") local wibox = require("wibox") local widget_themes = require("awesome-wm-widgets.github-contributions-widget.themes") -local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.now.sh/api/v1/%s | jq -r '[.contributions[] | select ( .date | strptime(\"%%Y-%%m-%%d\") | mktime < now)][:%s]| .[].color'"]] +local GET_CONTRIBUTIONS_CMD = [[bash -c "curl -s https://github-contributions.now.sh/api/v1/%s]] + .. [[ | jq -r '[.contributions[] | select ( .date | strptime(\"%%Y-%%m-%%d\") | mktime < now)][:%s]| .[].color'"]] local github_contributions_widget = wibox.widget{ reflection = { @@ -30,9 +31,9 @@ local function show_warning(message) text = message} end -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local username = args.username or 'streetturtle' local days = args.days or 365 @@ -62,10 +63,10 @@ local function worker(args) local r, g, b = hex2rgb(color) return wibox.widget{ - fit = function(self, context, width, height) + fit = function() return 3, 3 end, - draw = function(self, context, cr, width, height) + draw = function(_, _, cr, _, _) cr:set_source_rgb(r/255, g/255, b/255) cr:rectangle(0, 0, with_border and 2 or 3, with_border and 2 or 3) cr:fill() @@ -77,11 +78,11 @@ local function worker(args) local col = {layout = wibox.layout.fixed.vertical} local row = {layout = wibox.layout.fixed.horizontal} local a = 5 - os.date('%w') - for i = 0, a do + for _ = 0, a do table.insert(col, get_square(color_of_empty_cells)) end - local update_widget = function(widget, stdout, _, _, _) + local update_widget = function(_, stdout, _, _, _) for colors in stdout:gmatch("[^\r\n]+") do if a%7 == 0 then table.insert(row, col) @@ -100,7 +101,7 @@ local function worker(args) end awful.spawn.easy_async(string.format(GET_CONTRIBUTIONS_CMD, username, days), - function(stdout, stderr) + function(stdout) update_widget(github_contributions_widget, stdout) end) diff --git a/gitlab-widget/gitlab.lua b/gitlab-widget/gitlab.lua index 3482347..2ab65b6 100644 --- a/gitlab-widget/gitlab.lua +++ b/gitlab-widget/gitlab.lua @@ -21,8 +21,9 @@ local color = require("gears.color") local HOME_DIR = os.getenv("HOME") local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/gitlab-widget/' -local GET_PRS_CMD= [[bash -c "curl -s --connect-timeout 5 --show-error --header 'PRIVATE-TOKEN: %s' '%s/api/v4/merge_requests?state=opened'"]] -local DOWNLOAD_AVATAR_CMD = [[bash -c "curl -L --create-dirs -o %s/.cache/awmw/gitlab-widget/avatars/%s %s"]] +local GET_PRS_CMD= [[sh -c "curl -s --connect-timeout 5 --show-error --header 'PRIVATE-TOKEN: %s']] + ..[[ '%s/api/v4/merge_requests?state=opened'"]] +local DOWNLOAD_AVATAR_CMD = [[sh -c "curl -L --create-dirs -o %s/.cache/awmw/gitlab-widget/avatars/%s %s"]] local gitlab_widget = wibox.widget { { @@ -33,7 +34,7 @@ local gitlab_widget = wibox.widget { }, { id = 'error_marker', - draw = function(self, context, cr, width, height) + draw = function(_, _, cr, _, height) cr:set_source(color(beautiful.fg_urgent)) cr:arc(height/4, height/4, height/4, 0, math.pi*2) cr:fill() @@ -96,7 +97,7 @@ local popup = awful.popup{ --- Converts string representation of date (2020-06-02T11:25:27Z) to date local function parse_date(date_str) local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)%Z" - local y, m, d, h, min, sec, mil = date_str:match(pattern) + local y, m, d, h, min, sec, _ = date_str:match(pattern) return os.time{year = y, month = m, day = d, hour = h, min = min, sec = sec} end @@ -134,9 +135,9 @@ local tooltip = awful.tooltip { preferred_positions = {'bottom'}, } -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local icon = args.icon or WIDGET_DIR .. '/icons/gitlab-icon.svg' local api_token = args.api_token or show_warning('API Token is not set') @@ -318,7 +319,9 @@ local function worker(args) DOWNLOAD_AVATAR_CMD, HOME_DIR, pr.author.id, - pr.author.avatar_url), function() row:get_children_by_id('avatar')[1]:set_image(path_to_avatar) end) + pr.author.avatar_url), function() + row:get_children_by_id('avatar')[1]:set_image(path_to_avatar) + end) end row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end) @@ -342,25 +345,24 @@ local function worker(args) ) local old_cursor, old_wibox - row:get_children_by_id('title')[1]:connect_signal("mouse::enter", function(c) + row:get_children_by_id('title')[1]:connect_signal("mouse::enter", function() local wb = mouse.current_wibox old_cursor, old_wibox = wb.cursor, wb wb.cursor = "hand1" end) - row:get_children_by_id('title')[1]:connect_signal("mouse::leave", function(c) + row:get_children_by_id('title')[1]:connect_signal("mouse::leave", function() if old_wibox then old_wibox.cursor = old_cursor old_wibox = nil end end) - local old_cursor, old_wibox - row:get_children_by_id('avatar')[1]:connect_signal("mouse::enter", function(c) + row:get_children_by_id('avatar')[1]:connect_signal("mouse::enter", function() local wb = mouse.current_wibox old_cursor, old_wibox = wb.cursor, wb wb.cursor = "hand1" end) - row:get_children_by_id('avatar')[1]:connect_signal("mouse::leave", function(c) + row:get_children_by_id('avatar')[1]:connect_signal("mouse::leave", function() if old_wibox then old_wibox.cursor = old_cursor old_wibox = nil diff --git a/logout-widget/logout.lua b/logout-widget/logout.lua index 9fcc9fe..512ac23 100644 --- a/logout-widget/logout.lua +++ b/logout-widget/logout.lua @@ -54,8 +54,8 @@ local function create_button(icon_name, action_name, color, onclick, icon_size, capi.keygrabber.stop() end } - button:connect_signal("mouse::enter", function(c) action:set_text(action_name) end) - button:connect_signal("mouse::leave", function(c) action:set_text(' ') end) + button:connect_signal("mouse::enter", function() action:set_text(action_name) end) + button:connect_signal("mouse::leave", function() action:set_text(' ') end) return button end @@ -76,7 +76,8 @@ local function launch(args) w:set_bg(bg_color) if #phrases > 0 then - phrase_widget:set_markup('' .. phrases[ math.random( #phrases ) ] .. '') + phrase_widget:set_markup( + '' .. phrases[ math.random( #phrases ) ] .. '') end w:setup { diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua index d70e6ee..f1d6930 100644 --- a/mpdarc-widget/mpdarc.lua +++ b/mpdarc-widget/mpdarc.lua @@ -25,7 +25,7 @@ local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png" local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png" local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png" -local icon = wibox.widget { +local icon = wibox.widget { id = "icon", widget = wibox.widget.imagebox, image = PLAY_ICON_NAME @@ -58,7 +58,7 @@ local update_graphic = function(widget, stdout, _, _, _) stdout = string.gsub(stdout, "\n", "") local mpdpercent = string.match(stdout, "(%d%d)%%") local mpdstatus = string.match(stdout, "%[(%a+)%]") - if mpdstatus == "playing" then + if mpdstatus == "playing" then icon.image = PLAY_ICON_NAME widget.colors = { beautiful.widget_main_color } widget.value = tonumber((100-mpdpercent)/100) @@ -93,7 +93,7 @@ mpdarc:connect_signal("button::press", function(_, _, _, button) end) local notification -function show_MPD_status() +local function show_MPD_status() spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) notification = naughty.notify { diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua index 5af85b4..4651b45 100644 --- a/mpris-widget/init.lua +++ b/mpris-widget/init.lua @@ -29,7 +29,7 @@ local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png" local mpdarc_widget = {} -local function worker(args) +local function worker() -- retriving song info local current_song, artist, mpdstatus, art, artUrl @@ -123,7 +123,7 @@ local function worker(args) local notification local function show_MPD_status() - spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) + spawn.easy_async(GET_MPD_CMD, function() notification = naughty.notification { margin = 10, timeout = 5, diff --git a/net-speed-widget/net-speed.lua b/net-speed-widget/net-speed.lua index 846898c..409e03d 100644 --- a/net-speed-widget/net-speed.lua +++ b/net-speed-widget/net-speed.lua @@ -8,7 +8,6 @@ -- @copyright 2020 Pavel Makhov ------------------------------------------------- -local naughty = require("naughty") local watch = require("awful.widget.watch") local wibox = require("wibox") @@ -16,14 +15,6 @@ local HOME_DIR = os.getenv("HOME") local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/net-speed-widget/' local ICONS_DIR = WIDGET_DIR .. 'icons/' -local function show_warning(message) - naughty.notify { - preset = naughty.config.presets.critical, - title = 'Net Speed Widget', - text = message - } -end - local net_speed_widget = wibox.widget { { id = 'rx_speed', @@ -91,21 +82,21 @@ local function split(string_to_split, separator) return t end -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local interface = args.interface or '*' local timeout = args.timeout or 1 - local update_widget = function(widget, stdout, stderr) + local update_widget = function(widget, stdout) local cur_vals = split(stdout, '\r\n') local cur_rx = 0 local cur_tx = 0 - for i, v in ipairs(cur_vals) do + for i, _ in ipairs(cur_vals) do if i%2 == 1 then cur_rx = cur_rx + cur_vals[i] end if i%2 == 0 then cur_tx = cur_tx + cur_vals[i] end end @@ -120,7 +111,8 @@ local function worker(args) prev_tx = cur_tx end - watch(string.format([[bash -c "cat /sys/class/net/%s/statistics/*_bytes"]], interface), timeout, update_widget, net_speed_widget) + watch(string.format([[bash -c "cat /sys/class/net/%s/statistics/*_bytes"]], interface), + timeout, update_widget, net_speed_widget) return net_speed_widget diff --git a/pomodoroarc-widget/pomodoroarc.lua b/pomodoroarc-widget/pomodoroarc.lua index dab8c3a..497a208 100644 --- a/pomodoroarc-widget/pomodoroarc.lua +++ b/pomodoroarc-widget/pomodoroarc.lua @@ -92,7 +92,7 @@ text.font = "Inconsolata Medium 13" widget.value = tonumber(pomodoro/(25*60)) text.font = "Inconsolata Medium 13" text.text = "PW" - elseif workbreak == "B" then + elseif workbreak == "B" then widget.colors = { beautiful.widget_yellow } widget.value = tonumber(pomodoro/(5*60)) text.font = "Inconsolata Medium 13" @@ -114,7 +114,7 @@ pomodoroarc:connect_signal("button::press", function(_, _, _, button) end) local notification -function show_pomodoro_status() +local function show_pomodoro_status() spawn.easy_async(GET_pomodoro_CMD, function(stdout, _, _, _) notification = naughty.notify { diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index 66863f5..3ef5d6b 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -8,8 +8,8 @@ local wibox = require("wibox") local ramgraph_widget = {} -local function worker(args) - local args = args or {} +local function worker(user_args) + local args = user_args or {} local timeout = args.timeout or 1 --- Main ram widget shown on wibar @@ -43,6 +43,7 @@ local function worker(args) offset = { y = 5 }, } + --luacheck:ignore 231 local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap local function getPercentage(value) @@ -50,7 +51,7 @@ local function worker(args) end watch('bash -c "LANGUAGE=en_US.UTF-8 free | grep -z Mem.*Swap.*"', timeout, - function(widget, stdout, stderr, exitreason, exitcode) + function(widget, stdout) total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') @@ -75,7 +76,7 @@ local function worker(args) {'free ' .. getPercentage(free + free_swap), free + free_swap}, {'buff_cache ' .. getPercentage(buff_cache), buff_cache} } - + if popup.visible then popup.visible = not popup.visible else diff --git a/rhythmbox-widget/rhythmbox.lua b/rhythmbox-widget/rhythmbox.lua deleted file mode 100644 index 1287587..0000000 --- a/rhythmbox-widget/rhythmbox.lua +++ /dev/null @@ -1,16 +0,0 @@ -local wibox = require("wibox") -local awful = require("awful") -local watch = require("awful.widget.watch") - -rhythmbox_widget = wibox.widget.textbox() -rhythmbox_widget:set_font('Play 9') - -rhythmbox_icon = wibox.widget.imagebox() -rhythmbox_icon:set_image("/usr/share/icons/Arc/devices/22/audio-speakers.png") - -watch( - "rhythmbox-client --no-start --print-playing", 1, - function(widget, stdout, stderr, exitreason, exitcode) - rhythmbox_widget:set_text(stdout) - end -) \ No newline at end of file diff --git a/run-shell-3/run-shell.lua b/run-shell-3/run-shell.lua index 51feaf4..0015232 100644 --- a/run-shell-3/run-shell.lua +++ b/run-shell-3/run-shell.lua @@ -8,10 +8,6 @@ -- @copyright 2019 Pavel Makhov ------------------------------------------------- -local capi = { - screen = screen, - client = client, -} local awful = require("awful") local gfs = require("gears.filesystem") local wibox = require("wibox") @@ -26,8 +22,10 @@ local widget = {} function widget.new() local widget_instance = { _cached_wiboxes = {}, - _cmd_pixelate = [[bash -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -vf frei0r=pixeliz0r -vframes 1 /tmp/i3lock-%s.png ; echo done']], - _cmd_blur = [[bash -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -filter_complex "boxblur=9" -vframes 1 /tmp/i3lock-%s.png ; echo done']] + _cmd_pixelate = [[sh -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 -vf ]] + .. [[frei0r=pixeliz0r -vframes 1 /tmp/i3lock-%s.png ; echo done']], + _cmd_blur = [[sh -c 'ffmpeg -loglevel panic -f x11grab -video_size 1920x1060 -y -i :0.0+%s,20 ]] + .. [[-filter_complex "boxblur=9" -vframes 1 /tmp/i3lock-%s.png ; echo done']] } function widget_instance:_create_wibox() @@ -74,21 +72,18 @@ function widget.new() return w end - function widget_instance:launch(s, c) - c = c or capi.client.focus - s = mouse.screen - -- naughty.notify { text = 'screen ' .. s.index } + function widget_instance:launch() + local s = mouse.screen if not self._cached_wiboxes[s] then self._cached_wiboxes[s] = {} - -- naughty.notify { text = 'nope' } end if not self._cached_wiboxes[s][1] then self._cached_wiboxes[s][1] = self:_create_wibox() - -- naughty.notify { text = 'nope' } end local w = self._cached_wiboxes[s][1] local rnd = math.random() - awful.spawn.with_line_callback(string.format(self._cmd_blur, tostring(awful.screen.focused().geometry.x), rnd), { + awful.spawn.with_line_callback( + string.format(self._cmd_blur, tostring(awful.screen.focused().geometry.x), rnd), { stdout = function() w.visible = true w.bgimage = '/tmp/i3lock-' .. rnd ..'.png' diff --git a/run-shell/run-shell.lua b/run-shell/run-shell.lua index 2fda71b..a43c4d5 100644 --- a/run-shell/run-shell.lua +++ b/run-shell/run-shell.lua @@ -45,6 +45,7 @@ function widget.new() widget = wibox.widget.imagebox, resize = false, opacity = 0.2, + --luacheck:ignore 432 set_hover = function(self, opacity) self.opacity = opacity self.image = '/usr/share/icons/Arc/actions/symbolic/system-shutdown-symbolic.svg' diff --git a/todo-widget/todo.lua b/todo-widget/todo.lua index 14e3dc2..74b3d1b 100644 --- a/todo-widget/todo.lua +++ b/todo-widget/todo.lua @@ -23,7 +23,7 @@ local GET_TODO_ITEMS = 'bash -c "cat ' .. STORAGE .. '"' local rows = { layout = wibox.layout.fixed.vertical } local todo_widget = {} - +local update_widget todo_widget.widget = wibox.widget { { { @@ -115,7 +115,7 @@ add_button:connect_signal("button::press", function() local res = json.decode(stdout) table.insert(res.todo_items, {todo_item = input_text, status = false}) spawn.easy_async_with_shell("echo '" .. json.encode(res) .. "' > " .. STORAGE, function() - spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end) + spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end) end) end) end @@ -202,7 +202,7 @@ local function worker(user_args) trash_button:connect_signal("button::press", function() table.remove(result.todo_items, i) spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function () - spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end) + spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end) end) end) @@ -218,7 +218,7 @@ local function worker(user_args) result.todo_items[i] = result.todo_items[i-1] result.todo_items[i-1] = temp spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function () - spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end) + spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end) end) end) @@ -233,7 +233,7 @@ local function worker(user_args) result.todo_items[i] = result.todo_items[i+1] result.todo_items[i+1] = temp spawn.easy_async_with_shell("printf '" .. json.encode(result) .. "' > " .. STORAGE, function () - spawn.easy_async(GET_TODO_ITEMS, function(stdout) update_widget(stdout) end) + spawn.easy_async(GET_TODO_ITEMS, function(items) update_widget(items) end) end) end) @@ -242,13 +242,11 @@ local function worker(user_args) layout = wibox.layout.fixed.vertical } - if 1 == #result.todo_items then - -- one item, no need in arrows - elseif i == 1 then + if i == 1 and #result.todo_items > 1 then table.insert(move_buttons, move_down) - elseif i == #result.todo_items then + elseif i == #result.todo_items and #result.todo_items > 1 then table.insert(move_buttons, move_up) - else + elseif #result.todo_items > 1 then table.insert(move_buttons, move_up) table.insert(move_buttons, move_down) end -- cgit v1.2.3