~ruther/nixos-config

31b8137da2a051712dc0b4c602fdb8fbd73030c1 — Frantisek Bohacek 11 months ago 8af9642
feat: add swayidle service
2 files changed, 54 insertions(+), 8 deletions(-)

M home/modules/profiles/desktop/dwl/default.nix
M nixos/hosts/laptop-phobos/default.nix
M home/modules/profiles/desktop/dwl/default.nix => home/modules/profiles/desktop/dwl/default.nix +51 -3
@@ 1,6 1,23 @@
{ lib, inputs, config, pkgs, ... }:

let
  # TODO save only those that are on in somewhere like tmp,
  # after enable is called, wake up only these if the file exists
  wlopmScreens = operation: pkgs.writeShellApplication {
    name = "wlopm-all-screens-${operation}";
    runtimeInputs = [
      pkgs.wlopm
      pkgs.gawk
      pkgs.findutils
    ];
    text = ''
      screens=$(wlopm | awk '{print $1}')
      echo "$screens" | xargs -l wlopm --${operation}
    '';
  };

  wlopmDisableScreens = wlopmScreens "off";
  wlopmEnableScreens = wlopmScreens "on";
in {
  imports = [
  ];


@@ 54,17 71,20 @@ in {
    home.file.".config/dwl/sequence-detector.config.json".source = ../qtile/config/sequence-detector.config.json;

    home.packages = [
      # Clipboard
      pkgs.cliphist
      pkgs.wl-clipboard
      # PrintScreening
      pkgs.grim
      pkgs.slurp
      # pkgs.wldash
      pkgs.imv
      # DWL control
      inputs.self.packages.${pkgs.system}.dwlb
      inputs.self.packages.${pkgs.system}.dwlmsg
      pkgs.waylock
      pkgs.wlr-randr
      pkgs.wlrctl
      pkgs.wlopm

      ((pkgs.dwl.override {
        conf = ./config.h;


@@ 76,8 96,8 @@ in {
        src = pkgs.fetchFromGitHub {
          owner = "Rutherther";
          repo = "dwl";
          rev = "3c1dea9f64747d325cd64a9ec53a831e38870763";
          hash = "sha256-yi1zvcA61xy9tXdGr7Y3vk8IIt54In9hTn9a9RcGH0U=";
          rev = "ea81b93e3b29fc39c83c1c92bc025e30b71b376e";
          hash = "sha256-RDWIWuVjR525541ME2dolAQYN1t5BWy1ifY+cno8PVM=";
        };
      }))
    ];


@@ 88,6 108,29 @@ in {
      extraPortals = [ pkgs.xdg-desktop-portal-wlr ];
    };

    programs = {
      swaylock = {
        enable = true;
        settings = {
          color = "808080";
          indicator-radius = 100;
          show-failed-attempts = true;
        };
      };
    };

    services.swayidle = {
      enable = true;
      events = [
        { event = "before-sleep"; command = "${lib.getExe pkgs.swaylock} -Ff"; }
        { event = "lock"; command = "${lib.getExe pkgs.swaylock} -Ff"; }
      ];
      timeouts = [
        { timeout = 300; command = lib.getExe wlopmDisableScreens; resumeCommand = lib.getExe wlopmEnableScreens; }
        { timeout = 1800; command = "${lib.getExe' pkgs.systemd "systemctl"} suspend"; }
      ];
    };

    services.kanshi = {
      enable = true;
      systemdTarget = "wlr-session.target";


@@ 123,6 166,11 @@ in {
      longitude = 14.3225926;
    };

    systemd.user.services.swayidle = {
      Install.WantedBy = lib.mkForce [ "wlr-session.target" ];
      Unit.PartOf = lib.mkForce [ "wlr-session.target" ];
    };

    systemd.user.services.gammastep = {
      Unit.After = lib.mkForce [ "wlr-session.target" ];
      Unit.PartOf = lib.mkForce [ "wlr-session.target" ];

M nixos/hosts/laptop-phobos/default.nix => nixos/hosts/laptop-phobos/default.nix +3 -5
@@ 116,11 116,9 @@
    };
  };

  security.pam.services.waylock = {
    text = ''
      auth include login
    '';
  };
  # TODO put these in relevant files instead
  security.pam.services.waylock = {};
  security.pam.services.swaylock = {};

  # Wireguard
  profiles.vpn.lanIp = "192.168.32.25";

Do not follow this link