args@{ lib, config, pkgs, ... }: with lib; let psCfg = config.pub-solar; in { options.pub-solar.graphical = { v4l2loopback.enable = mkOption { type = types.bool; default = false; description = "WebCam streaming tool"; }; }; config = { boot = mkIf psCfg.graphical.v4l2loopback.enable { extraModulePackages = with config.boot.kernelPackages; [v4l2loopback]; kernelModules = ["v4l2loopback"]; extraModprobeConfig = '' options v4l2loopback exclusive_caps=1 devices=3 ''; }; environment.systemPackages = with pkgs; [ linuxPackages.v4l2loopback ]; programs.sway.enable = true; xdg.portal = { enable = true; wlr = { enable = true; settings = { screencast = { max_fps = 30; chooser_type = "simple"; chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; }; }; }; config.sway = { # https://alex.dandrea.io/2024/07/20/fixing-idle-inhibitor-behaviour-in-firefox-with-wayland/ # Use xdg-desktop-portal-gtk for every portal interface... default = "gtk"; # ... except for the ScreenCast, Screenshot and Secret "org.freedesktop.impl.portal.ScreenCast" = "wlr"; "org.freedesktop.impl.portal.Screenshot" = "wlr"; # ignore inhibit bc gtk portal always returns as success, # despite sway/the wlr portal not having an implementation, # stopping firefox from using wayland idle-inhibit "org.freedesktop.impl.portal.Inhibit" = "none"; }; extraPortals = with pkgs; [xdg-desktop-portal-gtk]; }; services.pipewire.enable = true; users.users."${psCfg.user.name}".packages = with pkgs; [ sway grim kanshi slurp swaybg xwayland libappindicator-gtk3 wl-clipboard wf-recorder brightnessctl xsettingsd ydotool sway-launcher record-screen import-gtk-settings s wcwd ]; services.geoclue2.enable = true; home-manager.users."${psCfg.user.name}" = { systemd.user.services.sway = import ./sway.service.nix args; systemd.user.targets.sway-session = import ./sway-session.target.nix args; services.xsettingsd.enable = true; services.gammastep = { enable = true; provider = "geoclue2"; }; xdg.configFile."sway/config".text = import ./config/config.nix args; services.swayidle = with pkgs; { enable = true; events = [ { event = "before-sleep"; command = "${systemd}/bin/systemctl hibernate"; } ]; timeouts = [ { timeout = 300; command = "${swaylock-bg}/bin/swaylock-bg"; } { timeout = 180; command = "${sway}/bin/swaymsg \"output * dpms off\""; resumeCommand = "${sway}/bin/swaymsg \"output * dpms on\""; } { timeout = 600; command = "${systemd}/bin/systemctl hibernate"; } ]; systemdTarget = "sway-session.target"; }; }; }; }