ENH make switch for ethernet toggle

This commit is contained in:
Nathan Dwarshuis 2022-08-01 10:43:52 -04:00
parent 78545be3d3
commit 9530b7369f
2 changed files with 7 additions and 2 deletions

View File

@ -494,6 +494,7 @@ data XPFeatures = XPFeatures
{ xpfOptimus :: Bool
, xpfVirtualBox :: Bool
, xpfXSANE :: Bool
, xpfEthernet :: Bool
, xpfWireless :: Bool
, xpfVPN :: Bool
, xpfBluetooth :: Bool
@ -508,6 +509,7 @@ instance FromJSON XPFeatures where
<$> o .:+ "optimus"
<*> o .:+ "virtualbox"
<*> o .:+ "xsane"
<*> o .:+ "ethernet"
<*> o .:+ "wireless"
<*> o .:+ "vpn"
<*> o .:+ "bluetooth"
@ -527,6 +529,7 @@ defXPFeatures = XPFeatures
{ xpfOptimus = False
, xpfVirtualBox = False
, xpfXSANE = False
, xpfEthernet = False
, xpfWireless = False
-- TODO this might be broken down into different flags (expressvpn, etc)
, xpfVPN = False

View File

@ -265,9 +265,11 @@ runToggleBluetooth cl = Sometimes "bluetooth toggle" xpfBluetooth
#!&& fmtNotifyCmd defNoteInfo { body = Just $ Text "bluetooth powered $a" }
runToggleEthernet :: SometimesX
runToggleEthernet = sometimes1 "ethernet toggle" "nmcli" $ IORoot (spawn . cmd) $
And1 (Only readEthernet) (Only_ $ sysExe networkManagerPkgs "nmcli")
runToggleEthernet = Sometimes "ethernet toggle" xpfEthernet
[Subfeature root "nmcli"]
where
root = IORoot (spawn . cmd) $ And1 (Only readEthernet) $ Only_
$ sysExe networkManagerPkgs "nmcli"
-- TODO make this less noisy
cmd iface =
"nmcli -g GENERAL.STATE device show " ++ iface ++ " | grep -q disconnected"