mirror of
https://github.com/gburd/nix-config.git
synced 2024-11-20 10:36:25 +00:00
f3fd89af54
Many thangs to the hard work and generous availability of: git@github.com:Misterio77/nix-config.git
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;
|
|
};
|
|
}
|