This file is indexed.

/usr/bin/jack_control is in jackd2 1.9.10+20150825git1ed50c92~dfsg-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
#! /usr/bin/python

name_base = 'org.jackaudio'
control_interface_name = name_base + '.JackControl'
configure_interface_name = name_base + '.Configure'
service_name = name_base + '.service'

import sys
import os
from traceback import print_exc

import dbus

def bool_convert(str_value):
    if str_value.lower() == "false":
        return False

    if str_value.lower() == "off":
        return False

    if str_value.lower() == "no":
        return False

    if str_value == "0":
        return False

    if str_value.lower() == "(null)":
        return False

    return bool(str_value)

def dbus_type_to_python_type(dbus_value):
    if type(dbus_value) == dbus.Boolean:
        return bool(dbus_value)
    if type(dbus_value) == dbus.Int32 or type(dbus_value) == dbus.UInt32:
        return int(dbus_value)
    return dbus_value

def python_type_to_jackdbus_type(value, type_char):
    type_char = str(type_char)

    if type_char == "b":
        return bool_convert(value);
    elif type_char == "y":
        return dbus.Byte(value);
    elif type_char == "i":
        return dbus.Int32(value)
    elif type_char == "u":
        return dbus.UInt32(value)

    return value

def dbus_type_to_type_string(dbus_value):
    if type(dbus_value) == dbus.Boolean:
        return "bool"
    if type(dbus_value) == dbus.Int32:
        return "sint"
    if type(dbus_value) == dbus.UInt32:
        return "uint"
    if type(dbus_value) == dbus.Byte:
        return "char"
    if type(dbus_value) == dbus.String:
        return "str"

    return None                         # throw exception here?

def dbus_typesig_to_type_string(type_char):
    type_char = str(type_char)
    if type_char == 'i':
        return "sint"
    if type_char == 'u':
        return "uint"
    if type_char == 'y':
        return "char"
    if type_char == 's':
        return "str"
    if type_char == 'b':
        return "bool"

    print 'shit'
    return None                         # throw exception here?

def get_parameters(iface, path):
    params = iface.GetParametersInfo(path)
                
    #print params
    for param in params:
        typestr = dbus_typesig_to_type_string(param[0])
        name = param[1]
        #print name
        descr = param[2]
        #print descr
        isset, default, value = iface.GetParameterValue(path + [name])
        #print typestr
        if bool(isset):
            isset = "set"
        else:
            isset = "notset"
        value = dbus_type_to_python_type(value)
        default = dbus_type_to_python_type(default)

        print "%20s: %s (%s:%s:%s:%s)" %(name, descr, typestr, isset, default, value)

def print_help():
    print "Usage: %s [command] [command] ..." % os.path.basename(sys.argv[0])
    print "Commands:"
    print "    exit                       - exit jack dbus service (stops jack server if currently running)"
    print "    help                       - print this help text"
    print "    status                     - check whether jack server is started, return value is 0 if running and 1 otherwise"
    print "    start                      - start jack server if not currently started"
    print "    stop                       - stop jack server if currently started"
    print "    sm                         - switch master to currently selected driver"
    print "    dl                         - get list of available drivers"
    print "    dg                         - get currently selected driver"
    print "    ds <driver>                - select driver"
    print "    dp                         - get parameters of currently selected driver"
    print "    dpd <param>                - get long description for driver parameter"
    print "    dps <param> <value>        - set driver parameter"
    print "    dpr <param>                - reset driver parameter to its default value"
    print "    asd <driver>               - add slave driver"
    print "    rsd <driver>               - remove slave driver"
    print "    il                         - get list of available internals"
    print "    ip <name>                  - get parameters of given internal"
    print "    ipd <name> <param>         - get long description for internal parameter"
    print "    ips <name> <param> <value> - set internal parameter"
    print "    ipr <name> <param>         - reset internal parameter to its default value"
    print "    iload <name>               - load internal"
    print "    iunload <name>             - unload internal"
    print "    ep                         - get engine parameters"
    print "    epd <param>                - get long description for engine parameter"
    print "    eps <param> <value>        - set engine parameter"
    print "    epr <param>                - reset engine parameter to its default value"

