FIX make network toggles actually work
This commit is contained in:
parent
a65cd669dc
commit
8a1345ae4b
|
@ -832,8 +832,9 @@ externalBindings runIO cleanup db =
|
||||||
, -- M-<F1> reserved for showing the keymap
|
, -- M-<F1> reserved for showing the keymap
|
||||||
KeyBinding "M-<F2>" "restart xmonad" restartf
|
KeyBinding "M-<F2>" "restart xmonad" restartf
|
||||||
, KeyBinding "M-<F3>" "recompile xmonad" recompilef
|
, KeyBinding "M-<F3>" "recompile xmonad" recompilef
|
||||||
, KeyBinding "M-<F8>" "select autorandr profile" $ Left $ toX runAutorandrMenu
|
, KeyBinding "M-<F7>" "select autorandr profile" $ Left $ toX runAutorandrMenu
|
||||||
, KeyBinding "M-<F9>" "toggle ethernet" $ Left $ toX runToggleEthernet
|
, KeyBinding "M-<F8>" "toggle wifi" $ Left $ toX runToggleWifi
|
||||||
|
, KeyBinding "M-<F9>" "toggle ethernet" $ Left $ toX runToggleNetworking
|
||||||
, KeyBinding "M-<F10>" "toggle bluetooth" $ Left $ toX $ runToggleBluetooth sys
|
, KeyBinding "M-<F10>" "toggle bluetooth" $ Left $ toX $ runToggleBluetooth sys
|
||||||
, KeyBinding "M-<F11>" "toggle screensaver" $ Left $ toX $ callToggle ses
|
, KeyBinding "M-<F11>" "toggle screensaver" $ Left $ toX $ callToggle ses
|
||||||
, KeyBinding "M-<F12>" "switch gpu" $ Left runOptimusPrompt
|
, KeyBinding "M-<F12>" "switch gpu" $ Left runOptimusPrompt
|
||||||
|
|
|
@ -19,7 +19,8 @@ module XMonad.Internal.Command.Desktop
|
||||||
, runVolumeUp
|
, runVolumeUp
|
||||||
, runVolumeMute
|
, runVolumeMute
|
||||||
, runToggleBluetooth
|
, runToggleBluetooth
|
||||||
, runToggleEthernet
|
, runToggleNetworking
|
||||||
|
, runToggleWifi
|
||||||
, runRestart
|
, runRestart
|
||||||
, runRecompile
|
, runRecompile
|
||||||
, runAreaCapture
|
, runAreaCapture
|
||||||
|
@ -107,6 +108,9 @@ bluetoothPkgs = [Package Official "bluez-utils"]
|
||||||
networkManagerPkgs :: [Fulfillment]
|
networkManagerPkgs :: [Fulfillment]
|
||||||
networkManagerPkgs = [Package Official "networkmanager"]
|
networkManagerPkgs = [Package Official "networkmanager"]
|
||||||
|
|
||||||
|
nmcli :: IODependency_
|
||||||
|
nmcli = sysExe networkManagerPkgs "nmcli"
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Misc constants
|
-- Misc constants
|
||||||
|
|
||||||
|
@ -304,27 +308,35 @@ runToggleBluetooth cl =
|
||||||
#!>> fmtCmd myBluetooth ["power", "$a", ">", "/dev/null"]
|
#!>> fmtCmd myBluetooth ["power", "$a", ">", "/dev/null"]
|
||||||
#!&& fmtNotifyCmd defNoteInfo {body = Just $ Text "bluetooth powered $a"}
|
#!&& fmtNotifyCmd defNoteInfo {body = Just $ Text "bluetooth powered $a"}
|
||||||
|
|
||||||
runToggleEthernet :: MonadUnliftIO m => Sometimes (m ())
|
runToggleNetworking :: MonadUnliftIO m => Sometimes (m ())
|
||||||
runToggleEthernet =
|
runToggleNetworking =
|
||||||
Sometimes
|
Sometimes
|
||||||
"ethernet toggle"
|
"network toggle"
|
||||||
xpfEthernet
|
(\x -> xpfEthernet x || xpfWireless x)
|
||||||
[Subfeature root "nmcli"]
|
[Subfeature root "nmcli"]
|
||||||
where
|
where
|
||||||
root =
|
root = IORoot_ cmd $ Only_ nmcli
|
||||||
IORoot cmd $
|
cmd =
|
||||||
And1 (Only readEthernet) $
|
|
||||||
Only_ $
|
|
||||||
sysExe networkManagerPkgs "nmcli"
|
|
||||||
-- TODO make this less noisy
|
|
||||||
cmd iface =
|
|
||||||
S.spawn $
|
S.spawn $
|
||||||
fmtCmd "nmcli" ["-g", "GENERAL.STATE", "device", "show", iface]
|
fmtCmd "nmcli" ["networking"]
|
||||||
#!| "grep -q disconnected"
|
#!| "grep -q enabled"
|
||||||
#!&& "a=connect"
|
#!&& "a=off"
|
||||||
#!|| "a=disconnect"
|
#!|| "a=on"
|
||||||
#!>> fmtCmd "nmcli" ["device", "$a", iface]
|
#!>> fmtCmd "nmcli" ["networking", "$a"]
|
||||||
#!&& fmtNotifyCmd defNoteInfo {body = Just $ Text "ethernet \"$a\"ed"}
|
#!&& fmtNotifyCmd defNoteInfo {body = Just $ Text "networking switched $a"}
|
||||||
|
|
||||||
|
runToggleWifi :: MonadUnliftIO m => Sometimes (m ())
|
||||||
|
runToggleWifi = Sometimes "wifi toggle" xpfWireless [Subfeature root "nmcli"]
|
||||||
|
where
|
||||||
|
root = IORoot_ cmd $ Only_ nmcli
|
||||||
|
cmd =
|
||||||
|
S.spawn $
|
||||||
|
fmtCmd "nmcli" ["radio", "wifi"]
|
||||||
|
#!| "grep -q enabled"
|
||||||
|
#!&& "a=off"
|
||||||
|
#!|| "a=on"
|
||||||
|
#!>> fmtCmd "nmcli" ["radio", "wifi", "$a"]
|
||||||
|
#!&& fmtNotifyCmd defNoteInfo {body = Just $ Text "wifi switched $a"}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Configuration commands
|
-- Configuration commands
|
||||||
|
|
Loading…
Reference in New Issue