ubuntu-mate / mate-optimus

NVIDIA Optimus GPU switcher
https://ubuntu-mate.org
GNU General Public License v3.0
93 stars 14 forks source link

radio items and asusctl/asusd support #26

Open kyokenn opened 3 years ago

kyokenn commented 3 years ago

PR changes:

flukejones commented 3 years ago

Is it possible for you to use the dbus interface instead of the cli tool directly? (I'm the asusctl owner)

kyokenn commented 3 years ago

@flukejones Sure, I can switch to dbus. It would be great. Does the asusctl's dbus methods documented somewhere?

flukejones commented 3 years ago

@kyokenn no, but it's very easy to get the info:

[luke@fedora]$ dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/asuslinux/Gfx org.freedesktop.DBus.Introspectable.Introspect
method return time=1629840916.728590 sender=:1.28 -> destination=:1.175 serial=170 reply_serial=2
   string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.DBus.Peer">
    <method name="Ping">
    </method>
    <method name="GetMachineId">
      <arg type="s" direction="out"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg type="s" direction="out"/>
    </method>
  </interface>
  <interface name="org.asuslinux.Daemon">
    <method name="Vendor">
      <arg type="u" direction="out"/>
    </method>
    <method name="Power">
      <arg type="u" direction="out"/>
    </method>
    <method name="SetVendor">
      <arg name="vendor" type="u" direction="in"/>
      <arg type="u" direction="out"/>
    </method>
    <signal name="NotifyGfx">
      <arg name="vendor" type="u"/>
    </signal>
    <signal name="NotifyAction">
      <arg name="action" type="u"/>
    </signal>
  </interface>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="property_name" type="s" direction="in"/>
      <arg type="v" direction="out"/>
    </method>
    <method name="Set">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="property_name" type="s" direction="in"/>
      <arg name="value" type="v" direction="in"/>
    </method>
    <method name="GetAll">
      <arg name="interface_name" type="s" direction="in"/>
      <arg type="a{sv}" direction="out"/>
    </method>
    <signal name="PropertiesChanged">
      <arg name="interface_name" type="s"/>
      <arg name="changed_properties" type="a{sv}"/>
      <arg name="invalidated_properties" type="as"/>
    </signal>
  </interface>
</node>
"
kyokenn commented 3 years ago

Thanks for the info. I have added optional dbus support with fallback to asusctl CLI, because the original mate-optimus tool doesn't requires dbus for generic laptops.

flukejones commented 3 years ago

I'm very sorry to say, but I am breaking userspace while I try to figure out the best way to pull the graphics control stuff fully out of asusctl. New xml is:

[luke@fedora]$ dbus-send --system --type=method_call --print-reply --dest=org.asuslinux.Daemon /org/supergfxctl/Gfx org.freedesktop.DBus.Introspectable.Introspect
method return time=1629891672.215171 sender=:1.294 -> destination=:1.304 serial=20 reply_serial=2
   string "
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg type="s" direction="out"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Peer">
    <method name="Ping">
    </method>
    <method name="GetMachineId">
      <arg type="s" direction="out"/>
    </method>
  </interface>
  <interface name="org.supergfxctl.Daemon">
    <method name="Vendor">
      <arg type="u" direction="out"/>
    </method>
    <method name="Power">
      <arg type="u" direction="out"/>
    </method>
    <method name="SetVendor">
      <arg name="vendor" type="u" direction="in"/>
      <arg type="u" direction="out"/>
    </method>
    <signal name="NotifyGfx">
      <arg name="vendor" type="u"/>
    </signal>
    <signal name="NotifyAction">
      <arg name="action" type="u"/>
    </signal>
  </interface>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="property_name" type="s" direction="in"/>
      <arg type="v" direction="out"/>
    </method>
    <method name="Set">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="property_name" type="s" direction="in"/>
      <arg name="value" type="v" direction="in"/>
    </method>
    <method name="GetAll">
      <arg name="interface_name" type="s" direction="in"/>
      <arg type="a{sv}" direction="out"/>
    </method>
    <signal name="PropertiesChanged">
      <arg name="interface_name" type="s"/>
      <arg name="changed_properties" type="a{sv}"/>
      <arg name="invalidated_properties" type="as"/>
    </signal>
  </interface>
</node>
"

destination is likely to end up being org.supergfxctl.Daemon

kyokenn commented 3 years ago

I'm very sorry to say, but I am breaking userspace while I try to figure out the best way to pull the graphics control stuff fully out of asusct

Which version of asusctl will have those changes?