commit be83449995c5eea04281a0db5a12ebdf1a2b4c76 Author: Mohammed Goder Date: Thu Mar 14 15:13:28 2024 -0500 Upload files to "/" diff --git a/hyprlock.sh b/hyprlock.sh new file mode 100644 index 0000000..bec8566 --- /dev/null +++ b/hyprlock.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Use "hyprctl -j monitors" to determine the parameters for the lock and unlock positions. +unlockedMonitorYPositions=(0 0 0) +lockedMonitorYPositions=(1080 1080 1080) + +monitors=$(hyprctl -j monitors) +monitorIndices=$(seq 0 $(($(echo "$monitors" | jq length)-1))) + +if [ "$1" == "" ]; then + 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") + + 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 + exit + done +elif [ "$1" == "status" ]; then + for monitorIndex in $monitorIndices; do + if [ $(echo "$monitors" | jq -j ".[$monitorIndex].y") == ${unlockedMonitorYPositions[$monitorIndex]} ]; + then echo Monitor $monitorIndex: Unlocked + else echo Monitor $monitorIndex: Locked; + fi + done + exit +fi + +monitor=$(echo "$monitors" | jq -c ".[$1]") + +unlockedMonitorYPosition=${unlockedMonitorYPositions[$1]} + +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") + + 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