trigger build action on a branch

This commit is contained in:
streetturtle 2020-12-02 09:24:05 -05:00
parent e3d3e07af3
commit d9eb3885ee
12 changed files with 92 additions and 71 deletions

View File

@ -21,7 +21,12 @@ local gfs = require("gears.filesystem")
local HOME_DIR = os.getenv("HOME") local HOME_DIR = os.getenv("HOME")
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/bitbucket-widget/' 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 DOWNLOAD_AVATAR_CMD = [[bash -c "curl -L -n --create-dirs -o %s/.cache/awmw/bitbucket-widget/avatars/%s %s"]]
local bitbucket_widget = wibox.widget { 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 --- Converts string representation of date (2020-06-02T11:25:27Z) to date
local function parse_date(date_str) local function parse_date(date_str)
local pattern = "(%d+)%-(%d+)%-(%d+)T(%d+):(%d+):(%d+)%Z" 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} return os.time{year = y, month = m, day = d, hour = h, min = min, sec = sec}
end end
@ -111,9 +116,9 @@ local function count_approves(participants)
return res return res
end 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 icon = args.icon or WIDGET_DIR .. '/bitbucket-icon-gradient-blue.svg'
local host = args.host or show_warning('Bitbucket host is not set') 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 if not gfs.file_readable(path_to_avatar) then
spawn.easy_async(string.format( local cmd = string.format(DOWNLOAD_AVATAR_CMD, HOME_DIR, pr.author.uuid, pr.author.links.avatar.href)
DOWNLOAD_AVATAR_CMD, spawn.easy_async(cmd, function() row:get_children_by_id('avatar')[1]:set_image(path_to_avatar) end)
HOME_DIR,
pr.author.uuid,
pr.author.links.avatar.href), function() row:get_children_by_id('avatar')[1]:set_image(path_to_avatar) end)
end end
@ -299,34 +301,36 @@ local function worker(args)
) )
) )
row:get_children_by_id('avatar')[1]:buttons( row:get_children_by_id('avatar')[1]:buttons(
awful.util.table.join( awful.util.table.join(
awful.button({}, 1, function() 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)) spawn.with_shell(
popup.visible = false string.format('xdg-open "https://bitbucket.org/%s/%s/pull-requests?state=OPEN&author=%s"',
end) workspace, repo_slug, pr.author.uuid)
) )
popup.visible = false
end)
)
) )
local old_cursor, old_wibox 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 local wb = mouse.current_wibox
old_cursor, old_wibox = wb.cursor, wb old_cursor, old_wibox = wb.cursor, wb
wb.cursor = "hand1" wb.cursor = "hand1"
end) 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 if old_wibox then
old_wibox.cursor = old_cursor old_wibox.cursor = old_cursor
old_wibox = nil old_wibox = nil
end end
end) end)
local old_cursor, old_wibox row:get_children_by_id('avatar')[1]:connect_signal("mouse::enter", function()
row:get_children_by_id('avatar')[1]:connect_signal("mouse::enter", function(c)
local wb = mouse.current_wibox local wb = mouse.current_wibox
old_cursor, old_wibox = wb.cursor, wb old_cursor, old_wibox = wb.cursor, wb
wb.cursor = "hand1" wb.cursor = "hand1"
end) 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 if old_wibox then
old_wibox.cursor = old_cursor old_wibox.cursor = old_cursor
old_wibox = nil old_wibox = nil

View File

@ -14,6 +14,9 @@ local wibox = require("wibox")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local gears = require("gears") 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 HOME_DIR = os.getenv("HOME")
local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/cpu-widget' local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/cpu-widget'
@ -86,9 +89,9 @@ local function create_kill_process_button()
} }
end 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 width = args.width or 50
local step_width = args.step_width or 2 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 -- 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::enter", function() is_update = false end)
popup:connect_signal("mouse::leave", function(c) is_update = true end) popup:connect_signal("mouse::leave", function() is_update = true end)
cpugraph_widget:buttons( cpugraph_widget:buttons(
awful.util.table.join( 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 cpu_widget = wibox.container.margin(wibox.container.mirror(cpugraph_widget, { horizontal = true }), 0, 0, 0, 2)
local cpus = {} 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) function(widget, stdout)
local i = 1 local i = 1
local j = 1 local j = 1

View File

@ -17,12 +17,12 @@ local naughty = require("naughty")
local gears = require("gears") local gears = require("gears")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local gfs = require("gears.filesystem") local gfs = require("gears.filesystem")
local gs = require("gears.string")
local color = require("gears.color") local color = require("gears.color")
local HOME_DIR = os.getenv("HOME") 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 DOWNLOAD_AVATAR_CMD = [[bash -c "curl -n --create-dirs -o %s/.cache/awmw/jira-widget/avatars/%s %s"]]
local function show_warning(message) local function show_warning(message)
@ -41,7 +41,7 @@ local jira_widget = wibox.widget {
}, },
{ {
id = 'd', id = 'd',
draw = function(self, context, cr, width, height) draw = function(_, _, cr, _, height)
cr:set_source(color(beautiful.fg_urgent)) cr:set_source(color(beautiful.fg_urgent))
cr:arc(height/4, height/4, height/4, 0, math.pi*2) cr:arc(height/4, height/4, height/4, 0, math.pi*2)
cr:fill() cr:fill()
@ -100,9 +100,9 @@ local tooltip = awful.tooltip {
preferred_positions = {'bottom'}, 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 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') 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 i = 0, #rows do rows[i]=nil end
for _, issue in ipairs(result.issues) do 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 if not gfs.file_readable(path_to_avatar) then
spawn.easy_async(string.format( spawn.easy_async(string.format(

View File

@ -89,7 +89,7 @@ function widget.new()
local w = self._cached_wiboxes[s][1] local w = self._cached_wiboxes[s][1]
local rnd = math.random() 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(line) stdout = function()
w.visible = true w.visible = true
w.bgimage = '/tmp/i3lock-' .. rnd ..'.png' w.bgimage = '/tmp/i3lock-' .. rnd ..'.png'
awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() }) awful.placement.top(w, { margins = { top = 20 }, parent = awful.screen.focused() })

View File

@ -11,7 +11,6 @@
local awful = require("awful") local awful = require("awful")
local wibox = require("wibox") local wibox = require("wibox")
local watch = require("awful.widget.watch") local watch = require("awful.widget.watch")
local naughty = require("naughty")
local GET_SPOTIFY_STATUS_CMD = 'sp status' local GET_SPOTIFY_STATUS_CMD = 'sp status'
local GET_CURRENT_SONG_CMD = 'sp current' local GET_CURRENT_SONG_CMD = 'sp current'
@ -24,9 +23,9 @@ end
local spotify_widget = {} 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 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' 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 end
local escaped = string.gsub(stdout, "&", '&') 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') string.match(escaped, 'Album%s*(.*)\nAlbumArtist%s*(.*)\nArtist%s*(.*)\nTitle%s*(.*)\n')
if album ~= nil and title ~=nil and artist ~= nil then if album ~= nil and title ~=nil and artist ~= nil then

View File

@ -18,13 +18,15 @@ local beautiful = require("beautiful")
local HOME_DIR = os.getenv("HOME") 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 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 icon = args.icon or HOME_DIR .. '/.config/awesome/awesome-wm-widgets/stackoverflow-widget/so-icon.svg'
local limit = args.limit or 5 local limit = args.limit or 5
@ -43,7 +45,7 @@ local function worker(args)
border_width = 1, border_width = 1,
border_color = beautiful.bg_focus, border_color = beautiful.bg_focus,
maximum_width = 400, maximum_width = 400,
preferred_positions = top, preferred_positions = 'top',
offset = { y = 5 }, offset = { y = 5 },
widget = {} widget = {}
} }
@ -63,7 +65,7 @@ local function worker(args)
end, end,
} }
local update_widget = function(widget, stdout, stderr, _, _) local update_widget = function(_, stdout, _, _, _)
local result = json.decode(stdout) local result = json.decode(stdout)
@ -91,7 +93,7 @@ local function worker(args)
widget = wibox.container.background widget = wibox.container.background
} }
row:connect_signal("button::release", function(_, _, _, button) row:connect_signal("button::release", function()
spawn.with_shell("xdg-open " .. item.link) spawn.with_shell("xdg-open " .. item.link)
popup.visible = false popup.visible = false
end) end)

