From 9386b9e64479faed6d1178b88600fe39730a1ff3 Mon Sep 17 00:00:00 2001 From: Mohammed Goder Date: Thu, 14 Mar 2024 16:32:10 -0500 Subject: [PATCH] Update hyprlock.sh --- hyprlock.sh | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/hyprlock.sh b/hyprlock.sh index bec8566..7f7820a 100644 --- a/hyprlock.sh +++ b/hyprlock.sh @@ -8,28 +8,36 @@ monitors=$(hyprctl -j monitors) monitorIndices=$(seq 0 $(($(echo "$monitors" | jq length)-1))) if [ "$1" == "" ]; then + monitorUnlocked=0 + for monitorIndex in $monitorIndices; do + monitor=$(echo "$monitors" | jq -c ".[$monitorIndex]") + + unlockedMonitorYPosition=${unlockedMonitorYPositions[$monitorIndex]} + + if [ $(echo "$monitor" | jq -j ".y") -eq $unlockedMonitorYPosition ]; then continue; fi + + hyprctl keyword monitor $(echo "$monitor" | jq -j ".name"),$(echo "$monitor" | jq -j ".width")x$(echo "$monitor" | jq -j ".height")@$(echo "$monitor" | jq -j ".refreshRate"),$(echo "$monitor" | jq -j ".x")x$unlockedMonitorYPosition,$(echo "$monitor" | jq -j ".scale") + + monitorUnlocked=1 + + echo Unlocked monitor $monitorIndex + done + + if [ $monitorUnlocked -eq 1 ]; then exit; fi + for monitorIndex in $monitorIndices; do monitor=$(echo "$monitors" | jq -c ".[$monitorIndex]") if [ $(echo "$monitor" | jq -j ".focused") == "false" ]; then continue; fi - unlockedMonitorYPosition=${unlockedMonitorYPositions[$monitorIndex]} - - if [ $(echo "$monitor" | jq -j ".y") == $unlockedMonitorYPosition ]; then - hyprctl keyword monitor $(echo "$monitor" | jq -j ".name"),$(echo "$monitor" | jq -j ".width")x$(echo "$monitor" | jq -j ".height")@$(echo "$monitor" | jq -j ".refreshRate"),$(echo "$monitor" | jq -j ".x")x${lockedMonitorYPositions[$monitorIndex]},$(echo "$monitor" | jq -j ".scale") + hyprctl keyword monitor $(echo "$monitor" | jq -j ".name"),$(echo "$monitor" | jq -j ".width")x$(echo "$monitor" | jq -j ".height")@$(echo "$monitor" | jq -j ".refreshRate"),$(echo "$monitor" | jq -j ".x")x${lockedMonitorYPositions[$monitorIndex]},$(echo "$monitor" | jq -j ".scale") - echo Locked monitor $monitorIndex - exit - fi - - hyprctl keyword monitor $(echo "$monitor" | jq -j ".name"),$(echo "$monitor" | jq -j ".width")x$(echo "$monitor" | jq -j ".height")@$(echo "$monitor" | jq -j ".refreshRate"),$(echo "$monitor" | jq -j ".x")x$unlockedMonitorYPosition,$(echo "$monitor" | jq -j ".scale") - - echo Unlocked monitor $monitorIndex + echo Locked monitor $monitorIndex exit done elif [ "$1" == "status" ]; then for monitorIndex in $monitorIndices; do - if [ $(echo "$monitors" | jq -j ".[$monitorIndex].y") == ${unlockedMonitorYPositions[$monitorIndex]} ]; + if [ $(echo "$monitors" | jq -j ".[$monitorIndex].y") -eq ${unlockedMonitorYPositions[$monitorIndex]} ]; then echo Monitor $monitorIndex: Unlocked else echo Monitor $monitorIndex: Locked; fi @@ -41,7 +49,7 @@ monitor=$(echo "$monitors" | jq -c ".[$1]") unlockedMonitorYPosition=${unlockedMonitorYPositions[$1]} -if [ $(echo "$monitor" | jq -j ".y") == $unlockedMonitorYPosition ]; then +if [ $(echo "$monitor" | jq -j ".y") -eq $unlockedMonitorYPosition ]; then hyprctl keyword monitor $(echo "$monitor" | jq -j ".name"),$(echo "$monitor" | jq -j ".width")x$(echo "$monitor" | jq -j ".height")@$(echo "$monitor" | jq -j ".refreshRate"),$(echo "$monitor" | jq -j ".x")x${lockedMonitorYPositions[$monitorIndex]},$(echo "$monitor" | jq -j ".scale") echo Locked monitor $monitorIndex @@ -50,4 +58,4 @@ fi hyprctl keyword monitor $(echo "$monitor" | jq -j ".name"),$(echo "$monitor" | jq -j ".width")x$(echo "$monitor" | jq -j ".height")@$(echo "$monitor" | jq -j ".refreshRate"),$(echo "$monitor" | jq -j ".x")x$unlockedMonitorYPosition,$(echo "$monitor" | jq -j ".scale") -echo Unlocked monitor $monitorIndex +echo Unlocked monitor $monitorIndex \ No newline at end of file