From a1225d7b49f66d9743b344c46f722cdbb70cb3d7 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 2 Aug 2024 20:56:49 -0400 Subject: [PATCH] hyprland: improve clamshell script off checks --- homeManagerModules/desktop/hyprland/scripts.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeManagerModules/desktop/hyprland/scripts.nix b/homeManagerModules/desktop/hyprland/scripts.nix index 0d2590ae..c003b8fa 100644 --- a/homeManagerModules/desktop/hyprland/scripts.nix +++ b/homeManagerModules/desktop/hyprland/scripts.nix @@ -6,21 +6,24 @@ }: let cfg = config.ar.home; hyprctl = lib.getExe' config.wayland.windowManager.hyprland.package "hyprctl"; - pkill = lib.getExe' pkgs.procps "pkill"; virtKeyboard = lib.getExe' pkgs.squeekboard "squeekboard"; in { clamshell = pkgs.writeShellScript "hyprland-clamshell" '' NUM_MONITORS=$(${hyprctl} monitors all | grep Monitor | wc --lines) + EDP_STATUS=$(${hyprctl} monitors all | grep -A 15 "Monitor eDP-1" | grep "disabled:") if [ "$1" == "on" ]; then if [ $NUM_MONITORS -gt 1 ]; then ${hyprctl} keyword monitor "eDP-1, disable" fi elif [ "$1" == "off" ]; then - ${ + # Check if the monitor is disabled + if echo "$EDP_STATUS" | grep -q "disabled: true"; then + ${ lib.strings.concatMapStringsSep "${hyprctl}\n" (monitor: ''${hyprctl} keyword monitor "${monitor}"'') cfg.desktop.hyprland.laptopMonitors } + fi fi '';