mirror of
https://github.com/jbowdre/dotfiles.git
synced 2024-11-26 02:52:18 +00:00
22 lines
703 B
Nix
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;
|
|
};
|
|
}
|