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 ...@@ -73,10 +73,16 @@ batteryBlock = do
getPluggedState :: IO Bool getPluggedState :: IO Bool
getPluggedState = do getPluggedState = do
line <- tryMaybe $ T.strip <$> TIO.readFile "/sys/class/power_supply/AC/online" stateAC <- getPluggedStateFromFile "/sys/class/power_supply/AC/online"
case line of stateACAD <- fromMaybe False <$> getPluggedStateFromFile "/sys/class/power_supply/ACAD/online"
Just "1" -> return True return $ fromMaybe stateACAD stateAC
_ -> return False 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 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