[Seek Help] dde-control-center -p 参数 Resolved
Tofloor
poster avatar
lzy
deepin
2022-11-10 05:49
Author

在使用自定义快捷键时,打算制定一个打开控制中心指定位置的命令,想了解下dde-control-center -p 参数怎么使用。看help文档没有案例介绍,不确定需要追加什么值。有案例的话就非常感谢。

Options:
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
-s, --show show control center(hide for default).
-t, --toggle toggle control center visible.
-d, --dbus, --startup on dbus
-m the module' id of which to be shown.
-p specified module page

Reply Favorite View the author
All Replies
寂静的羽夏
deepin
2022-11-10 06:26
#1

我的目前的建议是看源码(如下是关键代码):

    QCommandLineOption moduleOption("m", "the module' id of which to be shown.", "module");
    QCommandLineOption pageOption("p", "specified module page", "page");
...
    const QString &reqModule = parser.value(moduleOption);
    const QString &reqPage = parser.value(pageOption);
...
        if (!reqModule.isEmpty()) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("ShowPage")
            .arg(reqModule)
            .arg(reqPage)
            .call();
        }
        else if (parser.isSet(showOption) && !parser.isSet(dbusOption)) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("Show")
            .call();
        }

也就是说, -m 和 -p 参数其实就是调用 dbus ,这个 dbus ,我是研究过的,不过只是研究过网络的,不过有关其他模块,你可以通过我的指引进行检索(通过源码):

然后跟踪一下:

void DBusControlCenterService::ShowPage(const QString &module, const QString &page)
{
    parent()->initAllModule(module);

    static bool firstEnter = true;
    QStringList delayModule{"bluetooth"};
    if (delayModule.contains(module) && firstEnter) {
        firstEnter = false;
        //此时对应了dbus调用显示控制中心需要dbus同步方式数据
    }

    parent()->showModulePage(module, page, false);
}

这个 parent 正是 MainWindow,然后跟一下代码:

    m_modules = {
    #ifndef DISABLE_AUTHENTICATION
        { new LoginOptionsModule(this), tr("Biometric Authentication")},
    #endif
        { new AccountsModule(this), tr("Accounts")},
        { new DisplayModule(this), tr("Display")},
        { new TouchscreenModule(this), tr("Touch Screen")},
        { new DefaultAppsModule(this), tr("Default Applications")},
        { new PersonalizationModule(this), tr("Personalization")},
        { new NotificationModule(this), tr("Notification")},
        { new SoundModule(this), tr("Sound")},
        { new BluetoothModule(this), tr("Bluetooth")},
        { new DatetimeModule(this), tr("Date and Time")},
        { new PowerModule(this), tr("Power")},
        { new MouseModule(this), tr("Mouse")},
        { new WacomModule(this), tr("Drawing Tablet")},
        { new KeyboardModule(this), tr("Keyboard and Language")},
#ifndef DISABLE_SYS_UPDATE
        { new UpdateModule(this), tr("Updates")},
#endif
        { new SystemInfoModule(this), tr("System Info")},
        { new CommonInfoModule(this), tr("General Settings")},
    };

然后,我们的 module 的值,就差不多有了,据我观察,每个模块都有 nameavailPage属性,那个 name就是 -m 之后跟的值,availPage就是我们 -p 后面每个模块的值,举个例子:

const QString MouseModule::name() const
{
    return QStringLiteral("mouse");
}

QStringList MouseModule::availPage() const
{
    QStringList sl;
    sl << "General" << "Mouse";
    if (m_model->tpadExist()) {
        sl << "Touchpad";
    }
    if (m_model->redPointExist()) {
        sl << "TrackPoint";
    }
    return sl;
}

所以,我们可以这么使用:

dde-control-center -m "mouse" -p "General"  

我们就可以打开鼠标的通用设置。


如果你想通过这个调出网络,不幸的是,这个是没有的,它是通过插件提供的:

const QString ModuleDirectory = "/usr/lib/dde-control-center/modules";

这个就是插件的路径,只要你找到对应插件的源码,就可以找到对应的值,有关网络的我没有找到它的源码,是通过逆向分析手段获得的值,如下:

[module]
network

[page]
System Proxy
DSL/Create PPPoE Connection
VPN
VPN/Create VPN
VPN/Import VPN
Application Proxy
Network Details
Wired Network
Wired Network/addWiredConnection
Wireless Network
WirelessPage
Personal Hotspot
Airplane Mode

module 就是所谓的 -m 后面跟的值,page 就是 -p 可以跟的值,如果 -m 是 network 。

Reply View the author
忘记、过去
deepin
2022-11-10 08:31
#2
寂静的羽夏

