From 10c7fc8e917faa6b03216a7c536c344a3ce0c27d Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 27 Sep 2023 21:42:55 +0000 Subject: [PATCH] sxmo: exit fullscreen on screen rotation --- hosts/modules/gui/sxmo/default.nix | 16 +++++++++++----- hosts/modules/gui/sxmo/hooks/sxmo_hook_rotate.sh | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100755 hosts/modules/gui/sxmo/hooks/sxmo_hook_rotate.sh diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index a91cc26f..67567a5d 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -73,15 +73,20 @@ let src = ./hooks; pkgs = [ "coreutils" ]; }; + postwake = pkgs.static-nix-shell.mkBash { + pname = "sxmo_hook_postwake.sh"; + src = ./hooks; + }; + rotate = pkgs.static-nix-shell.mkBash { + pname = "sxmo_hook_rotate.sh"; + src = ./hooks; + pkgs = [ "sway" ]; + }; start = pkgs.static-nix-shell.mkBash { pname = "sxmo_hook_start.sh"; src = ./hooks; pkgs = [ "superd" "xdg-user-dirs" ]; }; - postwake = pkgs.static-nix-shell.mkBash { - pname = "sxmo_hook_postwake.sh"; - src = ./hooks; - }; }; in { @@ -123,9 +128,10 @@ in sane.gui.sxmo.hooks = mkOption { type = types.attrsOf types.path; default = { - "sxmo_hook_start.sh" = "${hookPkgs.start}/bin/sxmo_hook_start.sh"; "sxmo_hook_inputhandler.sh" = "${hookPkgs.inputhandler}/bin/sxmo_hook_inputhandler.sh"; "sxmo_hook_postwake.sh" = "${hookPkgs.postwake}/bin/sxmo_hook_postwake.sh"; + "sxmo_hook_rotate.sh" = "${hookPkgs.rotate}/bin/sxmo_hook_rotate.sh"; + "sxmo_hook_start.sh" = "${hookPkgs.start}/bin/sxmo_hook_start.sh"; }; description = '' extra hooks to add with higher priority than the builtins diff --git a/hosts/modules/gui/sxmo/hooks/sxmo_hook_rotate.sh b/hosts/modules/gui/sxmo/hooks/sxmo_hook_rotate.sh new file mode 100755 index 00000000..5b55ffe8 --- /dev/null +++ b/hosts/modules/gui/sxmo/hooks/sxmo_hook_rotate.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p sway + +# called whenever sxmo_rotate.sh is invoked. +# i.e. whenever the screen is rotated manually, or automatically if autorotate is enabled. +# $1 = the new orientation +# possible values are "normal", "invert", "left" and "right" + +# exit fullscreen, if any app is in FS. +# this benefits UX because: +# - most of my FS use is in landscape mode +# - when i toggle apps or desktops i always do so in portrait mode +# - therefore when i rotate landscape -> portrait mode, i almost never want fullscreen anymore. +if "$1" == "normal" || "$1" == "invert"; then + swaymsg fullscreen disable +fi