My configuration files for Debian/Ubuntu applications
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ## Usage
  2. [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
  3. ### Description
  4. Monitors network interfaces and shows current traffic.
  5. ```lua
  6. local mynet = lain.widget.net()
  7. ```
  8. ## Input table
  9. Variable | Meaning | Type | Default
  10. --- | --- | --- | ---
  11. `timeout` | Refresh timeout (in seconds) | integer | 2
  12. `iface` | Network device(s) | string (single interface) or table of strings (multiple interfaces) | autodetected
  13. `units` | Units | integer | 1024 (kilobytes)
  14. `notify` | Display "no carrier" notifications | string | "on"
  15. `wifi_state` | Get Wi-Fi connection status | string | "off"
  16. `eth_state` | Get Ethernet connection status | string | "off"
  17. `screen` | Notifications screen | integer | 1
  18. `settings` | User settings | function | empty function
  19. `iface` can be a string or an table of the form `{ "eth0", "eth1", ... }` containing a list of the devices to collect data on.
  20. If more than one device is included, `net_now.sent` and `net_now.received` will contain cumulative values over all given devices.
  21. Use `net_now.devices["eth0"]` to access `sent`, `received`, `state` or `carrier` per device.
  22. Possible alternative values for `units` are 1 (byte) or multiple of 1024: 1024^2 (MB), 1024^3 (GB), and so on.
  23. If `notify = "off"` is set, the widget won't display a notification when there's no carrier.
  24. `settings` can use the following `iface` related strings:
  25. - `net_now.carrier` ("0", "1");
  26. - `net_now.state` ("up", "down");
  27. - `net_now.sent` and `net_now.received` (numbers) will be the sum across all specified interfaces;
  28. - `net_now.devices["interface"]` contains the previous attributes for each detected interface.
  29. If `wifi_state = "on"` is set, `settings` can use the following extra strings attached to `net_now.devices["wireless interface"]`:
  30. - `wifi` (true, false) indicates if the interface is connected to a network;
  31. - `signal` (number) is the connection signal strength in dBm;
  32. If `eth_state = "on"` is set, `settings` can use the following extra string: `net_now.devices["ethernet interface"].ethernet`, which is a boolean indicating if an Ethernet connection's active.
  33. For compatibility reasons, if multiple devices are given, `net_now.carrier` and `net_now.state` correspond to the last interface in the `iface` table and should not be relied upon (deprecated).
  34. ## Output table
  35. Variable | Meaning | Type
  36. --- | --- | ---
  37. `widget` | The widget | `wibox.widget.textbox`
  38. `update` | Update `widget` | function
  39. `get_devices` | Update the `iface` table | function
  40. ## Notes
  41. ### Setting `iface` manually
  42. If the widget [spawns a "no carrier" notification and you are sure to have an active network device](https://github.com/lcpz/lain/issues/102), then autodetection is probably not working. This may due to [your user privileges](https://github.com/lcpz/lain/issues/102#issuecomment-246470526). In this case you can set `iface` manually. You can see which device is **UP,LOWER_UP** with the following command:
  43. ```shell
  44. ip link show
  45. ```
  46. ## Usage examples
  47. ### Two widgets for upload/download rates from the same `iface`
  48. ```lua
  49. local mynetdown = wibox.widget.textbox()
  50. local mynetup = lain.widget.net {
  51. settings = function()
  52. widget:set_markup(net_now.sent)
  53. mynetdown:set_markup(net_now.received)
  54. end
  55. }
  56. ```
  57. ### Wi-Fi/Ethernet connection and signal strength indicator
  58. ```lua
  59. local wifi_icon = wibox.widget.imagebox()
  60. local eth_icon = wibox.widget.imagebox()
  61. local net = lain.widget.net {
  62. notify = "off",
  63. wifi_state = "on",
  64. eth_state = "on",
  65. settings = function()
  66. local eth0 = net_now.devices.eth0
  67. if eth0 then
  68. if eth0.ethernet then
  69. eth_icon:set_image(ethernet_icon_filename)
  70. else
  71. eth_icon:set_image()
  72. end
  73. end
  74. local wlan0 = net_now.devices.wlan0
  75. if wlan0 then
  76. if wlan0.wifi then
  77. local signal = wlan0.signal
  78. if signal < -83 then
  79. wifi_icon:set_image(wifi_weak_filename)
  80. elseif signal < -70 then
  81. wifi_icon:set_image(wifi_mid_filename)
  82. elseif signal < -53 then
  83. wifi_icon:set_image(wifi_good_filename)
  84. elseif signal >= -53 then
  85. wifi_icon:set_image(wifi_great_filename)
  86. end
  87. else
  88. wifi_icon:set_image()
  89. end
  90. end
  91. end
  92. }
  93. ```