home/sway: add automatic laptop ad tablet mode for 2in1 devices

This commit is contained in:
2026-01-24 09:03:30 +01:00
parent aef788b5f1
commit 4356a2c4e4

View File

@@ -15,6 +15,15 @@ let
GEOM="$(${lib.getExe pkgs.slurp} -d)" GEOM="$(${lib.getExe pkgs.slurp} -d)"
${lib.getExe pkgs.grim} -g "$GEOM" - | ${pkgs.wl-clipboard}/bin/wl-copy ${lib.getExe pkgs.grim} -g "$GEOM" - | ${pkgs.wl-clipboard}/bin/wl-copy
''; '';
switch_laptop_mode = pkgs.writeShellScriptBin "switch_laptop_mode" ''
${pkgs.procps}/bin/pkill rot8 && \
${pkgs.sway}/bin/swaymsg output eDP-1 transform 0
'';
switch_tablet_mode = pkgs.writeShellScriptBin "switch_tablet_mode" ''
${lib.getExe pkgs.rot8} \
--invert-y \
--hooks ''\'systemctl --user restart lisgd.service''\'
'';
swaysw = inputs.swaysw.packages.${system}.swaysw; swaysw = inputs.swaysw.packages.${system}.swaysw;
term = "${pkgs.foot}/bin/footclient"; term = "${pkgs.foot}/bin/footclient";
in in
@@ -24,6 +33,11 @@ in
extraSessionCommands = ""; extraSessionCommands = "";
extraConfigEarly = ''''; extraConfigEarly = '''';
extraConfig = ''
bindswitch tablet:on exec ${switch_tablet_mode}/bin/switch_tablet_mode
bindswitch tablet:off exec ${switch_laptop_mode}/bin/switch_laptop_mode
'';
config = { config = {
fonts = { fonts = {
names = [ "JetBrainsMono" ]; names = [ "JetBrainsMono" ];