summaryrefslogtreecommitdiff
path: root/translate-widget/translate.lua
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@users.noreply.github.com>2020-12-07 15:33:55 -0500
committerGitHub <noreply@github.com>2020-12-07 15:33:55 -0500
commitd4971690cec1e074999e730d87045e578d71e43c (patch)
treeb0f05079840eba5467e14bdcd093ad3ed5362cf4 /translate-widget/translate.lua
parentf078748e76eacae599cf0ad06120d9fff54f8fa5 (diff)
parented2b256407291d8edadfcea9380029633cc7d9d8 (diff)
Merge pull request #224 from streetturtle/comply-with-luacheck
Comply with luacheck
Diffstat (limited to 'translate-widget/translate.lua')
-rw-r--r--translate-widget/translate.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/translate-widget/translate.lua b/translate-widget/translate.lua
index 9352ac9..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 = '<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
},
{
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
},
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)
)
@@ -159,9 +162,9 @@ input_widget:setup{
widget = wibox.container.margin
}
-local function launch(args)
+local function launch(user_args)
- local args = args or {}
+ local args = user_args or {}
local api_key = args.api_key
local url = args.url