From 05fd1bed80ff244c2302c2d33c4e2ae75843458c Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 9 Oct 2024 00:02:32 +0200 Subject: [PATCH] feat(sway-desktop): set up for screensharing of headless outputs --- nix/home-manager/profiles/sway-desktop.nix | 15 +++++++++++++++ nix/home-manager/programs/waybar.nix | 9 ++++++++- nix/os/snippets/sway-desktop.nix | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/nix/home-manager/profiles/sway-desktop.nix b/nix/home-manager/profiles/sway-desktop.nix index dcf6544..6f093be 100644 --- a/nix/home-manager/profiles/sway-desktop.nix +++ b/nix/home-manager/profiles/sway-desktop.nix @@ -1,3 +1,18 @@ +/* +TODO: create helper scripts for sharing of a screen portion +``` +swaymsg create_output + +# find the name and the workspace number +swaymsg -t get_outputs | jq '.[] | select(.name | test("HEADLESS-.*")) | (.name, .current_workspace)' + +swaymsg output HEADLESS-1 mode 1920@108060Hz + +# mirror the headless workspace on the current one +nix run nixpkgs\#wl-mirror -- HEADLESS-1 + +# shift windows to the workspace and switch the focus to it +*/ { pkgs, config, diff --git a/nix/home-manager/programs/waybar.nix b/nix/home-manager/programs/waybar.nix index 05392c5..b6137e1 100644 --- a/nix/home-manager/programs/waybar.nix +++ b/nix/home-manager/programs/waybar.nix @@ -22,7 +22,14 @@ layer = "top"; position = "bottom"; height = 30; - output = ["*"]; + output = + # hide the bar on HEADDLESS displays as i use them only for screensharing + ( + builtins.genList (i: "!HEADLESS-${builtins.toString i}") 99 + ) + ++ [ + "*" + ]; # output = [ # "eDP-1" # "DP-*" diff --git a/nix/os/snippets/sway-desktop.nix b/nix/os/snippets/sway-desktop.nix index ec6859c..8d6d9f1 100644 --- a/nix/os/snippets/sway-desktop.nix +++ b/nix/os/snippets/sway-desktop.nix @@ -40,6 +40,25 @@ in { wlr = { enable = true; + settings = { + screencast = { + chooser_type = "dmenu"; + # display the output as a list in favor of the default mouse selection + chooser_cmd = lib.getExe (pkgs.writeShellApplication { + name = "chooser_cmd"; + runtimeInputs = [ + pkgs.sway + pkgs.jq + pkgs.fuzzel + pkgs.gnused + ]; + text = '' + swaymsg -t get_outputs | jq '.[] | "\(.name)@\(.current_mode.width)x\(.current_mode.height) on \(.model)"' | sed 's/"//g' | fuzzel -d | sed 's/@.*//' + ''; + }); + max_fps = 30; + }; + }; }; # keep the behaviour in < 1.17, which uses the first portal implementation found in lexicographical order, use the following: