diff options
-rw-r--r-- | network-widget/network.lua | 27 | ||||
-rwxr-xr-x | network-widget/networkio.sh | 7 | ||||
-rw-r--r-- | secrets.lua | 6 | ||||
-rw-r--r-- | translate-widget/README.MD | 6 |
4 files changed, 44 insertions, 2 deletions
diff --git a/network-widget/network.lua b/network-widget/network.lua new file mode 100644 index 0000000..898be24 --- /dev/null +++ b/network-widget/network.lua @@ -0,0 +1,27 @@ +local awful = require("awful") +local wibox = require("wibox") +local watch = require("awful.widget.watch") + +local NETWORK_DEVICE = "/home/pmakhov/.config/awesome/awesome-wm-widgets/network-widget/networkio.sh" + +net_widget = wibox.widget { + font = "Play 9", + widget = wibox.widget.textbox +} + +local rspeed_prev = 0; +local tspeed_prev = 0; + +watch(NETWORK_DEVICE, 1, + function(widget, stdout, _, _, _) + local r, t = string.match(stdout, '(%d+);(%d+)') + + local rspeed = r - rspeed_prev + local tspeed = t - tspeed_prev + + rspeed_prev = r + tspeed_prev = t + + widget:set_text(rspeed) + end, + net_widget) diff --git a/network-widget/networkio.sh b/network-widget/networkio.sh new file mode 100755 index 0000000..db3d774 --- /dev/null +++ b/network-widget/networkio.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +ACTIVE_INTERFACE="$(ip -o link show | awk '$9~/UP/{sub(":","",$2);print $2}')" + +IO="$(cat /proc/net/dev | grep ${ACTIVE_INTERFACE} | sed "s/.*://" | awk '{printf $1";"$9}')" + +echo "${IO}" diff --git a/secrets.lua b/secrets.lua new file mode 100644 index 0000000..3d5139c --- /dev/null +++ b/secrets.lua @@ -0,0 +1,6 @@ +local secrets = { + translate_widget_api_key = 'trnsl.1.1.20170708T010252Z.8b3fcacab3396ad1.88df3f48339672bce016a0e85a4db3aeb34dc7ae', + weather_widget_api_key = 'c3d7320b359da4e48c2d682a04076576' +} + +return secrets
\ No newline at end of file diff --git a/translate-widget/README.MD b/translate-widget/README.MD index e13b1e4..498b36e 100644 --- a/translate-widget/README.MD +++ b/translate-widget/README.MD @@ -12,7 +12,8 @@ This widget allows quickly translate words or phrases without opening a browser ## Installation -1. Get an [API key](https://translate.yandex.com/developers/keys) and paste it **secrets.lua** +1. Clone repo under **~/.config/awesome/** +1. Get an [API key](https://translate.yandex.com/developers/keys) and paste it in **secrets.lua** 1. Require widget and secrets in **rc.lua**: ```lua @@ -20,7 +21,7 @@ This widget allows quickly translate words or phrases without opening a browser local translate = require("awesome-wm-widgets.translate-widget.translate") ``` -1. Create a translate prompt (just under `mypromptbox`): +1. Create a translate prompt, just under `mypromptbox`: ```lua s.mypromptbox = awful.widget.prompt() @@ -54,3 +55,4 @@ This widget allows quickly translate words or phrases without opening a browser end } ``` + |