ENH don't ignore ethenet interfaces
This commit is contained in:
parent
8064b01c90
commit
3ab6ccf45b
|
@ -468,6 +468,8 @@ data XPFeatures = XPFeatures
|
||||||
, xpfIntelBacklight :: Bool
|
, xpfIntelBacklight :: Bool
|
||||||
, xpfClevoBacklight :: Bool
|
, xpfClevoBacklight :: Bool
|
||||||
, xpfBattery :: Bool
|
, xpfBattery :: Bool
|
||||||
|
, xpfEthPrefix :: Maybe Text
|
||||||
|
, xpfWifiPrefix :: Maybe Text
|
||||||
}
|
}
|
||||||
|
|
||||||
instance FromJSON XPFeatures where
|
instance FromJSON XPFeatures where
|
||||||
|
@ -493,6 +495,10 @@ instance FromJSON XPFeatures where
|
||||||
.:+ "clevo_backlight"
|
.:+ "clevo_backlight"
|
||||||
<*> o
|
<*> o
|
||||||
.:+ "battery"
|
.:+ "battery"
|
||||||
|
<*> o
|
||||||
|
.:? "ethPrefix"
|
||||||
|
<*> o
|
||||||
|
.:? "wifiPrefix"
|
||||||
|
|
||||||
defParams :: XParams
|
defParams :: XParams
|
||||||
defParams =
|
defParams =
|
||||||
|
@ -515,6 +521,8 @@ defXPFeatures =
|
||||||
, xpfIntelBacklight = False
|
, xpfIntelBacklight = False
|
||||||
, xpfClevoBacklight = False
|
, xpfClevoBacklight = False
|
||||||
, xpfBattery = False
|
, xpfBattery = False
|
||||||
|
, xpfEthPrefix = Nothing
|
||||||
|
, xpfWifiPrefix = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
type XPQuery = XPFeatures -> Bool
|
type XPQuery = XPFeatures -> Bool
|
||||||
|
@ -825,16 +833,16 @@ testFont fam = maybe pass (Left . (: [])) <$> shellTest "fc-list" args msg
|
||||||
-- start with "en" and wireless interfaces always start with "wl"
|
-- start with "en" and wireless interfaces always start with "wl"
|
||||||
|
|
||||||
readEthernet :: IODependency T.Text
|
readEthernet :: IODependency T.Text
|
||||||
readEthernet = readInterface "get ethernet interface" isEthernet
|
readEthernet = readInterface "get ethernet interface" (fromMaybe "en" . xpfEthPrefix)
|
||||||
|
|
||||||
readWireless :: IODependency T.Text
|
readWireless :: IODependency T.Text
|
||||||
readWireless = readInterface "get wireless interface" isWireless
|
readWireless = readInterface "get wireless interface" (fromMaybe "wl" . xpfWifiPrefix)
|
||||||
|
|
||||||
isWireless :: T.Text -> Bool
|
-- isWireless :: T.Text -> Bool
|
||||||
isWireless = T.isPrefixOf "wl"
|
-- isWireless = T.isPrefixOf "wl"
|
||||||
|
|
||||||
isEthernet :: T.Text -> Bool
|
-- isEthernet :: T.Text -> Bool
|
||||||
isEthernet = T.isPrefixOf "en"
|
-- isEthernet = T.isPrefixOf "en"
|
||||||
|
|
||||||
listInterfaces :: MonadUnliftIO m => m [T.Text]
|
listInterfaces :: MonadUnliftIO m => m [T.Text]
|
||||||
listInterfaces =
|
listInterfaces =
|
||||||
|
@ -846,11 +854,12 @@ sysfsNet = "/sys/class/net"
|
||||||
|
|
||||||
-- ASSUME there are no (non-base) packages required to make these interfaces
|
-- ASSUME there are no (non-base) packages required to make these interfaces
|
||||||
-- work (all at the kernel level)
|
-- work (all at the kernel level)
|
||||||
readInterface :: T.Text -> (T.Text -> Bool) -> IODependency T.Text
|
readInterface :: T.Text -> (XPFeatures -> Text) -> IODependency T.Text
|
||||||
readInterface n f = IORead n [] go
|
readInterface n f = IORead n [] go
|
||||||
where
|
where
|
||||||
go = io $ do
|
go = do
|
||||||
ns <- filter f <$> listInterfaces
|
p <- asks (f . xpFeatures . xParams)
|
||||||
|
ns <- filter (T.isPrefixOf p) <$> listInterfaces
|
||||||
case ns of
|
case ns of
|
||||||
[] -> return $ Left [Msg LevelError "no interfaces found"]
|
[] -> return $ Left [Msg LevelError "no interfaces found"]
|
||||||
(x : xs) -> do
|
(x : xs) -> do
|
||||||
|
|
Loading…
Reference in New Issue