summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--secrets.lua14
-rw-r--r--translate-widget/README.MD4
-rw-r--r--translate-widget/translate.lua9
3 files changed, 6 insertions, 21 deletions
diff --git a/secrets.lua b/secrets.lua
deleted file mode 100644
index d3250fd..0000000
--- a/secrets.lua
+++ /dev/null
@@ -1,14 +0,0 @@
--------------------------------------------------
--- Allows to store client specific settings in one place
---
--- @author Pavel Makhov
--- @copyright 2019 Pavel Makhov
---------------------------------------------
-
-local secrets = {
-
- -- Yandex.Translate API key - https://tech.yandex.com/translate/
- translate_widget_api_key = os.getenv('AWW_TRANSLATE_API_KEY') or 'trnsl.1.1.20170708T010252Z.8b3fcacab3396ad1.88df3f48339672bce016a0e85a4db3aeb34dc7ae',
-}
-
-return secrets
diff --git a/translate-widget/README.MD b/translate-widget/README.MD
index 9c87ed0..2c783a0 100644
--- a/translate-widget/README.MD
+++ b/translate-widget/README.MD
@@ -13,7 +13,7 @@ This widget allows quickly translate words or phrases without opening a browser
## Installation
1. Clone repo under **~/.config/awesome/**
-1. Get an [API key](https://translate.yandex.com/developers/keys) and paste it in **secrets.lua** as value of the ` translate_widget_api_key` variable
+1. Get an [API key](https://translate.yandex.com/developers/keys)
1. Require widget in **rc.lua**:
```lua
@@ -24,7 +24,7 @@ This widget allows quickly translate words or phrases without opening a browser
```lua
awful.key({ modkey }, "c",
- function() translate.show_translate_prompt() end,
+ function() translate.show_translate_prompt('<api-key>') end,
{ description = "run translate prompt", group = "launcher" }),
```
diff --git a/translate-widget/translate.lua b/translate-widget/translate.lua
index 27f65c7..ae538c8 100644
--- a/translate-widget/translate.lua
+++ b/translate-widget/translate.lua
@@ -14,7 +14,6 @@ local naughty = require("naughty")
local wibox = require("wibox")
local gears = require("gears")
local gfs = require("gears.filesystem")
-local secrets = require("awesome-wm-widgets.secrets")
local BASE_URL = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
local ICON = '/usr/share/icons/Papirus-Dark/48x48/apps/gnome-translate.svg'
@@ -87,8 +86,8 @@ w:setup {
--- Main function - takes the user input and shows the widget with translation
-- @param request_string - user input (dog enfr)
-local function translate(to_translate, lang)
- local urll = BASE_URL .. '?lang=' .. lang .. '&text=' .. urlencode(to_translate) .. '&key=' .. secrets.translate_widget_api_key
+local function translate(to_translate, lang, api_key)
+ local urll = BASE_URL .. '?lang=' .. lang .. '&text=' .. urlencode(to_translate) .. '&key=' .. api_key
local resp_json, code = https.request(urll)
if (code == 200 and resp_json ~= nil) then
@@ -162,7 +161,7 @@ input_widget:setup {
left = 10
}
-local function show_translate_prompt()
+local function show_translate_prompt(api_key)
awful.placement.top(input_widget, { margins = {top = 40}, parent = awful.screen.focused()})
input_widget.height = 40
input_widget.visible = true
@@ -183,7 +182,7 @@ local function show_translate_prompt()
})
return
end
- translate(to_translate, lang)
+ translate(to_translate, lang, api_key)
end,
done_callback = function()
input_widget.visible = false