Skip to content
Snippets Groups Projects
Verified Commit 37e5f4f6 authored by Legy (Beini)'s avatar Legy (Beini)
Browse files

Fix battery online state for laptobs that use the ACAD endpoint

parent 41de1e50
No related branches found
No related tags found
No related merge requests found
......@@ -73,10 +73,16 @@ batteryBlock = do
getPluggedState :: IO Bool
getPluggedState = do
line <- tryMaybe $ T.strip <$> TIO.readFile "/sys/class/power_supply/AC/online"
case line of
Just "1" -> return True
_ -> return False
stateAC <- getPluggedStateFromFile "/sys/class/power_supply/AC/online"
stateACAD <- fromMaybe False <$> getPluggedStateFromFile "/sys/class/power_supply/ACAD/online"
return $ fromMaybe stateACAD stateAC
where
getPluggedStateFromFile :: FilePath -> IO (Maybe Bool)
getPluggedStateFromFile f = do
line <- tryMaybe $ T.strip <$> TIO.readFile f
case line of
Just "1" -> return . return $ True
_ -> return . return $ False
batteryBlockOutput :: Bool -> [BatteryState] -> Maybe BlockOutput
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment