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