Refactor displayselect
This commit is contained in:
parent
8466ffcfb7
commit
94ec854383
8 changed files with 59 additions and 36 deletions
35
modules/displayselect/default.nix
Normal file
35
modules/displayselect/default.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
{ inputs, ... }:
|
||||
|
||||
{
|
||||
flake.modules.homeManager.gui =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
(pkgs.stdenv.mkDerivation {
|
||||
pname = "displayselect";
|
||||
version = "unstable";
|
||||
|
||||
src = inputs.voidrice;
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
bash
|
||||
xorg.xrandr
|
||||
];
|
||||
|
||||
prePatch = ''
|
||||
cp "$src/.local/bin/displayselect" displayselect
|
||||
'';
|
||||
|
||||
patches = [ ./scaling.patch ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp displayselect $out/bin
|
||||
chmod +x $out/bin/displayselect
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
26
modules/displayselect/scaling.patch
Normal file
26
modules/displayselect/scaling.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
diff --git a/.local/bin/displayselect b/.local/bin/displayselect
|
||||
index 51dd468..c132b7a 100755
|
||||
--- a/displayselect
|
||||
+++ b/displayselect
|
||||
@@ -15,20 +15,13 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
|
||||
|
||||
res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
|
||||
tail -n 1 | awk '{print $1}')
|
||||
- res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
|
||||
- tail -n 1 | awk '{print $1}')
|
||||
|
||||
res_ext_x=$(echo "$res_external" | sed 's/x.*//')
|
||||
res_ext_y=$(echo "$res_external" | sed 's/.*x//')
|
||||
- res_int_x=$(echo "$res_internal" | sed 's/x.*//')
|
||||
- res_int_y=$(echo "$res_internal" | sed 's/.*x//')
|
||||
-
|
||||
- scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
|
||||
- scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)
|
||||
|
||||
xrandr --output "$external" --auto --scale 1.0x1.0 \
|
||||
--output "$internal" --auto --same-as "$external" \
|
||||
- --scale "$scale_x"x"$scale_y"
|
||||
+ --scale-from "${res_ext_x}x${res_ext_y}"
|
||||
else
|
||||
|
||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
|
@ -13,7 +13,7 @@
|
|||
"${pkgs.xdotool}/bin/xdotool type $(cat ~/.local/share/snippets.txt | grep -v '^#' | grep -v '^$' | sort | dmenu -i -l 50 | cut -d' ' -f1)";
|
||||
"super + shift + p" = "${lib.getExe pkgs.passmenu-otp} -i";
|
||||
"super + x; {1, 2, 3, 4}" = "st {notes, newsboat, nmtui, bluetuith}";
|
||||
"@F3" = "${lib.getExe pkgs.displayselect}";
|
||||
"@F3" = "displayselect";
|
||||
"@F9" = "/home/opdavies/.local/bin/mounter";
|
||||
"@F10" = "/home/opdavies/.local/bin/unmounter";
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue