diff options
Diffstat (limited to '.config/awesome/services/wifi.lua')
-rw-r--r-- | .config/awesome/services/wifi.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/.config/awesome/services/wifi.lua b/.config/awesome/services/wifi.lua new file mode 100644 index 0000000..f6b67f1 --- /dev/null +++ b/.config/awesome/services/wifi.lua @@ -0,0 +1,23 @@ +local gtimer = require "gears.timer" + +gtimer { + timeout = 1, + call_now = true, + autostart = true, + callback = function() + local lines = {} + + for line in io.lines("/proc/net/wireless") do + table.insert(lines, line) + end + + if not lines[3] then + awesome.emit_signal("services::wifi", 0, false) + return + end + + local strength = lines[3]:match("^%s*(.*)"):match("^.-%s+.-%s+.-(%S+)%.") + + awesome.emit_signal("services::wifi", math.floor(tonumber(strength) * 10 / 7), true) + end +} |