Adding '/proc/net/wireless' file information, no more recursive calls in case interface="", fixing markdown

This commit is contained in:
bzgec 2021-03-20 19:57:10 +01:00
parent 5a6a267646
commit 0de32abcde
3 changed files with 139 additions and 81 deletions

View File

@ -22,7 +22,7 @@ to improve your Awesome setup.
* [Battery Indicator (UPower)](https://github.com/stefano-m/awesome-power_widget)
* [[Google Play Music Desktop Player|recipes/gpmdp]]
* [Set of simple widgets](https://github.com/streetturtle/awesome-wm-widgets) - widgets for battery, cpu, brightness, volume, email, etc.
* [Wireless status](../recipes/wirelessStatus)
* [[Wireless status|recipes/wirelessStatus]]
## Libraries

View File

@ -5,21 +5,49 @@
# Wireless status widget/watcher
Get wireless Quality link (converted to percentages) and wireless status.
## Requirements:
Data is taken from `/proc/net/wireless`.
According to [this](https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Linux.Wireless.Extensions.html)
website `/proc/net/wireless` has the following information:
- Status: Its current state. This is a device dependent information.
- Quality - link: general quality of the reception.
- Quality - level: signal strength at the receiver.
- Quality - noise: silence level (no packet) at the receiver.
- Discarded - nwid: number of discarded packets due to invalid network id.
- Discarded - crypt: number of packet unable to decrypt.
- Discarded - misc: unused (for now).
This widget uses `Quality - link` and converts it to percentages (`perc=Quality_link*10/7`).
The above equation is taken from [this](https://superuser.com/a/1360447) forum answer.
It also stores `Status` information (note that this is presumably device dependent).
## Requirements
- `iw`
## Usage:
## Usage
- Download [wirelessStatus.lua](https://awesomewm.org/recipes/wirelessStatus.lua) file and put it
into awesome's folder (like `~/.config/awesome/widgets/wirelessStatus.lua`)
- Add widget to `theme.lua`:
```lua
local widgets = {
wirelessStatus = require("widgets/wirelessStatus"),
}
-- Wireless status widget
-- Wireless status widget (`status` is presumably device dependent)
theme.wirelessStatus = widgets.wirelessStatus({
notification_preset = { font = "Mononoki Nerd Font 10", fg = theme.fg_normal },
timeout = 10,
@ -133,10 +161,12 @@ local function factory(args)
-- Remove last character/s from string ("wlp4s0:"" -> "wlp4s0")
self.interface = stdout:sub(0, -3)
-- This is needed the first time there is an update
-- (or every time the `.interface` is equal to "")
-- Check in case interface is now equal to "" (we don't want to cause recursive
-- calls)
if self.interface ~= "" then
self:update()
end
end
)
end
@ -146,7 +176,7 @@ local function factory(args)
-- Get status and Quality link (convert quality link to percentages)
wirelessStatus, wirelessStatus.timer = awful.widget.watch(
"awk 'NR==3 {printf(\"%d-%.0f\\n\", $2, $3*10/7)}' /proc/net/wireless",
{ 'awk', 'NR==3 {printf("%d-%.0f\\n", $2, $3*10/7)}', '/proc/net/wireless' },
wirelessStatus.timeout,
function(self, stdout, stderr, exitreason, exitcode)
if stdout == "" then

View File

@ -1,19 +1,47 @@
# Wireless status widget/watcher
Get wireless Quality link (converted to percentages) and wireless status.
## Requirements:
Data is taken from `/proc/net/wireless`.
According to [this](https://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Linux.Wireless.Extensions.html)
website `/proc/net/wireless` has the following information:
- Status: Its current state. This is a device dependent information.
- Quality - link: general quality of the reception.
- Quality - level: signal strength at the receiver.
- Quality - noise: silence level (no packet) at the receiver.
- Discarded - nwid: number of discarded packets due to invalid network id.
- Discarded - crypt: number of packet unable to decrypt.
- Discarded - misc: unused (for now).
This widget uses `Quality - link` and converts it to percentages (`perc=Quality_link*10/7`).
The above equation is taken from [this](https://superuser.com/a/1360447) forum answer.
It also stores `Status` information (note that this is presumably device dependent).
## Requirements
- `iw`
## Usage:
## Usage
- Download [wirelessStatus.lua](https://awesomewm.org/recipes/wirelessStatus.lua) file and put it
into awesome's folder (like `~/.config/awesome/widgets/wirelessStatus.lua`)
- Add widget to `theme.lua`:
```lua
local widgets = {
wirelessStatus = require("widgets/wirelessStatus"),
}
-- Wireless status widget
-- Wireless status widget (`status` is presumably device dependent)
theme.wirelessStatus = widgets.wirelessStatus({
notification_preset = { font = "Mononoki Nerd Font 10", fg = theme.fg_normal },
timeout = 10,