commit 7b1a0999285ba9e292511f81416aaa532e88617f parent 88fd857013ce1a1b7778cd6b56ae9fcdd07ba5a9 Author: Vincent Demeester <vincent@sbr.pm> Date: Thu, 2 Jun 2022 14:08:59 +0200 Port profiles.desktop to modules.desktop Signed-off-by: Vincent Demeester <vincent@sbr.pm> Diffstat:
M | systems/modules/desktop/base.nix | | | 27 | +++++++++++++++++++++++++++ |
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/systems/modules/desktop/base.nix b/systems/modules/desktop/base.nix @@ -71,6 +71,33 @@ in ++ lib.optionals config.virtualisation.docker.enable [ "interface-name:docker0" ] # Do not manager libvirt interfaces ++ lib.optionals config.virtualisation.libvirtd.enable [ "interface-name:virbr*" ]; + packages = with pkgs; [ networkmanager-openvpn ]; + dispatcherScripts = [{ + # https://askubuntu.com/questions/1271491/disable-wifi-if-lan-is-connected + source = pkgs.writeText "wifi-wired-exclusive" '' + #!${pkgs.bash}/bin/bash + export LC_ALL=C + + enable_disable_wifi () + { + result=$(${pkgs.networkmanager}/bin/nmcli dev | ${pkgs.gnugrep}/bin/grep "ethernet" | ${pkgs.gnugrep}/bin/grep -w "connected") + if [ -n "$result" ]; then + ${pkgs.networkmanager}/bin/nmcli radio wifi off + else + ${pkgs.networkmanager}/bin/nmcli radio wifi on + fi + } + + if [ "$2" = "up" ]; then + enable_disable_wifi + fi + + if [ "$2" = "down" ]; then + enable_disable_wifi + fi + ''; + type = "basic"; + }]; }; nix = {