From 39d46fa9e150cc7e0a1946737ef3e8618dcacba0 Mon Sep 17 00:00:00 2001 From: Dawson Matthews Date: Thu, 4 Dec 2025 06:57:39 -0700 Subject: [PATCH] removed alternate load profile script and finished up the original one. ready for testing I believe. --- load-display-profile.sh | 7 +++ load-display-profile2.sh | 108 --------------------------------------- 2 files changed, 7 insertions(+), 108 deletions(-) delete mode 100755 load-display-profile2.sh diff --git a/load-display-profile.sh b/load-display-profile.sh index 9a78591..1e9152b 100755 --- a/load-display-profile.sh +++ b/load-display-profile.sh @@ -54,6 +54,9 @@ function enable_outputs { done <<< "$outputs" } +enable_outputs $enabled_outputs +enable_outputs $disabled_outputs + function load_profile_to_outputs { local outputs=$1 while IFS= read -r out; do @@ -92,6 +95,7 @@ function load_profile_to_outputs { done <<< "$outputs" } +load_profile_to_outputs $outputs ######################### # 2. Restore clone groups @@ -100,6 +104,7 @@ function load_profile_to_outputs { clone_groups=$(jq -c '.clones[]?' "$PROFILE") function restore_clone_groups { + local clone_groups=$1 while IFS= read -r clone; do primary=$(echo "$clone" | jq -r '.[0]') others=$(echo "$clone" | jq -r '.[]' | tail -n +2) @@ -110,4 +115,6 @@ function restore_clone_groups { done <<< "$clone_groups" } +restore_clone_groups $clone_groups + echo "Display configuration restored." \ No newline at end of file diff --git a/load-display-profile2.sh b/load-display-profile2.sh deleted file mode 100755 index 7ec3718..0000000 --- a/load-display-profile2.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Make sure a config file was provided -if [ $# -lt 1 ]; then - echo "Usage: $0 " - exit -fi - -PROFILE=$1 - -if [[ ! -f "$PROFILE" ]]; then - echo "Profile file not found: $PROFILE" >&2 - exit 1 -fi - -if ! command -v jq &>/dev/null; then - echo "jq not installed!" >&2 - exit 1 -fi - -if ! command -v kscreen-doctor &>/dev/null; then - echo "kscreen-doctor not found!" >&2 - exit 1 -fi - - -####################### -# Parse JSON + ordering -####################### - -# Extract output entries based on positions -origin_out=$(jq -c '.outputs[] | select(.pos.x == 0 and .pos.y == 0 and .enabled == true)' "$PROFILE") -non_origin_outs=$(jq -c '.outputs[] | select(.pos.x != 0 or .pos.y != 0 or .enable == false)' "$PROFILE") - -####################### -# Function: Apply output -####################### -apply_output() { - local out="$1" - - id=$(echo "$out" | jq -r '.id') - posx=$(echo "$out" | jq -r '.pos.x') - posy=$(echo "$out" | jq -r '.pos.y') - rotation=$(echo "$out" | jq -r '.rotation') - scale=$(echo "$out" | jq -r '.scale') - mode=$(echo "$out" | jq -r '.currentModeId') - priority=$(echo "$out" | jq -r '.priority') - enabled=$(echo "$out" | jq -r '.enabled') - - # Enable/disable - if [[ "$enabled" == "true" ]]; then - kscreen-doctor "output.$id.enable" - else - kscreen-doctor "output.$id.disable" - return - fi - - # Mode - kscreen-doctor "output.$id.mode.$mode" - - # Position - kscreen-doctor "output.$id.position.$posx,$posy" - - # Scale - kscreen-doctor "output.$id.scale.$scale" - - # Rotation - case "$rotation" in - "1") kscreen-doctor "output.$id.rotation.normal" ;; - "2") kscreen-doctor "output.$id.rotation.left" ;; - "4") kscreen-doctor "output.$id.rotation.inverted" ;; - "8") kscreen-doctor "output.$id.rotation.right" ;; - esac - - # Primary - if [ "$priority" -eq 1 ]; then - kscreen-doctor "output.$id.primary" - fi -} - -if [[ -n "$origin_out" ]]; then - apply_output "$origin_out" -fi - -while IFS= read -r out; do - apply_output "$out" -done <<< "$non_origin_outs" - - - -######################### -# 3. Restore clone groups -######################### - -clone_groups=$(jq -c '.clones[]?' "$PROFILE") - -while IFS= read -r clone; do - primary=$(echo "$clone" | jq -r '.[0]') - others=$(echo "$clone" | jq -r '.[]' | tail -n +2) - - for o in $others; do - kscreen-doctor "output.$o.clone.$primary" - done -done <<< "$clone_groups" - -echo "Display configuration restored."