我的目前的建议是看源码(如下是关键代码):

    QCommandLineOption moduleOption("m", "the module' id of which to be shown.", "module");
    QCommandLineOption pageOption("p", "specified module page", "page");
...
    const QString &reqModule = parser.value(moduleOption);
    const QString &reqPage = parser.value(pageOption);
...
        if (!reqModule.isEmpty()) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("ShowPage")
            .arg(reqModule)
            .arg(reqPage)
            .call();
        }
        else if (parser.isSet(showOption) && !parser.isSet(dbusOption)) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("Show")
            .call();
        }

也就是说, -m 和 -p 参数其实就是调用 dbus ,这个 dbus ,我是研究过的,不过只是研究过网络的,不过有关其他模块,你可以通过我的指引进行检索(通过源码):

然后跟踪一下:

void DBusControlCenterService::ShowPage(const QString &module, const QString &page)
{
    parent()->initAllModule(module);

    static bool firstEnter = true;
    QStringList delayModule{"bluetooth"};
    if (delayModule.contains(module) && firstEnter) {
        firstEnter = false;
        //此时对应了dbus调用显示控制中心需要dbus同步方式数据
    }

    parent()->showModulePage(module, page, false);
}

这个 parent 正是 MainWindow,然后跟一下代码:

    m_modules = {
    #ifndef DISABLE_AUTHENTICATION
        { new LoginOptionsModule(this), tr("Biometric Authentication")},
    #endif
        { new AccountsModule(this), tr("Accounts")},
        { new DisplayModule(this), tr("Display")},
        { new TouchscreenModule(this), tr("Touch Screen")},
        { new DefaultAppsModule(this), tr("Default Applications")},
        { new PersonalizationModule(this), tr("Personalization")},
        { new NotificationModule(this), tr("Notification")},
        { new SoundModule(this), tr("Sound")},
        { new BluetoothModule(this), tr("Bluetooth")},
        { new DatetimeModule(this), tr("Date and Time")},
        { new PowerModule(this), tr("Power")},
        { new MouseModule(this), tr("Mouse")},
        { new WacomModule(this), tr("Drawing Tablet")},
        { new KeyboardModule(this), tr("Keyboard and Language")},
#ifndef DISABLE_SYS_UPDATE
        { new UpdateModule(this), tr("Updates")},
#endif
        { new SystemInfoModule(this), tr("System Info")},
        { new CommonInfoModule(this), tr("General Settings")},
    };

然后,我们的 module 的值,就差不多有了,据我观察,每个模块都有 nameavailPage属性,那个 name就是 -m 之后跟的值,availPage就是我们 -p 后面每个模块的值,举个例子:

const QString MouseModule::name() const
{
    return QStringLiteral("mouse");
}

QStringList MouseModule::availPage() const
{
    QStringList sl;
    sl << "General" << "Mouse";
    if (m_model->tpadExist()) {
        sl << "Touchpad";
    }
    if (m_model->redPointExist()) {
        sl << "TrackPoint";
    }
    return sl;
}

所以,我们可以这么使用:

dde-control-center -m "mouse" -p "General"  

我们就可以打开鼠标的通用设置。


如果你想通过这个调出网络,不幸的是,这个是没有的,它是通过插件提供的:

const QString ModuleDirectory = "/usr/lib/dde-control-center/modules";

这个就是插件的路径,只要你找到对应插件的源码,就可以找到对应的值,有关网络的我没有找到它的源码,是通过逆向分析手段获得的值,如下:

[module]
network

[page]
System Proxy
DSL/Create PPPoE Connection
VPN
VPN/Create VPN
VPN/Import VPN
Application Proxy
Network Details
Wired Network
Wired Network/addWiredConnection
Wireless Network
WirelessPage
Personal Hotspot
Airplane Mode

module 就是所谓的 -m 后面跟的值,page 就是 -p 可以跟的值,如果 -m 是 network 。

Reply View the author
wtz
deepin
2022-11-10 17:24
#3
寂静的羽夏

我的目前的建议是看源码(如下是关键代码):

    QCommandLineOption moduleOption("m", "the module' id of which to be shown.", "module");
    QCommandLineOption pageOption("p", "specified module page", "page");
...
    const QString &reqModule = parser.value(moduleOption);
    const QString &reqPage = parser.value(pageOption);
...
        if (!reqModule.isEmpty()) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("ShowPage")
            .arg(reqModule)
            .arg(reqPage)
            .call();
        }
        else if (parser.isSet(showOption) && !parser.isSet(dbusOption)) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("Show")
            .call();
        }

也就是说, -m 和 -p 参数其实就是调用 dbus ,这个 dbus ,我是研究过的,不过只是研究过网络的,不过有关其他模块,你可以通过我的指引进行检索(通过源码):

