Compare commits
2 Commits
54b3b0373d
...
7180d12bb8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7180d12bb8 | ||
|
|
4ae2967529 |
24
flake.lock
generated
24
flake.lock
generated
@@ -73,11 +73,11 @@
|
|||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760347839,
|
"lastModified": 1760491443,
|
||||||
"narHash": "sha256-ltUxXWWx0hC1uzx8b6ezM5YejCVng2ZNYhxjnpwlecI=",
|
"narHash": "sha256-f99YQJn2rXiOiBNkVPLzn7dVuKlj9IZM/b7ldaNP1PI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "emacs-overlay",
|
"repo": "emacs-overlay",
|
||||||
"rev": "5f44d9b4967818419c40480a1fa18d9d90c5f576",
|
"rev": "2f62ce25357ec7195a83cb800197222f69c0265c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -114,11 +114,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760312644,
|
"lastModified": 1760500983,
|
||||||
"narHash": "sha256-U9SkK45314urw9P7MmjhEgiQwwD/BTj+T3HTuz1JU1Q=",
|
"narHash": "sha256-zfY4F4CpeUjTGgecIJZ+M7vFpwLc0Gm9epM/iMQd4w8=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "e121f3773fa596ecaba5b22e518936a632d72a90",
|
"rev": "c53e65ec92f38d30e3c14f8d628ab55d462947aa",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -200,11 +200,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760038930,
|
"lastModified": 1760284886,
|
||||||
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
|
"narHash": "sha256-TK9Kr0BYBQ/1P5kAsnNQhmWWKgmZXwUQr4ZMjCzWf2c=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
|
"rev": "cf3f5c4def3c7b5f1fc012b3d839575dbe552d43",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -216,11 +216,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-stable": {
|
"nixpkgs-stable": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760139962,
|
"lastModified": 1760423683,
|
||||||
"narHash": "sha256-4xggC56Rub3WInz5eD7EZWXuLXpNvJiUPahGtMkwtuc=",
|
"narHash": "sha256-Tb+NYuJhWZieDZUxN6PgglB16yuqBYQeMJyYBGCXlt8=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7e297ddff44a3cc93673bb38d0374df8d0ad73e4",
|
"rev": "a493e93b4a259cd9fea8073f89a7ed9b1c5a1da2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ in
|
|||||||
env = GDK_DPI_SCALE,1.5
|
env = GDK_DPI_SCALE,1.5
|
||||||
env = XCURSOR_SIZE,64
|
env = XCURSOR_SIZE,64
|
||||||
|
|
||||||
monitor=eDP-1, 1920x1200, 0x0, 1
|
monitor=eDP-1, 1920x1200, auto-center-down, 1
|
||||||
|
monitor=HDMI-A-1, 2560x1440@100, auto-center-up, 1
|
||||||
|
|
||||||
workspace = 1, monitor:HDMI-A-1
|
workspace = 1, monitor:HDMI-A-1
|
||||||
workspace = 2, monitor:HDMI-A-1
|
workspace = 2, monitor:HDMI-A-1
|
||||||
@@ -177,88 +178,5 @@ in
|
|||||||
|
|
||||||
# openGL is needed for wayland/hyprland
|
# openGL is needed for wayland/hyprland
|
||||||
hardware.graphics.enable = true;
|
hardware.graphics.enable = true;
|
||||||
|
|
||||||
systemd.user.services.hyprland-monitors = {
|
|
||||||
# systemctl --user restart hyprland-monitors.service
|
|
||||||
# journalctl --user -u hyprland-monitors.service -e -f
|
|
||||||
unitConfig = {
|
|
||||||
Description = "handles hyprland monitor connect/disconnect";
|
|
||||||
};
|
|
||||||
|
|
||||||
wantedBy = [ "graphical-session.target" ];
|
|
||||||
requires = [ "graphical-session.target" ];
|
|
||||||
after = [ "graphical-session.target" ];
|
|
||||||
|
|
||||||
path = [
|
|
||||||
pkgs.coreutils # to include `cat`
|
|
||||||
pkgs.waybar
|
|
||||||
pkgs.hyprland
|
|
||||||
pkgs.socat
|
|
||||||
pkgs.jq
|
|
||||||
pkgs.bc
|
|
||||||
pkgs.libnotify
|
|
||||||
];
|
|
||||||
|
|
||||||
script =
|
|
||||||
let
|
|
||||||
moveWSToMonitor =
|
|
||||||
monitor: first: last:
|
|
||||||
if last < first then
|
|
||||||
throw "'first' has to be less than or equal to 'last'"
|
|
||||||
else
|
|
||||||
builtins.genList (
|
|
||||||
n: "dispatch moveworkspacetomonitor ${builtins.toString (first + n)} ${monitor}"
|
|
||||||
) (last - first + 1);
|
|
||||||
|
|
||||||
external = moveWSToMonitor "HDMI-A-1" 1 5;
|
|
||||||
internal = moveWSToMonitor "eDPI-1" 6 10;
|
|
||||||
onlyInternal = moveWSToMonitor "eDPI-1" 1 10;
|
|
||||||
in
|
|
||||||
''
|
|
||||||
update() {
|
|
||||||
HDMI_STATUS=$(cat /sys/class/drm/card1-HDMI-A-1/status)
|
|
||||||
|
|
||||||
INTERNAL_WIDTH=1920
|
|
||||||
INTERNAL_HEIGHT=1200
|
|
||||||
|
|
||||||
if [ $HDMI_STATUS = "connected" ]; then
|
|
||||||
notify-send "Using external and laptop monitor"
|
|
||||||
|
|
||||||
hyprctl keyword monitor HDMI-A-1,preferred,0x0,1
|
|
||||||
|
|
||||||
HDMI=$(hyprctl monitors -j | jq '.[] | select(.name=="HDMI-A-1")')
|
|
||||||
HDMI_WIDTH=$(echo $HDMI | jq .width)
|
|
||||||
HDMI_HEIGHT=$(echo $HDMI | jq .height)
|
|
||||||
|
|
||||||
INTERNAL_POS_X=$(echo "($HDMI_WIDTH - $INTERNAL_WIDTH) / 2" | bc)
|
|
||||||
if (( $(echo "$INTERNAL_POS_X < 0" | bc) )); then INTERNAL_POS_X=0; fi
|
|
||||||
INTERNAL_POS_Y=$HDMI_HEIGHT
|
|
||||||
|
|
||||||
hyprctl keyword monitor eDP-1,$INTERNAL_WIDTH"x"$INTERNAL_HEIGHT,$INTERNAL_POS_X"x"$INTERNAL_POS_Y,1
|
|
||||||
hyprctl --batch "${lib.strings.concatStringsSep ";" (external ++ internal)}"
|
|
||||||
else
|
|
||||||
notify-send "Using only laptop monitor"
|
|
||||||
|
|
||||||
hyprctl --batch "keyword monitor HDMI-A,disable; keyword monitor eDP-1,$INTERNAL_WIDTH"x"$INTERNAL_HEIGHT,0x0,1"
|
|
||||||
hyprctl --batch "${lib.strings.concatStringsSep ";" onlyInternal}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
handle() {
|
|
||||||
case $1 in
|
|
||||||
monitoradded\>\>*|monitorremoved\>\>*)
|
|
||||||
echo "handling event: \"$1\""
|
|
||||||
update ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Starting service with instance \"$HYPRLAND_INSTANCE_SIGNATURE\""
|
|
||||||
|
|
||||||
# Do initial configuration
|
|
||||||
update
|
|
||||||
|
|
||||||
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user