View File

@ -11,7 +11,6 @@ local awful = require("awful")
local wibox = require("wibox") local wibox = require("wibox")
local json = require("json") local json = require("json")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
local naughty = require("naughty")
local gears = require("gears") local gears = require("gears")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local gfs = require("gears.filesystem") 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::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) 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' local icon = args.icon or WIDGET_DIR .. '/checkbox-checked-symbolic.svg'
@ -229,7 +228,7 @@ local function worker(args)
widget = wibox.widget.imagebox 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] local temp = result.todo_items[i]
result.todo_items[i] = result.todo_items[i+1] result.todo_items[i] = result.todo_items[i+1]
result.todo_items[i+1] = temp result.todo_items[i+1] = temp
@ -322,7 +321,8 @@ local function worker(args)
end end
if not gfs.file_readable(STORAGE) then 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 end
return setmetatable(todo_widget, { __call = function(_, ...) return worker(...) end }) return setmetatable(todo_widget, { __call = function(_, ...) return worker(...) end })

View File

@ -16,7 +16,8 @@ local wibox = require("wibox")
local gears = require("gears") local gears = require("gears")
local gfs = require("gears.filesystem") 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' local ICON = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/translate-widget/gnome-translate.svg'
--- Returns two values - string to translate and direction: --- Returns two values - string to translate and direction:
@ -82,12 +83,14 @@ local function translate(to_translate, lang, api_key, url)
{ {
{ {
id = 'src', id = 'src',
markup = '<b>' .. lang:sub(1,2) .. '</b>: <span color="#FFFFFF"> ' .. to_translate .. '</span>', markup = '<b>' .. lang:sub(1,2) .. '</b>: <span color="#FFFFFF"> '
.. to_translate .. '</span>',
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
id = 'res', id = 'res',
markup = '<b>' .. lang:sub(4) .. '</b>: <span color="#FFFFFF"> ' .. resp.translations[1].translation .. '</span>', markup = '<b>' .. lang:sub(4) .. '</b>: <span color="#FFFFFF"> '
.. resp.translations[1].translation .. '</span>',
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
id = 'text', id = 'text',
@ -110,11 +113,11 @@ local function translate(to_translate, lang, api_key, url)
w:buttons( w:buttons(
awful.util.table.join( awful.util.table.join(
awful.button({}, 1, function() 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 w.visible = false
end), end),
awful.button({}, 3, function() 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 w.visible = false
end) end)
) )

View File

@ -9,7 +9,6 @@
------------------------------------------------- -------------------------------------------------
local wibox = require("wibox") local wibox = require("wibox")
local watch = require("awful.widget.watch")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
local naughty = require("naughty") local naughty = require("naughty")
local gfs = require("gears.filesystem") 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 volume_icon_name="audio-volume-high-symbolic"
local GET_VOLUME_CMD = 'amixer sget Master' 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() function volume:toggle()
volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle') volume:_cmd('amixer ' .. volume.device .. ' sset Master toggle')
@ -88,9 +93,9 @@ end
--}}} --}}}
local function worker(args) local function worker(user_args)
--{{{ Args --{{{ Args
local args = args or {} local args = user_args or {}
local volume_audio_controller = args.volume_audio_controller or 'pulse' local volume_audio_controller = args.volume_audio_controller or 'pulse'
volume.display_notification = args.display_notification or false volume.display_notification = args.display_notification or false
@ -120,7 +125,8 @@ local function worker(args)
resize = false, resize = false,
widget = wibox.widget.imagebox, widget = wibox.widget.imagebox,
}, },
layout = wibox.container.margin(_, _, _, 3), margins = 3,
layout = wibox.container.margin,
set_image = function(self, path) set_image = function(self, path)
self.icon.image = path self.icon.image = path
end end
@ -136,7 +142,7 @@ local function worker(args)
local function show() local function show()
spawn.easy_async(GET_VOLUME_CMD, function(stdout, _, _, _) spawn.easy_async(GET_VOLUME_CMD, function(stdout, _, _, _)
txt = parse_output(stdout) local txt = parse_output(stdout)
notif(txt, true) notif(txt, true)
end end
) )

View File

@ -23,9 +23,9 @@ local PATH_TO_ICON = "/usr/share/icons/Arc/status/symbolic/audio-volume-muted-sy
local widget = {} 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 main_color = args.main_color or beautiful.fg_color
local bg_color = args.bg_color or '#ffffff11' local bg_color = args.bg_color or '#ffffff11'
@ -59,7 +59,7 @@ local function worker(args)
widget = wibox.container.arcchart 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 mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off]
local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%) local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%)
volume = tonumber(string.format("% 3d", volume)) volume = tonumber(string.format("% 3d", volume))

View File

@ -22,9 +22,9 @@ local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle'
local widget = {} 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 main_color = args.main_color or beautiful.fg_normal
local mute_color = args.mute_color or beautiful.fg_urgent local mute_color = args.mute_color or beautiful.fg_urgent
@ -52,7 +52,7 @@ local function worker(args)
widget = wibox.widget.progressbar 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 mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off]
local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%) local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%)
volume = tonumber(string.format("% 3d", volume)) volume = tonumber(string.format("% 3d", volume))