然后跟踪一下:

void DBusControlCenterService::ShowPage(const QString &module, const QString &page)
{
    parent()->initAllModule(module);

    static bool firstEnter = true;
    QStringList delayModule{"bluetooth"};
    if (delayModule.contains(module) && firstEnter) {
        firstEnter = false;
        //此时对应了dbus调用显示控制中心需要dbus同步方式数据
    }

    parent()->showModulePage(module, page, false);
}

这个 parent 正是 MainWindow,然后跟一下代码:

    m_modules = {
    #ifndef DISABLE_AUTHENTICATION
        { new LoginOptionsModule(this), tr("Biometric Authentication")},
    #endif
        { new AccountsModule(this), tr("Accounts")},
        { new DisplayModule(this), tr("Display")},
        { new TouchscreenModule(this), tr("Touch Screen")},
        { new DefaultAppsModule(this), tr("Default Applications")},
        { new PersonalizationModule(this), tr("Personalization")},
        { new NotificationModule(this), tr("Notification")},
        { new SoundModule(this), tr("Sound")},
        { new BluetoothModule(this), tr("Bluetooth")},
        { new DatetimeModule(this), tr("Date and Time")},
        { new PowerModule(this), tr("Power")},
        { new MouseModule(this), tr("Mouse")},
        { new WacomModule(this), tr("Drawing Tablet")},
        { new KeyboardModule(this), tr("Keyboard and Language")},
#ifndef DISABLE_SYS_UPDATE
        { new UpdateModule(this), tr("Updates")},
#endif
        { new SystemInfoModule(this), tr("System Info")},
        { new CommonInfoModule(this), tr("General Settings")},
    };

然后,我们的 module 的值,就差不多有了,据我观察,每个模块都有 nameavailPage属性,那个 name就是 -m 之后跟的值,availPage就是我们 -p 后面每个模块的值,举个例子:

const QString MouseModule::name() const
{
    return QStringLiteral("mouse");
}

QStringList MouseModule::availPage() const
{
    QStringList sl;
    sl << "General" << "Mouse";
    if (m_model->tpadExist()) {
        sl << "Touchpad";
    }
    if (m_model->redPointExist()) {
        sl << "TrackPoint";
    }
    return sl;
}

所以,我们可以这么使用:

dde-control-center -m "mouse" -p "General"  

我们就可以打开鼠标的通用设置。


如果你想通过这个调出网络,不幸的是,这个是没有的,它是通过插件提供的:

const QString ModuleDirectory = "/usr/lib/dde-control-center/modules";

这个就是插件的路径,只要你找到对应插件的源码,就可以找到对应的值,有关网络的我没有找到它的源码,是通过逆向分析手段获得的值,如下:

[module]
network

[page]
System Proxy
DSL/Create PPPoE Connection
VPN
VPN/Create VPN
VPN/Import VPN
Application Proxy
Network Details
Wired Network
Wired Network/addWiredConnection
Wireless Network
WirelessPage
Personal Hotspot
Airplane Mode

module 就是所谓的 -m 后面跟的值,page 就是 -p 可以跟的值,如果 -m 是 network 。

没写进文档,以后就可能随便改

外围应用也不敢随便用啊joy

Reply View the author
寂静的羽夏
deepin
2022-11-10 17:45
#4

感谢,原来在这里😂 ,和我逆的结果是一样的。

Reply View the author
寂静的羽夏
deepin
2022-11-10 17:48
#5
wtz

没写进文档,以后就可能随便改

外围应用也不敢随便用啊joy

我其实研究这个是为了方便打开代理设置的,因为我用 clash 习惯了,但它不能自动设置,我就利用 python 脚本调出设置,所以有这些经验。shamed

Reply View the author
lzy
deepin
2022-11-11 04:44
#6
寂静的羽夏

我的目前的建议是看源码(如下是关键代码):

    QCommandLineOption moduleOption("m", "the module' id of which to be shown.", "module");
    QCommandLineOption pageOption("p", "specified module page", "page");
...
    const QString &reqModule = parser.value(moduleOption);
    const QString &reqPage = parser.value(pageOption);
...
        if (!reqModule.isEmpty()) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("ShowPage")
            .arg(reqModule)
            .arg(reqPage)
            .call();
        }
        else if (parser.isSet(showOption) && !parser.isSet(dbusOption)) {
            DDBusSender()
            .service("com.deepin.dde.ControlCenter")
            .interface("com.deepin.dde.ControlCenter")
            .path("/com/deepin/dde/ControlCenter")
            .method("Show")
            .call();
        }

