sway: Add hack for mayushii’s external monitor

This commit is contained in:
Simon Bruder 2022-08-25 14:49:31 +02:00
parent 0bbe240018
commit fa773ca8cf
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
2 changed files with 33 additions and 23 deletions

View file

@ -26,6 +26,15 @@ let
wallpaper = if nixosConfig.sbruder.unfree.allowAssets then wallpaperUnfree else wallpaperFree;
cfg = config.wayland.windowManager.sway.config;
# Due to various issues in sway and drm,
# https://github.com/swaywm/sway/issues/5759 and
# https://gitlab.freedesktop.org/drm/amd/-/issues/1376,
# my external monitor often does not turn on after it has been turned off (DPMS).
# This hack fixes this, by not using kanshi for mayushi
# and instead disabling the internal display based on the lid switch state.
# Taken from https://github.com/swaywm/sway/wiki#clamshell-mode
clamshellHack = nixosConfig.networking.hostName == "mayushii";
in
{
imports = lib.optionals nixosConfig.sbruder.gui.enable [
@ -47,7 +56,15 @@ in
menu = "${pkgs.dmenu-wayland}/bin/dmenu-wl_path | ${pkgs.dmenu-wayland}/bin/dmenu-wl -nb '#002b36' -nf '#839496' -sb '#859900' -sf '#073642' | ${pkgs.findutils}/bin/xargs swaymsg exec --";
output."*".bg = "${wallpaper} fill";
output = {
"*".bg = "${wallpaper} fill";
} // (lib.optionalAttrs clamshellHack {
"Acer Technologies Acer B277K 0x0000F36C" = {
position = "1920,0";
scale = "2";
mode = "3840x2160";
};
});
input = {
"type:keyboard" = {
@ -246,7 +263,18 @@ in
dbus-update-activation-environment --systemd ${environmentVariables} && \
systemctl --user start sway-session.target
''
);
) + (lib.optionalString clamshellHack ''
bindswitch --reload --locked lid:on output eDP-1 disable
bindswitch --reload --locked lid:off output eDP-1 enable
exec_always ${pkgs.writeShellScript "sway-lid-switch-toggle-output" /* bash */ ''
if grep -q open /proc/acpi/button/lid/LID/state; then
swaymsg output eDP-1 enable
else
swaymsg output eDP-1 disable
fi
''}
'');
};
systemd.user.targets.sway-session = {

View file

@ -6,27 +6,9 @@ let
else { };
machineConfigs = {
mayushii = {
standalone.outputs = lib.singleton {
criteria = "eDP-1";
mode = "1920x1080";
position = "0,0";
status = "enable";
};
home.outputs = [
{
criteria = "eDP-1";
position = "1920,0";
status = "disable";
}
{
criteria = "Acer Technologies Acer B277K 0x0000F36C";
mode = "3840x2160";
position = "0,0";
scale = 2.0;
}
];
};
# mayushii is handled separately in sways main configuration.
# See it for more details.
# mayushii = { };
sayuri = {
home.outputs = lib.singleton {
criteria = "Acer Technologies Acer B277K 0x0000F36C";