nix-config/pkgs/primary-xwayland/default.nix
Greg Burd f3fd89af54
A fork of Misterio77 and his standard template.
Many thangs to the hard work and generous availability of:
git@github.com:Misterio77/nix-config.git
2023-09-15 10:53:38 -04:00

22 lines
703 B
Nix

# Sets the largest monitor as primary xwayland display, or select one with slurp
{ lib, writeShellApplication, xrandr, slurp }: (writeShellApplication {
name = "primary-xwayland";
runtimeInputs = [ slurp xrandr ];
text = /* bash */ ''
if [ "$#" -ge 1 ] && [ "$1" == "largest" ]; then
output=$(xrandr --listmonitors | tail -n +2 | awk '{printf "%s %s\n", $3, $4}' | sort | tail -1 | cut -d ' ' -f2)
else
selected=$(slurp -f "%wx%h+%x+%y" -o)
output=$(xrandr | grep "$selected" | cut -d ' ' -f1)
fi
echo "Setting $output"
xrandr --output "$output" --primary
'';
}) // {
meta = with lib; {
license = licenses.mit;
platforms = platforms.all;
};
}