♻️ refactor(hypr): focused monitor script changed from python to bash

This commit is contained in:
Sergio Laín 2023-10-09 14:50:54 +02:00
parent f5428b9a0e
commit b9234e1469
No known key found for this signature in database
GPG key ID: 14C9B8080681777B

View file

@ -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