awesome-wm-widgets/translate-widget/README.MD

53 lines
1.2 KiB
Plaintext
Raw Normal View History

2017-07-17 04:04:46 +02:00
in progress...
2017-12-27 19:59:34 +01:00
# Translate Widget
2018-01-20 20:12:40 +01:00
![demo](./demo.gif)
2018-01-20 20:10:36 +01:00
This widget is based on the [Yandex.Translate API](https://tech.yandex.com/translate/).
2017-12-27 19:59:34 +01:00
## Installation
2018-01-20 20:10:36 +01:00
1. Get an [https://translate.yandex.com/developers/keys](API key)
2017-12-27 19:59:34 +01:00
1.
2017-12-27 20:05:50 +01:00
Create a translate prompt:
```lua
s.translateprompt = awful.widget.prompt()
```
Add it to the left widgets of the wibox, just after `mypromptbox`:
```lua
-- Add widgets to the wibox
s.mywibox:setup {
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
mylauncher,
s.mytaglist,
s.mypromptbox,
s.translateprompt,
},
```
Add a shortcut to run this prompt:
```lua
awful.key({ modkey }, "c", function()
awful.prompt.run {
prompt = "trnslt: ",
textbox = awful.screen.focused().translateprompt.widget,
exe_callback = function(text)
translate.translate(text)
end
}
```
2017-12-27 19:59:34 +01:00
## Controls
- <kbd>Mod4</kbd> + <kbd>c</kbd> - opens a translate prompt;
- left click on the popup widget - copies the translation to the clipboard and closes widget;
2018-01-19 14:46:12 +01:00
- right click on the popup widget - copies text to translate to the clipboard and closes widget.