Compare commits
7 Commits
9e990cf58d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc15980ba5 | ||
| 5490b665f3 | |||
| 3c184743d0 | |||
| 46bf8aec49 | |||
| b07d7f3b03 | |||
|
|
39d46fa9e1 | ||
|
|
4bbe14f8f2 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
profiles/*.json
|
profiles/
|
||||||
|
*.json
|
||||||
30
all_attributes.md
Normal file
30
all_attributes.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# All Kscreen Doctor attributes
|
||||||
|
|
||||||
|
- [x] primary
|
||||||
|
- [ ] priority
|
||||||
|
- [x] enable
|
||||||
|
- [x] disable
|
||||||
|
- [x] mode
|
||||||
|
- [x] position
|
||||||
|
- [x] scale
|
||||||
|
- [x] orientation / rotation
|
||||||
|
- [ ] overscan (0-100)
|
||||||
|
- [ ] vrrpolicy (never / always / automatic)
|
||||||
|
- [ ] rgbrange (automatic / full / limited)
|
||||||
|
- [ ] hdr (enable / disable / toggle)
|
||||||
|
- [ ] sdr-brightness (50-10000)
|
||||||
|
- [ ] wcg (enable / disable / toggle)
|
||||||
|
- [ ] iccprofile (path)
|
||||||
|
- [ ] sdrGamut (0-100)
|
||||||
|
- [ ] maxBrightnessOverride (disable / int)
|
||||||
|
- [ ] maxAverageBrightnessOverride (disable / int)
|
||||||
|
- [ ] minBrightnessOverride (disable / int)
|
||||||
|
- [ ] colorProfileSource (sRBG / ICC / EDID)
|
||||||
|
- [ ] brightness (0-100)
|
||||||
|
- [ ] colorPowerTradeoff (preferEfficiency / preferAccuracy)
|
||||||
|
- [ ] dimming (0-100)
|
||||||
|
- [ ] mirror ( none / output )
|
||||||
|
- [ ] ddcCi (allow / disallow)
|
||||||
|
- [ ] maxbpc (automatic / 6-16)
|
||||||
|
- [ ] edrPolicy (never / always)
|
||||||
|
- [ ] sharpness (0 - 100)
|
||||||
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
|
||||||
@@ -26,12 +33,8 @@ if ! command -v kscreen-doctor &>/dev/null; then
|
|||||||
fi
|
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:"
|
disabled_outputs=$(jq -c '.outputs[] | select(.enabled == false)' "$PROFILE")
|
||||||
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")
|
||||||
|
|
||||||
# Restore enabled/disabled starting with the enabled monitors
|
# Restore enabled/disabled starting with the enabled monitors
|
||||||
@@ -40,22 +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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log "Enabling enabled 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')
|
||||||
@@ -63,52 +86,81 @@ function load_profile_to_outputs {
|
|||||||
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')
|
||||||
scale=$(echo "$out" | jq -r '.scale')
|
scale=$(echo "$out" | jq -r '.scale')
|
||||||
mode=$(echo "$out" | jq -r '.currentModeId')
|
mode_id=$(echo "$out" | jq -r '.currentModeId')
|
||||||
|
# mode_name=$(echo "$out" | jq -r ".modes[] | select(.id == \"$mode_id\") | .name")
|
||||||
|
# log "[VAR] mode_name:" $mode_name
|
||||||
|
refresh_rate=$(echo "$out" | jq -r ".modes[] | select(.id == \"$mode_id\") | .refreshRate")
|
||||||
|
height=$(echo "$out" | jq -r ".modes[] | select(.id == \"$mode_id\") | .size.height")
|
||||||
|
width=$(echo "$out" | jq -r ".modes[] | select(.id == \"$mode_id\") | .size.width")
|
||||||
|
mode="${width}x${height}@${refresh_rate}"
|
||||||
|
replication_source_id=$(echo "$out" | jq -r ".replicationSource")
|
||||||
|
log "[VAR] replication_source_id: $replication_source_id"
|
||||||
|
if [ $replication_source_id -neq 0 ]; then
|
||||||
|
replication_source_name=$(echo "$outputs.[] | select(.id == \"$replication_source_id\" | .name)" )
|
||||||
|
log "[VAR] replication_source_name: $replication_source_name"
|
||||||
|
CMD="kscreen-doctor output.$"
|
||||||
|
done
|
||||||
|
log "[VAR] mode: $mode"
|
||||||
priority=$(echo "$out" | jq -r '.priority')
|
priority=$(echo "$out" | jq -r '.priority')
|
||||||
|
|
||||||
|
#
|
||||||
|
|
||||||
# Mode (Resolution + refresh)
|
# Mode (Resolution + refresh)
|
||||||
kscreen-doctor "output.$id.mode.$mode"
|
# CMD="kscreen-doctor output.$name.mode.$mode"
|
||||||
|
CMD="kscreen-doctor output.$name.mode.$mode"
|
||||||
|
log "[CMD]" $CMD
|
||||||
|
$CMD
|
||||||
|
|
||||||
# Position
|
# Position
|
||||||
kscreen-doctor "output.$id.position.$posx,$posy"
|
CMD="kscreen-doctor output.$name.position.$posx,$posy"
|
||||||
|
log "[CMD]" $CMD
|
||||||
|
$CMD
|
||||||
|
|
||||||
# Scale
|
# Scale
|
||||||
kscreen-doctor "output.$id.scale.$scale"
|
CMD="kscreen-doctor output.$name.scale.$scale"
|
||||||
|
log "[CMD]" $CMD
|
||||||
|
$CMD
|
||||||
|
|
||||||
# Rotation (map from JSON names to kscreen-doctor options)
|
# Rotation (map from JSON names to kscreen-doctor options)
|
||||||
|
CMD=""
|
||||||
case "$rotation" in
|
case "$rotation" in
|
||||||
"1") kscreen-doctor "output.$id.rotation.normal" ;;
|
"1") CMD="kscreen-doctor output.$name.rotation.normal" ;;
|
||||||
"2") kscreen-doctor "output.$id.rotation.left" ;;
|
"2") CMD="kscreen-doctor output.$name.rotation.left" ;;
|
||||||
"4") kscreen-doctor "output.$id.rotation.inverted" ;;
|
"4") CMD="kscreen-doctor output.$name.rotation.inverted" ;;
|
||||||
"8") kscreen-doctor "output.$id.rotation.right" ;;
|
"8") CMD="kscreen-doctor output.$name.rotation.right" ;;
|
||||||
esac
|
esac
|
||||||
|
log "[CMD]" $CMD
|
||||||
|
$CMD
|
||||||
|
|
||||||
# Primary / Not Primary
|
# Primary / Not Primary
|
||||||
echo $priority
|
|
||||||
if [ $priority -eq 1 ]; then
|
if [ $priority -eq 1 ]; then
|
||||||
kscreen-doctor "output.$id.primary"
|
CMD="kscreen-doctor output.$name.primary"
|
||||||
|
log "[CMD]" $CMD
|
||||||
|
$CMD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done <<< "$outputs"
|
done <<< "$outputs"
|
||||||
`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_profile_to_outputs "$outputs"
|
||||||
#########################
|
|
||||||
# 2. Restore clone groups
|
|
||||||
#########################
|
|
||||||
|
|
||||||
clone_groups=$(jq -c '.clones[]?' "$PROFILE")
|
clone_groups=$(jq -c '.clones[]?' "$PROFILE")
|
||||||
|
|
||||||
function restore_clone_groups {
|
function restore_clone_groups {
|
||||||
|
local clone_groups=$1
|
||||||
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)
|
||||||
|
|
||||||
for o in $others; do
|
for o in $others; do
|
||||||
kscreen-doctor "output.$o.clone.$primary"
|
CMD="kscreen-doctor output.$o.clone.$primary"
|
||||||
|
log "[CMD]" $CMD
|
||||||
|
$CMD
|
||||||
|
|
||||||
done
|
done
|
||||||
done <<< "$clone_groups"
|
done <<< "$clone_groups"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore_clone_groups "$clone_groups"
|
||||||
|
|
||||||
echo "Display configuration restored."
|
echo "Display configuration restored."
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Make sure a config file was provided
|
|
||||||
if [ $# -lt 1 ]; then
|
|
||||||
echo "Usage: $0 <config file>"
|
|
||||||
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."
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1297
profiles/tv.json
1297
profiles/tv.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user