more fixes...
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERBOSE=1
|
||||
|
||||
function log {
|
||||
if [ $VERBOSE -eq 1 ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
set -e
|
||||
|
||||
# Make sure a config file was provided
|
||||
@@ -27,11 +34,7 @@ fi
|
||||
|
||||
# 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 $disabled_outputs
|
||||
outputs=$(jq -c '.outputs[]' "$PROFILE")
|
||||
|
||||
# Restore enabled/disabled starting with the enabled monitors
|
||||
@@ -40,25 +43,42 @@ outputs=$(jq -c '.outputs[]' "$PROFILE")
|
||||
|
||||
function enable_outputs {
|
||||
local outputs=$1
|
||||
|
||||
# If empty or only whitespace, return early
|
||||
[[ -z "$outputs" ]] && return
|
||||
|
||||
while IFS= read -r out; do
|
||||
id=$(echo "$out" | jq -r '.id')
|
||||
log "[VAR] id:" $id
|
||||
name=$(echo "$out" | jq -r '.name')
|
||||
log "[VAR] name:" $name
|
||||
enabled=$(echo "$out" | jq -r '.enabled')
|
||||
log "[VAR] enabled:" $enabled
|
||||
|
||||
# Enable/disable
|
||||
if [[ "$enabled" == "true" ]]; then
|
||||
kscreen-doctor "output.$name.enable"
|
||||
CMD="kscreen-doctor output.$name.enable"
|
||||
log "[CMD]" $CMD
|
||||
$CMD
|
||||
else
|
||||
kscreen-doctor "output.$name.disable"
|
||||
CMD="kscreen-doctor output.$name.disable"
|
||||
log "[CMD]" $CMD
|
||||
$CMD
|
||||
fi
|
||||
done <<< "$outputs"
|
||||
}
|
||||
|
||||
enable_outputs $enabled_outputs
|
||||
enable_outputs $disabled_outputs
|
||||
log "Enabling enabled outputs..."
|
||||
enable_outputs "$enabled_outputs"
|
||||
log "Disabling disabled outputs..."
|
||||
enable_outputs "$disabled_outputs"
|
||||
|
||||
function load_profile_to_outputs {
|
||||
local outputs=$1
|
||||
|
||||
# If empty or only whitespace, return early
|
||||
[[ -z "$outputs" ]] && return
|
||||
|
||||
while IFS= read -r out; do
|
||||
id=$(echo "$out" | jq -r '.id')
|
||||
name=$(echo "$out" | jq -r '.name')
|
||||
@@ -95,7 +115,7 @@ function load_profile_to_outputs {
|
||||
done <<< "$outputs"
|
||||
}
|
||||
|
||||
load_profile_to_outputs $outputs
|
||||
load_profile_to_outputs "$outputs"
|
||||
|
||||
#########################
|
||||
# 2. Restore clone groups
|
||||
@@ -115,6 +135,6 @@ function restore_clone_groups {
|
||||
done <<< "$clone_groups"
|
||||
}
|
||||
|
||||
restore_clone_groups $clone_groups
|
||||
restore_clone_groups "$clone_groups"
|
||||
|
||||
echo "Display configuration restored."
|
||||
Reference in New Issue
Block a user