From 768d8789817b12dd74628a2ca18f88c9bf41328a Mon Sep 17 00:00:00 2001 From: Dawson Matthews Date: Sun, 1 Feb 2026 13:55:01 -0700 Subject: [PATCH] more often uses apply_attribute --- ...play-profile.sh => load-display-profile.sh | 101 +++++++----------- ...play-profile.sh => save-display-profile.sh | 0 src/profile_manager.py | 27 +---- 3 files changed, 38 insertions(+), 90 deletions(-) rename scripts/load-display-profile.sh => load-display-profile.sh (72%) rename scripts/save-display-profile.sh => save-display-profile.sh (100%) diff --git a/scripts/load-display-profile.sh b/load-display-profile.sh similarity index 72% rename from scripts/load-display-profile.sh rename to load-display-profile.sh index dfc37b2..ce2e691 100755 --- a/scripts/load-display-profile.sh +++ b/load-display-profile.sh @@ -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 - - if [ "$hdr" == true ]; then - CMD="kscreen-doctor output.$name.hdr.enable" - else - CMD="kscreen-doctor output.$name.hdr.disable" - fi - log "[CMD]" $CMD - $CMD + apply_attribute $name "maxbpc" $maxBpc + apply_attribute $name "ddcCi" $ddcCi $bool_allow_map + 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 diff --git a/scripts/save-display-profile.sh b/save-display-profile.sh similarity index 100% rename from scripts/save-display-profile.sh rename to save-display-profile.sh diff --git a/src/profile_manager.py b/src/profile_manager.py index 1928700..af6f110 100644 --- a/src/profile_manager.py +++ b/src/profile_manager.py @@ -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"""