{
  lib,
  config,
  pkgs,
  ...
}: let
  cfg = config.myConfig.sway;
in {
  options.myConfig.sway = {
    enable = lib.mkEnableOption "sway";
    laptop = lib.mkEnableOption "enable laptop things (backlight)";
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = with pkgs; [
      dbus # make dbus-update-activation-environment available in the path
      libnotify
    ];

    # xdg-desktop-portal works by exposing a series of D-Bus interfaces
    # known as portals under a well-known name
    # (org.freedesktop.portal.Desktop) and object path
    # (/org/freedesktop/portal/desktop).
    # The portal interfaces include APIs for file access, opening URIs,
    # printing and others.
    services.dbus.enable = true;
    xdg.portal = {
      enable = true;
      wlr.enable = true;
      config.common.default = ["wlr" "gtk"];
      # gtk portal needed to make gtk apps happy
      extraPortals = [pkgs.xdg-desktop-portal-gtk];
    };

    programs.sway = {
      enable = true;
      wrapperFeatures.gtk = true;
    };

    # make brightness keys work
    users.users.${config.myConfig.user}.extraGroups = ["video" "input"];
    programs.light.enable = lib.mkIf cfg.laptop true;

    # make swaylock work
    security.pam.services.swaylock = {};
  };
}
