Use acpi for battery
parent
23e3adc741
commit
6308f00345
|
@ -11,7 +11,7 @@ Some features require extra tools. Tools each module requires are listed below.
|
||||||
|
|
||||||
- Core: `fish`, `sox` (and plugins)
|
- Core: `fish`, `sox` (and plugins)
|
||||||
- Backlight: `xbacklight`
|
- Backlight: `xbacklight`
|
||||||
- Battery: `upower`
|
- Battery: `acpi`
|
||||||
- Ibus: `ibus`
|
- Ibus: `ibus`
|
||||||
- Launcher: `rofi`
|
- Launcher: `rofi`
|
||||||
- Lock: `i3lock, imagemagick, scrot` or `lightdm` (For `dm-tool`), depending on configuration.
|
- Lock: `i3lock, imagemagick, scrot` or `lightdm` (For `dm-tool`), depending on configuration.
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/fish
|
|
||||||
# returns battery percentage and status
|
|
||||||
# 45%, discharging
|
|
||||||
# second parameter returns "fully" when fully charged. Since awesome only checks for "discharging," fixing that isn't necessary.
|
|
||||||
|
|
||||||
echo \
|
|
||||||
(upower --show-info /org/freedesktop/UPower/devices/battery_BAT1 | grep percentage | grep -Po "(\d\d?\d?)%"), \
|
|
||||||
(upower --show-info /org/freedesktop/UPower/devices/battery_BAT1 | grep state | grep -Po "(?<=state:)\s*(\w*)" | xargs) \
|
|
|
@ -1,13 +1,11 @@
|
||||||
local battery = {}
|
local battery = {}
|
||||||
|
|
||||||
local script = conf_dir .. "modules/battery/battery.fish"
|
|
||||||
|
|
||||||
battery.watch = function(timeout, callback, widget)
|
battery.watch = function(timeout, callback, widget)
|
||||||
awful.widget.watch(script, timeout, callback, widget)
|
awful.widget.watch("acpi --battery", timeout, callback, widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
battery.status = function(callback)
|
battery.status = function(callback)
|
||||||
awful.spawn.easy_async(script, callback)
|
awful.spawn.easy_async("acpi --battery", callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
return battery
|
return battery
|
||||||
|
|
|
@ -95,7 +95,7 @@ widget.update = function(stdout)
|
||||||
local batpec = string.match(stdout, "(%d?%d?%d)%%")
|
local batpec = string.match(stdout, "(%d?%d?%d)%%")
|
||||||
batpec = tonumber(string.format("% 3d", batpec))
|
batpec = tonumber(string.format("% 3d", batpec))
|
||||||
|
|
||||||
local discharging = string.match(stdout, "discharging") or false
|
local discharging = string.match(stdout, "Discharging") or false
|
||||||
|
|
||||||
-- Handle low power notifications
|
-- Handle low power notifications
|
||||||
if discharging then
|
if discharging then
|
||||||
|
|
Loading…
Reference in New Issue