making changes to get back lost progress from yesterday
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
profiles/*.json
|
||||||
@@ -25,18 +25,40 @@ if ! command -v kscreen-doctor &>/dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Parse JSON + restore
|
|
||||||
#######################
|
|
||||||
|
|
||||||
# Extract outputs list
|
# Extract outputs list
|
||||||
|
enabled_outputs=$(jq -c '.outputs[] | select(.enabled=="true")' "$PROFILE")
|
||||||
|
echo "enabled:"
|
||||||
|
echo $enabled_outputs
|
||||||
|
disabled_outputs=$(jq -c '.outputs[] | select(.enabled=="false")' "$PROFILE")
|
||||||
|
echo "disabled:"
|
||||||
|
echo $dis
|
||||||
outputs=$(jq -c '.outputs[]' "$PROFILE")
|
outputs=$(jq -c '.outputs[]' "$PROFILE")
|
||||||
|
|
||||||
# 1. Restore enabled/disabled + basic properties
|
# Restore enabled/disabled starting with the enabled monitors
|
||||||
|
# Starting with a disabled monitor might not work if it was
|
||||||
|
# previously the only enabled monitor
|
||||||
|
|
||||||
|
function enable_outputs {
|
||||||
|
local outputs=$1
|
||||||
while IFS= read -r out; do
|
while IFS= read -r out; do
|
||||||
id=$(echo "$out" | jq -r '.id')
|
id=$(echo "$out" | jq -r '.id')
|
||||||
|
name=$(echo "$out" | jq -r '.name')
|
||||||
enabled=$(echo "$out" | jq -r '.enabled')
|
enabled=$(echo "$out" | jq -r '.enabled')
|
||||||
|
|
||||||
|
# Enable/disable
|
||||||
|
if [[ "$enabled" == "true" ]]; then
|
||||||
|
kscreen-doctor "output.$name.enable"
|
||||||
|
else
|
||||||
|
kscreen-doctor "output.$name.disable"
|
||||||
|
fi
|
||||||
|
done <<< "$outputs"
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_profile_to_outputs {
|
||||||
|
local outputs=$1
|
||||||
|
while IFS= read -r out; do
|
||||||
|
id=$(echo "$out" | jq -r '.id')
|
||||||
|
name=$(echo "$out" | jq -r '.name')
|
||||||
posx=$(echo "$out" | jq -r '.pos.x')
|
posx=$(echo "$out" | jq -r '.pos.x')
|
||||||
posy=$(echo "$out" | jq -r '.pos.y')
|
posy=$(echo "$out" | jq -r '.pos.y')
|
||||||
rotation=$(echo "$out" | jq -r '.rotation')
|
rotation=$(echo "$out" | jq -r '.rotation')
|
||||||
@@ -44,14 +66,6 @@ while IFS= read -r out; do
|
|||||||
mode=$(echo "$out" | jq -r '.currentModeId')
|
mode=$(echo "$out" | jq -r '.currentModeId')
|
||||||
priority=$(echo "$out" | jq -r '.priority')
|
priority=$(echo "$out" | jq -r '.priority')
|
||||||
|
|
||||||
# Enable/disable
|
|
||||||
if [[ "$enabled" == "true" ]]; then
|
|
||||||
kscreen-doctor "output.$id.enable"
|
|
||||||
else
|
|
||||||
kscreen-doctor "output.$id.disable"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Mode (Resolution + refresh)
|
# Mode (Resolution + refresh)
|
||||||
kscreen-doctor "output.$id.mode.$mode"
|
kscreen-doctor "output.$id.mode.$mode"
|
||||||
|
|
||||||
@@ -75,8 +89,9 @@ while IFS= read -r out; do
|
|||||||
kscreen-doctor "output.$id.primary"
|
kscreen-doctor "output.$id.primary"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
done <<< "$outputs"
|
done <<< "$outputs"
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
@@ -85,6 +100,7 @@ done <<< "$outputs"
|
|||||||
|
|
||||||
clone_groups=$(jq -c '.clones[]?' "$PROFILE")
|
clone_groups=$(jq -c '.clones[]?' "$PROFILE")
|
||||||
|
|
||||||
|
function restore_clone_groups {
|
||||||
while IFS= read -r clone; do
|
while IFS= read -r clone; do
|
||||||
primary=$(echo "$clone" | jq -r '.[0]')
|
primary=$(echo "$clone" | jq -r '.[0]')
|
||||||
others=$(echo "$clone" | jq -r '.[]' | tail -n +2)
|
others=$(echo "$clone" | jq -r '.[]' | tail -n +2)
|
||||||
@@ -93,5 +109,6 @@ while IFS= read -r clone; do
|
|||||||
kscreen-doctor "output.$o.clone.$primary"
|
kscreen-doctor "output.$o.clone.$primary"
|
||||||
done
|
done
|
||||||
done <<< "$clone_groups"
|
done <<< "$clone_groups"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Display configuration restored."
|
echo "Display configuration restored."
|
||||||
Reference in New Issue
Block a user