From b9234e1469b93b4eef2664501a732b48a965ecc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Mon, 9 Oct 2023 14:50:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(hypr):=20focused?= =?UTF-8?q?=20monitor=20script=20changed=20from=20python=20to=20bash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/hypr/scripts/focused_monitor | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.config/hypr/scripts/focused_monitor b/.config/hypr/scripts/focused_monitor index a2712409..fddd8c1c 100755 --- a/.config/hypr/scripts/focused_monitor +++ b/.config/hypr/scripts/focused_monitor @@ -1,16 +1,18 @@ -#!/usr/bin/env python3 -import subprocess +#!/usr/bin/bash -monitor_data = subprocess.check_output(["hyprctl", "monitors"], text=True) -lines = monitor_data.split("\n") +MONITOR_DATA=$(hyprctl monitors) +readarray -t LINES <<<"$MONITOR_DATA" -current_monitor = "" +CURRENT_MONITOR="" # Recorrer las lĂ­neas y buscar el nombre y el estado enfocado -for line in lines: - if "Monitor" in line: - current_monitor = line.split(" ", 1)[1].split(" ")[0] +for LINE in "${LINES[@]}"; do + if [[ $LINE == *"Monitor"* ]]; then + CURRENT_MONITOR=$(echo $LINE | awk '{print $2}') + fi - if "focused: yes" in line: - print(current_monitor) + if [[ $LINE == *"focused: yes"* ]]; then + echo $CURRENT_MONITOR break + fi +done