统信/深度如何获取屏幕模式设置信息

公司有一个软件需要获取和设置屏幕模式,但是这个软件是windows软件,为了节约时间和成本,我们采用wine来适配linux操作系统,目前主要考虑国内主要3个操作系统:统信,深度,麒麟
在适配的过程中,发现屏幕模式实际上在不同的linux发行版上设置都是不一样的,并没有一套统一的代码能够完成,最近的是采用xrandr 命令,但是这个命令有一个很大的缺点,就是在设置扩展模式时需要强制指定2个屏幕的方向,这对于用习惯了windows功能的我非常不习惯,更难受的是软件没能自动识别2个屏幕的方向。
后面想了一下,那为什么统信他们自己能够知道呢,通过研究,统信/深度的linux桌面发行版有一个配置文件,这个文件中记录了历史的屏幕以及屏幕方向,配置信息大概如下:

{
    "Version": "1.0",
    "Config": {
        "DisplayMode": 2,
        "Screens": {
            "@DP-1|353af8affa87c316e65f99bd7e578f2d|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@DP-1|353af8affa87c316e65f99bd7e578f2d|v1",
                            "Name": "DP1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@DP-1|353af8affa87c316e65f99bd7e578f2d|v1,@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1": {
                "Mirror": {
                    "Monitors": [
                        {
                            "UUID": "@DP-1|353af8affa87c316e65f99bd7e578f2d|v1",
                            "Name": "DP1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        },
                        {
                            "UUID": "@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": false
                        }
                    ]
                },
                "Extend": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 1920,
                            "Y": 6,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": false
                        },
                        {
                            "UUID": "@DP-1|353af8affa87c316e65f99bd7e578f2d|v1",
                            "Name": "DP1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@DP-1|81e74281bd92f7f55790ea39cb81bd93|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@DP-1|81e74281bd92f7f55790ea39cb81bd93|v1",
                            "Name": "DP1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-1|13b466a47186907d1a42292ce8689184|v1,@HDMI-A-2|bff58c2578a6c1bac13e1b49f6156e19|v1": {
                "Extend": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|bff58c2578a6c1bac13e1b49f6156e19|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 120,
                            "Brightness": 1,
                            "Primary": true
                        },
                        {
                            "UUID": "@HDMI-A-1|13b466a47186907d1a42292ce8689184|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 1920,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": false
                        }
                    ]
                }
            },
            "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1,@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1": {
                "Mirror": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        },
                        {
                            "UUID": "@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": false
                        }
                    ]
                },
                "Extend": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": false
                        },
                        {
                            "UUID": "@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 1920,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                },
                "OnlyOneMap": {
                    "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1": {
                        "Monitors": [
                            {
                                "UUID": "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1",
                                "Name": "HDMI1",
                                "Enabled": true,
                                "X": 0,
                                "Y": 0,
                                "Width": 1920,
                                "Height": 1080,
                                "Rotation": 1,
                                "Reflect": 0,
                                "RefreshRate": 60,
                                "Brightness": 1,
                                "Primary": true
                            }
                        ]
                    },
                    "@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1": {
                        "Monitors": [
                            {
                                "UUID": "@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1",
                                "Name": "HDMI2",
                                "Enabled": true,
                                "X": 0,
                                "Y": 0,
                                "Width": 1920,
                                "Height": 1080,
                                "Rotation": 1,
                                "Reflect": 0,
                                "RefreshRate": 60,
                                "Brightness": 1,
                                "Primary": true
                            }
                        ]
                    }
                },
                "OnlyOneUuid": "@HDMI-A-1|3128f5c8ac50b0730b92947e30b49fa6|v1"
            },
            "@HDMI-A-1|bff58c2578a6c1bac13e1b49f6156e19|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-1|bff58c2578a6c1bac13e1b49f6156e19|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-1|bff58c2578a6c1bac13e1b49f6156e19|v1,@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1": {
                "Mirror": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-1|bff58c2578a6c1bac13e1b49f6156e19|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        },
                        {
                            "UUID": "@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 120,
                            "Brightness": 1,
                            "Primary": false
                        }
                    ]
                },
                "Extend": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-1|bff58c2578a6c1bac13e1b49f6156e19|v1",
                            "Name": "HDMI1",
                            "Enabled": true,
                            "X": 1920,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        },
                        {
                            "UUID": "@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 1920,
                            "Y": 1080,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 120,
                            "Brightness": 1,
                            "Primary": false
                        }
                    ]
                }
            },
            "@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|13b466a47186907d1a42292ce8689184|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-2|30cff5485a83282f9d86406299cc042d|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|30cff5485a83282f9d86406299cc042d|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-2|93502b5784753b3cb3a549cfa5cc5175|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|93502b5784753b3cb3a549cfa5cc5175|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-2|bff58c2578a6c1bac13e1b49f6156e19|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|bff58c2578a6c1bac13e1b49f6156e19|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 120,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-2|c9104bd1970ef8ac67873f0ff0473da6|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|c9104bd1970ef8ac67873f0ff0473da6|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 1920,
                            "Height": 1080,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 60,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            },
            "@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1": {
                "Single": {
                    "Monitors": [
                        {
                            "UUID": "@HDMI-A-2|cc9cea80dd0ca2c8b799199906e352aa|v1",
                            "Name": "HDMI2",
                            "Enabled": true,
                            "X": 0,
                            "Y": 0,
                            "Width": 3840,
                            "Height": 2160,
                            "Rotation": 1,
                            "Reflect": 0,
                            "RefreshRate": 30,
                            "Brightness": 1,
                            "Primary": true
                        }
                    ]
                }
            }
        },
        "ScaleFactors": {
            "ALL": 1
        },
        "FillModes": null,
        "Cache": {
            "BuiltinMonitor": "",
            "ConnectTime": {
                "DP1": "2024-07-02T18:43:21.332269927+08:00",
                "HDMI2": "2024-07-03T09:13:39.317067141+08:00"
            }
        }
    },
    "AutoBacklightEnable": false,
    "UpdateAt": "2024-07-04T15:13:13.284027715+08:00"
}

通过这个配置文件,就可以通过上面的命令执行扩展莫斯设置了 。配置文件路径:/data/var/lib/dde-daemon/display/config.json

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值