View File

@ -138,6 +138,7 @@ local function worker(user_args)
local icons_extension = args.icons_extension or '.png' local icons_extension = args.icons_extension or '.png'
local timeout = args.timeout or 120 local timeout = args.timeout or 120
local ICONS_DIR = WIDGET_DIR .. '/icons/' .. icon_pack_name .. '/'
local owm_one_cal_api = local owm_one_cal_api =
('https://api.openweathermap.org/data/2.5/onecall' .. ('https://api.openweathermap.org/data/2.5/onecall' ..
'?lat=' .. coordinates[1] .. '&lon=' .. coordinates[2] .. '&appid=' .. api_key .. '?lat=' .. coordinates[1] .. '&lon=' .. coordinates[2] .. '&appid=' .. api_key ..
@ -240,11 +241,14 @@ local function worker(user_args)
forced_width = 300, forced_width = 300,
layout = wibox.layout.flex.horizontal, layout = wibox.layout.flex.horizontal,
update = function(self, weather) 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('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('description')[1]:set_text(weather.weather[1].description)
self:get_children_by_id('wind')[1]:set_markup('Wind: <b>' .. weather.wind_speed .. 'm/s (' .. to_direction(weather.wind_deg) .. ')</b>') self:get_children_by_id('wind')[1]:set_markup(
'Wind: <b>' .. weather.wind_speed .. 'm/s (' .. to_direction(weather.wind_deg) .. ')</b>')
self:get_children_by_id('humidity')[1]:set_markup('Humidity: <b>' .. weather.humidity .. '%</b>') self:get_children_by_id('humidity')[1]:set_markup('Humidity: <b>' .. weather.humidity .. '%</b>')
self:get_children_by_id('uv')[1]:set_markup('UV: ' .. uvi_index_color(weather.uvi)) self:get_children_by_id('uv')[1]:set_markup('UV: ' .. uvi_index_color(weather.uvi))
end 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, resize = true,
forced_width = 48, forced_width = 48,
forced_height = 48, forced_height = 48,
@ -470,8 +474,8 @@ local function worker(user_args)
if stderr ~= '' then if stderr ~= '' then
if not warning_shown then if not warning_shown then
if (stderr ~= 'curl: (52) Empty reply from server' 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 ~= '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:find('^curl: %(18%) transfer closed with %d+ bytes remaining to read$') ~= nil
) then ) then
show_warning(stderr) show_warning(stderr)
end end
@ -490,7 +494,7 @@ local function worker(user_args)
local result = json.decode(stdout) 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)) widget:set_text(gen_temperature_str(result.current.temp, '%.0f', both_units_widget, units))
current_weather_widget:update(result.current) current_weather_widget:update(result.current)