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["true"]="enable"
bool_enable_map["false"]="disable" 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 declare -A rgb_range_map
rgb_range_map["0"]="automatic" rgb_range_map["0"]="automatic"
rgb_range_map["full"]="full" rgb_range_map["full"]="full"
rgb_range_map["limited"]="limited" 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 "wcg" $wcg $bool_enable_map
apply_attribute $name "sdr-brightness" $sdrbrightness apply_attribute $name "sdr-brightness" $sdrbrightness
apply_attribute $name "vrrpolicy" $vrrPolicy apply_attribute $name "vrrpolicy" $vrrPolicy
apply_attribute $name "rgbrange" $rgbRange $rgb_range_map apply_attribute $name "rgbrange" $rgbRange $rgb_range_map
apply_attribute $name "overscan" $overscan
CMD="kscreen-doctor output.$name.overscan.$overscan" apply_attribute $name "hdr" $hdr $bool_enable_map
log "[CMD]" $CMD apply_attribute $name "brightness" $brightness
$CMD
if [ "$maxBpc" == 0 ]; then if [ "$maxBpc" == 0 ]; then
CMD="kscreen-doctor output.$name.maxbpc.automatic" maxBpc="automatic"
else
CMD="kscreen-doctor output.$name.maxbpc.$maxBpc"
fi fi
log "[CMD]" $CMD apply_attribute $name "maxbpc" $maxBpc
$CMD 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" log "[VAR] replication_source_id: $replication_source_id"
if [ $replication_source_id != 0 ]; then if [ $replication_source_id != 0 ]; then
replication_source_name=$(echo "$outputs.[] | select(.id == \"$replication_source_id\" | .name)" ) replication_source_name=$(echo "$outputs.[] | select(.id == \"$replication_source_id\" | .name)" )
log "[VAR] replication_source_name: $replication_source_name" apply_attribute $name "mirror" $replication_source_name
CMD="kscreen-doctor output.$name.mirror.$replication_source_name"
log "[CMD]" $CMD
$CMD
else else
CMD="kscreen-doctor output.$name.mirror.none" apply_attribute $name "mirror" "none"
log "[CMD]" $CMD
$CMD
fi fi
log "[VAR] mode: $mode"
priority=$(echo "$out" | jq -r '.priority') 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 if [ "$iccProfilePath" != "" ]; then
CMD="kscreen-doctor output.$name.iccProfilePath.$iccProfilePath" apply_attribute $name "iccProfilePath" $iccProfilePath
log "[CMD]" $CMD
$CMD
fi fi
CMD="kscreen-doctor output.$name.brightness.$brightness"
log "[CMD]" $CMD
$CMD
#
# Mode (Resolution + refresh) apply_attribute $name "mode" $mode
# CMD="kscreen-doctor output.$name.mode.$mode"
CMD="kscreen-doctor output.$name.mode.$mode"
log "[CMD]" $CMD
$CMD
# Position # Position
CMD="kscreen-doctor output.$name.position.$posx,$posy" # CMD="kscreen-doctor output.$name.position.$posx,$posy"
log "[CMD]" $CMD # log "[CMD]" $CMD
$CMD # $CMD
fullPosition="$posx,$posy"
apply_attribute $name "position" $fullPosition
# Scale apply_attribute $name "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="" # CMD=""
case "$rotation" in # case "$rotation" in
"1") CMD="kscreen-doctor output.$name.rotation.normal" ;; # "1") CMD="kscreen-doctor output.$name.rotation.normal" ;;
"2") CMD="kscreen-doctor output.$name.rotation.left" ;; # "2") CMD="kscreen-doctor output.$name.rotation.left" ;;
"4") CMD="kscreen-doctor output.$name.rotation.inverted" ;; # "4") CMD="kscreen-doctor output.$name.rotation.inverted" ;;
"8") CMD="kscreen-doctor output.$name.rotation.right" ;; # "8") CMD="kscreen-doctor output.$name.rotation.right" ;;
esac # esac
log "[CMD]" $CMD # log "[CMD]" $CMD
$CMD # $CMD
apply_attribute $name "rotation" $rotation $rotation_map
# Primary / Not Primary # Primary / Not Primary
if [ $priority -eq 1 ]; then if [ $priority -eq 1 ]; then
+1 -26
View File
@@ -18,32 +18,7 @@ class ProfileManager:
def find_script(self): def find_script(self):
"""Find the bash script for display management""" """Find the bash script for display management"""
# Check common locations return "scripts/"
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)
def list_profiles(self): def list_profiles(self):
"""Return list of all profiles""" """Return list of all profiles"""