也就是说, -m 和 -p 参数其实就是调用 dbus ,这个 dbus ,我是研究过的,不过只是研究过网络的,不过有关其他模块,你可以通过我的指引进行检索(通过源码):

然后跟踪一下:

void DBusControlCenterService::ShowPage(const QString &module, const QString &page)
{
    parent()->initAllModule(module);

    static bool firstEnter = true;
    QStringList delayModule{"bluetooth"};
    if (delayModule.contains(module) && firstEnter) {
        firstEnter = false;
        //此时对应了dbus调用显示控制中心需要dbus同步方式数据
    }

    parent()->showModulePage(module, page, false);
}

这个 parent 正是 MainWindow,然后跟一下代码:

    m_modules = {
    #ifndef DISABLE_AUTHENTICATION
        { new LoginOptionsModule(this), tr("Biometric Authentication")},
    #endif
        { new AccountsModule(this), tr("Accounts")},
        { new DisplayModule(this), tr("Display")},
        { new TouchscreenModule(this), tr("Touch Screen")},
        { new DefaultAppsModule(this), tr("Default Applications")},
        { new PersonalizationModule(this), tr("Personalization")},
        { new NotificationModule(this), tr("Notification")},
        { new SoundModule(this), tr("Sound")},
        { new BluetoothModule(this), tr("Bluetooth")},
        { new DatetimeModule(this), tr("Date and Time")},
        { new PowerModule(this), tr("Power")},
        { new MouseModule(this), tr("Mouse")},
        { new WacomModule(this), tr("Drawing Tablet")},
        { new KeyboardModule(this), tr("Keyboard and Language")},
#ifndef DISABLE_SYS_UPDATE
        { new UpdateModule(this), tr("Updates")},
#endif
        { new SystemInfoModule(this), tr("System Info")},
        { new CommonInfoModule(this), tr("General Settings")},
    };

然后,我们的 module 的值,就差不多有了,据我观察,每个模块都有 nameavailPage属性,那个 name就是 -m 之后跟的值,availPage就是我们 -p 后面每个模块的值,举个例子:

const QString MouseModule::name() const
{
    return QStringLiteral("mouse");
}

QStringList MouseModule::availPage() const
{
    QStringList sl;
    sl << "General" << "Mouse";
    if (m_model->tpadExist()) {
        sl << "Touchpad";
    }
    if (m_model->redPointExist()) {
        sl << "TrackPoint";
    }
    return sl;
}

所以,我们可以这么使用:

dde-control-center -m "mouse" -p "General"  

我们就可以打开鼠标的通用设置。


如果你想通过这个调出网络,不幸的是,这个是没有的,它是通过插件提供的:

const QString ModuleDirectory = "/usr/lib/dde-control-center/modules";

这个就是插件的路径,只要你找到对应插件的源码,就可以找到对应的值,有关网络的我没有找到它的源码,是通过逆向分析手段获得的值,如下:

[module]
network

[page]
System Proxy
DSL/Create PPPoE Connection
VPN
VPN/Create VPN
VPN/Import VPN
Application Proxy
Network Details
Wired Network
Wired Network/addWiredConnection
Wireless Network
WirelessPage
Personal Hotspot
Airplane Mode

module 就是所谓的 -m 后面跟的值,page 就是 -p 可以跟的值,如果 -m 是 network 。

感谢大佬,参考后已经可以使用了,O(∩_∩)O谢谢!

thanks

Reply View the author
lzy
deepin
2022-11-11 04:45
#7

▶️

Reply View the author
深蓝
deepin
2023-11-15 21:36
#8
寂静的羽夏

我其实研究这个是为了方便打开代理设置的,因为我用 clash 习惯了,但它不能自动设置,我就利用 python 脚本调出设置,所以有这些经验。shamed

大佬, 怎么用命令设置, 网络-系统代理下的socks代理和端口参数,如下两个地方
image.png

Reply View the author
寂静的羽夏
deepin
2023-11-20 18:14
#9
深蓝

大佬, 怎么用命令设置, 网络-系统代理下的socks代理和端口参数,如下两个地方
image.png

最近忙着出差了,抱歉今天才能够回复,如果使用命令行来进行设置的话,需要调用 dbus 接口(deepin 有相关接口,我现在因工作不用 Deepin 好久了,自己找找看)或者 gsetting 来进行设置,每个都有对应的命令行。

Reply View the author
深蓝
deepin
2023-11-20 21:31
#10
寂静的羽夏

最近忙着出差了,抱歉今天才能够回复,如果使用命令行来进行设置的话,需要调用 dbus 接口(deepin 有相关接口,我现在因工作不用 Deepin 好久了,自己找找看)或者 gsetting 来进行设置,每个都有对应的命令行。

谢谢大佬,我找找试试

Reply View the author