2024-07-27 15:22:55 -04:00
|
|
|
defaultSession: {
|
2024-06-30 02:20:12 -04:00
|
|
|
config,
|
|
|
|
lib,
|
2024-11-22 23:15:13 -05:00
|
|
|
mainUser,
|
2024-06-30 02:20:12 -04:00
|
|
|
pkgs,
|
|
|
|
...
|
2024-08-04 20:36:20 -04:00
|
|
|
}: {
|
|
|
|
config = let
|
|
|
|
inherit (lib) findFirst getExe mkForce;
|
2024-06-30 02:20:12 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
switch-session = pkgs.writeShellApplication {
|
|
|
|
name = "switch-session";
|
2024-06-30 02:20:12 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
text = ''
|
|
|
|
mkdir -p /etc/sddm.conf.d
|
2024-06-30 02:20:12 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
cat <<EOF | tee /etc/sddm.conf.d/autologin.conf
|
|
|
|
[Autologin]
|
|
|
|
User=${mainUser}
|
|
|
|
Session=$1
|
|
|
|
Relogin=true
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
};
|
2024-07-27 15:22:55 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
gaming-mode = pkgs.writeShellScriptBin "gaming-mode" ''
|
|
|
|
sudo ${pkgs.systemd}/bin/systemctl start to-gaming-mode.service
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
services.displayManager.sddm = {
|
2024-08-04 18:44:53 -04:00
|
|
|
enable = true;
|
2024-08-04 20:36:20 -04:00
|
|
|
autoLogin.relogin = true;
|
|
|
|
|
|
|
|
wayland = {
|
|
|
|
enable = true;
|
|
|
|
compositorCommand = "kwin";
|
|
|
|
};
|
2024-08-04 18:44:53 -04:00
|
|
|
};
|
2024-06-29 22:53:47 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
# Sets the default session at launch
|
|
|
|
systemd.services."set-session" = {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
before = ["display-manager.service"];
|
2024-06-29 03:45:06 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
path = [switch-session];
|
2024-06-30 02:20:12 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
script = ''
|
|
|
|
switch-session "${defaultSession}"
|
|
|
|
'';
|
|
|
|
};
|
2024-06-30 02:20:12 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
# Allows switching to gaming mode
|
|
|
|
systemd.services."to-gaming-mode" = {
|
|
|
|
wantedBy = mkForce [];
|
2024-06-30 02:20:12 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
path = [switch-session];
|
2024-06-29 03:45:06 -04:00
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
script = ''
|
|
|
|
switch-session "gamescope-wayland"
|
|
|
|
systemctl restart display-manager
|
|
|
|
sleep 10
|
|
|
|
switch-session "${defaultSession}"
|
|
|
|
'';
|
2024-07-31 23:47:15 -04:00
|
|
|
};
|
|
|
|
|
2024-08-04 20:36:20 -04:00
|
|
|
# Make it so we don't need root to switch to gaming mode
|
|
|
|
security.sudo.extraRules = [
|
|
|
|
{
|
|
|
|
users = [mainUser];
|
|
|
|
groups = [100];
|
|
|
|
commands = [
|
|
|
|
{
|
|
|
|
command = "${pkgs.systemd}/bin/systemctl start to-gaming-mode.service";
|
|
|
|
options = ["SETENV" "NOPASSWD"];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
home-manager.users.${mainUser} = {
|
|
|
|
# Add desktop entry to make it GUI friendly
|
|
|
|
xdg.desktopEntries."Gaming Mode" = {
|
|
|
|
name = "Gaming Mode";
|
|
|
|
exec = getExe gaming-mode;
|
|
|
|
icon = "steam";
|
|
|
|
terminal = false;
|
|
|
|
type = "Application";
|
2024-08-04 18:44:53 -04:00
|
|
|
};
|
2024-08-04 20:36:20 -04:00
|
|
|
|
|
|
|
home.file."Desktop/Gaming Mode.desktop".source =
|
|
|
|
(
|
|
|
|
findFirst
|
|
|
|
(x: x.meta.name == "Gaming Mode.desktop") {}
|
|
|
|
config.home-manager.users.mariah.home.packages
|
|
|
|
)
|
|
|
|
+ "/share/applications/Gaming Mode.desktop";
|
|
|
|
|
|
|
|
# Fix remote control prompt showing up everytime
|
|
|
|
xdg.configFile = let
|
|
|
|
mkAutostart = name: flags: {
|
|
|
|
"autostart/${name}.desktop".text = "[Desktop Entry]\nType=Application\nExec=${name} ${flags}";
|
|
|
|
};
|
|
|
|
in (
|
|
|
|
# Needs xdg-desktop-portal-kde patch provided by `self.overlays.xdg-desktop-portal-kde`
|
|
|
|
{"plasmaremotedesktoprc".text = "[Sharing]\nUnattended=true";}
|
|
|
|
// (mkAutostart "krfb" "--nodialog %c")
|
|
|
|
// (mkAutostart "steam" "-silent %U")
|
|
|
|
);
|
|
|
|
};
|
2024-06-30 02:20:12 -04:00
|
|
|
};
|
2024-08-04 20:36:20 -04:00
|
|
|
|
|
|
|
# For accurate stack trace
|
|
|
|
_file = ./session-switching.nix;
|
2024-06-29 03:45:06 -04:00
|
|
|
}
|