3 name_base
= 'org.gna.home.a2jmidid'
4 control_interface_name
= name_base
+ '.control'
5 service_name
= name_base
9 from traceback
import print_exc
14 if len(sys
.argv
) == 1:
15 print("Usage: %s [command] [command] ..." % os
.path
.basename(sys
.argv
[0]))
17 print(" exit - exit a2j bridge dbus service")
18 print(" start - start bridging")
19 print(" stop - stop brdiging")
20 print(" status - get bridging status")
21 print(" gjcn - get JACK client name")
22 print(" ma2jp <client_id> <port_id> - map ALSA to JACK playback port")
23 print(" ma2jc <client_id> <port_id> - map ALSA to JACK capture port")
24 print(" mj2a <jack_port_name> - map JACK port to ALSA port")
25 print(" ehw - enable export of hardware ports")
26 print(" dhw - disable export of hardware ports")
27 print(" dup - disallow unique port names")
28 print(" aup - allow unique port names")
31 bus
= dbus
.SessionBus()
33 controller
= bus
.get_object(service_name
, "/")
34 control_iface
= dbus
.Interface(controller
, control_interface_name
)
38 while index
< len(sys
.argv
):
53 if control_iface
.is_started():
54 print("Bridging enabled")
56 print("Bridging disabled")
57 if control_iface
.get_hw_export():
58 print("Hardware exported")
60 print("Hardware not exported")
61 if control_iface
.get_disable_port_uniqueness():
62 print("Avoiding unique port names")
64 print("Allowing unique port names")
66 print("--- get jack client name")
67 print(control_iface
.get_jack_client_name())
69 print("--- map ALSA to JACK playback port")
70 if index
+ 1 >= len(sys
.argv
):
71 print("map ALSA to JACK playback port command requires ALSA client ID and ALSA port ID arguments")
73 client_id
= sys
.argv
[index
]
75 port_id
= sys
.argv
[index
]
78 print("'%s'" % control_iface
.map_alsa_to_jack_port(client_id
, port_id
, True))
80 print("--- map ALSA to JACK capture port")
81 if index
+ 1 >= len(sys
.argv
):
82 print("map ALSA to JACK capture port command requires ALSA client ID and ALSA port ID arguments")
84 client_id
= sys
.argv
[index
]
86 port_id
= sys
.argv
[index
]
89 print("'%s'" % control_iface
.map_alsa_to_jack_port(client_id
, port_id
, False))
91 print("--- map JACK to ALSA port")
92 if index
>= len(sys
.argv
):
93 print("map JACK to ALSA port command requires JACK port name argument")
95 jack_port
= sys
.argv
[index
]
98 out
= control_iface
.map_jack_port_to_alsa(jack_port
)
99 print("%u:%u ('%s':'%s')" % (int(out
[0]), int(out
[1]), str(out
[2]), str(out
[3])))
101 print("--- enable export of hardware ports")
102 control_iface
.set_hw_export(True)
104 print("--- disable export of hardware ports")
105 control_iface
.set_hw_export(False)
107 print("--- allow unique port names")
108 control_iface
.set_disable_port_uniqueness(False)
110 print("--- disallow unique port names")
111 control_iface
.set_disable_port_uniqueness(True)
113 print("Unknown command '%s'" % arg
)
114 except dbus
.DBusException
as e
:
115 print("DBus exception: %s" % str(e
))
117 if __name__
== '__main__':