def maybe_print_param_constraint(iface, param):
    is_range, is_strict, is_fake, values = iface.GetParameterConstraint(param)
    if is_range:
        print
        print("allowed range: %s to %s (inclusive)" % (values[0][0], values[1][0]))
    elif len(values):
        print
        if is_strict:
            print("allowed values:")
        else:
            print("suggested values:")

        max_len = 0
        for value in values:
            if len(str(value[0])) > max_len:
                   max_len = len(str(value[0]))
        for value in values:
            print("%*s'%s' - %s" % (1 + max_len - len(str(value[0])), "", str(value[0]), str(value[1])))

def main():
    if len(sys.argv) == 1 or sys.argv[1] in ["-h", "--help", "help"]:
        print_help()
        sys.exit(0)
    
    bus = dbus.SessionBus()

    controller = bus.get_object(service_name, "/org/jackaudio/Controller")
    control_iface = dbus.Interface(controller, control_interface_name)
    configure_iface = dbus.Interface(controller, configure_interface_name)

    # check arguments
    index = 1
    while index < len(sys.argv):
        arg = sys.argv[index]
        index += 1
        try:
            if arg == "exit":
                print "--- exit"
                control_iface.Exit()
            elif arg == "status":
                print "--- status"
                if control_iface.IsStarted():
                    print "started"
                    sys.exit(0)
                else:
                    print "stopped"
                    sys.exit(1)
            elif arg == 'start':
                print "--- start"
                control_iface.StartServer()
            elif arg == 'stop':
                print "--- stop"
                control_iface.StopServer()
	    elif arg == 'sm':
                print "--- switch master driver"
                control_iface.SwitchMaster()
            elif arg == 'ism':
                if control_iface.IsManuallyActivated():
                    print "Manually activated"
                else:
                    print "Automatically activated"
            elif arg == 'dl':
                print "--- drivers list"
                is_range, is_strict, is_fake_values, values = configure_iface.GetParameterConstraint(['engine', 'driver'])
                for value in values:
                    print value[1]
            elif arg == 'dg':
                print "--- get selected driver"
                isset, default, value = configure_iface.GetParameterValue(['engine', 'driver'])
                print value
            elif arg == 'ds':
                if index >= len(sys.argv):
                    print "driver select command requires driver name argument"
                    sys.exit()

                arg = sys.argv[index]
                index += 1

                print "--- driver select \"%s\"" % arg
                configure_iface.SetParameterValue(['engine', 'driver'], dbus.String(arg))
            elif arg == 'dp':
                print "--- get driver parameters (type:isset:default:value)"
                get_parameters(configure_iface, ['driver'])
            elif arg == 'dpd':
                if index >= len(sys.argv):
                    print "get driver parameter long description command requires parameter name argument"
                    sys.exit()

                param = sys.argv[index]
                index += 1

                print "--- get driver parameter description (%s)" % param
                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['driver', param])
                print long_descr
                maybe_print_param_constraint(configure_iface, ['driver', param])
            elif arg == 'dps':
                if index + 1 >= len(sys.argv):
                    print "driver parameter set command requires parameter name and value arguments"
                    sys.exit()

                param = sys.argv[index]
                index += 1
                value = sys.argv[index]
                index += 1

                print "--- driver param set \"%s\" -> \"%s\"" % (param, value)

                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['driver', param])
                configure_iface.SetParameterValue(['driver', param], python_type_to_jackdbus_type(value, type_char))
            elif arg == 'dpr':
                if index >= len(sys.argv):
                    print "driver parameter reset command requires parameter name argument"
                    sys.exit()

                param = sys.argv[index]
                index += 1

                print "--- driver param reset \"%s\"" % param
                configure_iface.ResetParameterValue(['driver', param])
            elif arg == 'ep':
                print "--- get engine parameters (type:isset:default:value)"
                get_parameters(configure_iface, ['engine'])
            elif arg == 'epd':
                if index >= len(sys.argv):
                    print "get engine parameter long description command requires parameter name argument"
                    sys.exit()

                param_name = sys.argv[index]
                index += 1

                print "--- get engine parameter description (%s)" % param_name

                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['engine', param_name])
                print long_descr
                maybe_print_param_constraint(configure_iface, ['engine', param_name])
            elif arg == 'eps':
                if index + 1 >= len(sys.argv):
                    print "engine parameter set command requires parameter name and value arguments"
                    sys.exit()

                param = sys.argv[index]
                index += 1
                value = sys.argv[index]
                index += 1

                print "--- engine param set \"%s\" -> \"%s\"" % (param, value)

                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['engine', param])
                configure_iface.SetParameterValue(['engine', param], python_type_to_jackdbus_type(value, type_char))
            elif arg == 'epr':
                if index >= len(sys.argv):
                    print "engine parameter reset command requires parameter name"
                    sys.exit()

                param = sys.argv[index]
                index += 1

                print "--- engine param reset \"%s\"" % param

                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['engine', param])
                configure_iface.ResetParameterValue(['engine', param])
            elif arg == 'il':
                print "--- internals list"
                is_leaf, internals = configure_iface.ReadContainer(['internals'])
                for internal in internals:
                    print internal
            elif arg == 'ip':
                print "--- get internal parameters (type:isset:default:value)"

                if index >= len(sys.argv):
                    print "internal parameters command requires internal name argument"
                    sys.exit()

                internal_name = sys.argv[index]
                index += 1

                get_parameters(configure_iface, ['internals', internal_name])
            elif arg == 'ipd':
                if index + 1 >= len(sys.argv):
                    print "get internal parameter long description command requires internal and parameter name arguments"
                    sys.exit()

                name = sys.argv[index]
                index += 1
                param = sys.argv[index]
                index += 1

                print "--- get internal parameter description (%s)" % param
                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['internals', name, param])
                print long_descr
            elif arg == 'ips':
                if index + 2 >= len(sys.argv):
                    print "internal parameter set command requires internal, parameter name and value arguments"
                    sys.exit()

                internal_name = sys.argv[index]
                index += 1
                param = sys.argv[index]
                index += 1
                value = sys.argv[index]
                index += 1
                
                print "--- internal param set \"%s\" -> \"%s\"" % (param, value)

                type_char, name, short_descr, long_descr = configure_iface.GetParameterInfo(['internals', internal_name, param])
                configure_iface.SetParameterValue(['internals', internal_name, param], python_type_to_jackdbus_type(value, type_char))
            elif arg == 'ipr':
                if index + 1 >= len(sys.argv):
                    print "reset internal parameter command requires internal and parameter name arguments"
                    sys.exit()

                internal_name = sys.argv[index]
                index += 1
                param = sys.argv[index]
                index += 1

                print "--- internal param reset \"%s\"" % param

                configure_iface.ResetParameterValue(['internals', internal_name, param])
            elif arg == 'iload':
                print "--- load internal"

                if index >= len(sys.argv):
                    print "load internal command requires internal name argument"
                    sys.exit()

                name = sys.argv[index]
                index += 1
                result = control_iface.LoadInternal(name)
            elif arg == 'iunload':
                print "--- unload internal"

                if index >= len(sys.argv):
                    print "unload internal command requires internal name argument"
                    sys.exit()

                name = sys.argv[index]
                index += 1
                result = control_iface.UnloadInternal(name)
            elif arg == 'asd':
                print "--- add slave driver"

                if index >= len(sys.argv):
                    print "add slave driver command requires driver name argument"
                    sys.exit()

                name = sys.argv[index]
                index += 1
                result = control_iface.AddSlaveDriver(name)
            elif arg == 'rsd':
                print "--- remove slave driver"

                if index >= len(sys.argv):
                    print "remove slave driver command requires driver name argument"
                    sys.exit()

                name = sys.argv[index]
                index += 1
                result = control_iface.RemoveSlaveDriver(name)
            else:
                print "Unknown command '%s'" % arg
        except dbus.DBusException, e:
            print "DBus exception: %s" % str(e)

if __name__ == '__main__':
    main()