2

最初に簡単なスクリプトを呼び出して、ネットブックから外部モニターを有効または無効にしたいと考えています。デスクトップとして XFCE を使用して Fedora 17 を実行しています。python と python-dbus を使用して、アクティブなトグルのオンとオフを切り替えることができるはずです。私の問題は、新しい設定をアクティブにするための信号を発信する方法がわからないことです。残念ながら、Python は私が頻繁に使用する言語ではありません。私が用意したコードは次のとおりです。

import dbus
item = 'org.xfce.Xfconf'
path = '/org/xfce/Xfconf'
channel = 'displays'
base = '/'
setting = '/Default/VGA1/Active'

bus = dbus.SessionBus()
remote_object = bus.get_object(item, path)
remote_interface = dbus.Interface(remote_object, "org.xfce.Xfconf")

if remote_interface.GetProperty(channel, setting):
  remote_interface.SetProperty(channel, setting, '0')
  remote_object.PropertyChanged(channel, setting, '0')
else:
  remote_interface.SetProperty(channel, setting, '1')
  remote_object.PropertyChanged(channel, setting, '0')

それは失敗して追い出されています:

Traceback (most recent call last):   File "./vgaToggle", line 31, in <module>
remote_object.PropertyChanged(channel, setting, '0')   
File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 140, in __call__
**keywords)   
File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 630, in call_blocking
message, timeout) dbus.exceptions.DBusException: 
org.freedesktop.DBus.Error.UnknownMethod: Method "PropertyChanged"
with signature "sss" on interface "(null)" doesn't exist

私は検索に少し時間を費やしましたが、これに近いことをしているPythonの例はあまり見つかりません。前もって感謝します。

4

1 に答える 1