more often uses apply_attribute

This commit is contained in:
Dawson Matthews
2026-02-01 13:55:01 -07:00
parent afccfbbc05
commit 768d878981
3 changed files with 38 additions and 90 deletions
@@ -134,100 +134,73 @@ function load_profile_to_outputs {
bool_enable_map["true"]="enable"
bool_enable_map["false"]="disable"
declare -A bool_allow_map
bool_allow_map["true"]="allow"
bool_allow_map["false"]="disallow"
declare -A rgb_range_map
rgb_range_map["0"]="automatic"
rgb_range_map["full"]="full"
rgb_range_map["limited"]="limited"
declare -A rotation_map
rotation_map["1"]="normal"
rotation_map["2"]="left"
rotation_map["4"]="inverted"
rotation_map["8"]="right"
apply_attribute $name "wcg" $wcg $bool_enable_map
apply_attribute $name "sdr-brightness" $sdrbrightness
apply_attribute $name "vrrpolicy" $vrrPolicy
apply_attribute $name "rgbrange" $rgbRange $rgb_range_map
CMD="kscreen-doctor output.$name.overscan.$overscan"
log "[CMD]" $CMD
$CMD
apply_attribute $name "overscan" $overscan
apply_attribute $name "hdr" $hdr $bool_enable_map
apply_attribute $name "brightness" $brightness
if [ "$maxBpc" == 0 ]; then
CMD="kscreen-doctor output.$name.maxbpc.automatic"
else
CMD="kscreen-doctor output.$name.maxbpc.$maxBpc"
maxBpc="automatic"
fi
log "[CMD]" $CMD
$CMD
apply_attribute $name "maxbpc" $maxBpc
apply_attribute $name "ddcCi" $ddcCi $bool_allow_map
if [ "$hdr" == true ]; then
CMD="kscreen-doctor output.$name.hdr.enable"
else
CMD="kscreen-doctor output.$name.hdr.disable"
fi
log "[CMD]" $CMD
$CMD
log "[VAR] replication_source_id: $replication_source_id"
if [ $replication_source_id != 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.$name.mirror.$replication_source_name"
log "[CMD]" $CMD
$CMD
apply_attribute $name "mirror" $replication_source_name
else
CMD="kscreen-doctor output.$name.mirror.none"
log "[CMD]" $CMD
$CMD
apply_attribute $name "mirror" "none"
fi
log "[VAR] mode: $mode"
priority=$(echo "$out" | jq -r '.priority')
if [ $ddcCi == true ]; then
CMD="kscreen-doctor output.$name.ddcCi.allow"
else
CMD="kscreen-doctor output.$name.ddcCi.disallow"
fi
log "[CMD]" $CMD
$CMD
if [ "$iccProfilePath" != "" ]; then
CMD="kscreen-doctor output.$name.iccProfilePath.$iccProfilePath"
log "[CMD]" $CMD
$CMD
apply_attribute $name "iccProfilePath" $iccProfilePath
fi
CMD="kscreen-doctor output.$name.brightness.$brightness"
log "[CMD]" $CMD
$CMD
#
# Mode (Resolution + refresh)
# CMD="kscreen-doctor output.$name.mode.$mode"
CMD="kscreen-doctor output.$name.mode.$mode"
log "[CMD]" $CMD
$CMD
apply_attribute $name "mode" $mode
# Position
CMD="kscreen-doctor output.$name.position.$posx,$posy"
log "[CMD]" $CMD
$CMD
# CMD="kscreen-doctor output.$name.position.$posx,$posy"
# log "[CMD]" $CMD
# $CMD
fullPosition="$posx,$posy"
apply_attribute $name "position" $fullPosition
# Scale
CMD="kscreen-doctor output.$name.scale.$scale"
log "[CMD]" $CMD
$CMD
apply_attribute $name "scale" $scale
# Rotation (map from JSON names to kscreen-doctor options)
CMD=""
case "$rotation" in
"1") CMD="kscreen-doctor output.$name.rotation.normal" ;;
"2") CMD="kscreen-doctor output.$name.rotation.left" ;;
"4") CMD="kscreen-doctor output.$name.rotation.inverted" ;;
"8") CMD="kscreen-doctor output.$name.rotation.right" ;;
esac
log "[CMD]" $CMD
$CMD
# CMD=""
# case "$rotation" in
# "1") CMD="kscreen-doctor output.$name.rotation.normal" ;;
# "2") CMD="kscreen-doctor output.$name.rotation.left" ;;
# "4") CMD="kscreen-doctor output.$name.rotation.inverted" ;;
# "8") CMD="kscreen-doctor output.$name.rotation.right" ;;
# esac
# log "[CMD]" $CMD
# $CMD
apply_attribute $name "rotation" $rotation $rotation_map
# Primary / Not Primary
if [ $priority -eq 1 ]; then
+1 -26
View File
@@ -18,32 +18,7 @@ class ProfileManager:
def find_script(self):
"""Find the bash script for display management"""
# Check common locations
possible_paths = [
Path(__file__).parent.parent / "scripts/display-script.sh",
Path.home() / "bin/display-script.sh",
Path("/usr/local/bin/display-script.sh"),
]
for path in possible_paths:
if path.exists():
return path
# For now, return None - we'll handle this gracefully
return None
def load_metadata(self):
"""Load profile metadata from JSON file"""
try:
with open(self.metadata_file, 'r') as f:
return json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
return []
def save_metadata(self, profiles):
"""Save profile metadata to JSON file"""
with open(self.metadata_file, 'w') as f:
json.dump(profiles, f, indent=2)
return "scripts/"
def list_profiles(self):
"""Return list of all profiles"""