summaryrefslogtreecommitdiff
path: root/xgpsspeed
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-11-26 17:20:41 -0800
committerJon Schlueter <jon.schlueter@gmail.com>2016-12-18 22:27:55 -0500
commit116c0b548aa8ce5430c9f19a40534b1056268f5b (patch)
tree105abf8b2b810a0018c0ac64f71c993ba09098a7 /xgpsspeed
parent40b8f6657f3766926900c7c552b0c25972d0230a (diff)
downloadgpsd-116c0b548aa8ce5430c9f19a40534b1056268f5b.tar.gz
Tweaks xgps and xgpsspeed UIs.
This makes a couple of minor improvements to the xgps[speed] UIs: 1) If a target (host/port/device) is specified, it is included in the window title. This is especially useful when running multiple instances pointing at different targets. 2) Interprets blank host and/or port fields in host:port:device notation as the default values. This allows, e.g., specifying a device without having to explicitly specify the default host/port. Also replaces all hardcoded '2947' instances with gps.GPSD_PORT. TESTED: Tried various arguments, including using the option forms in xgpsspeed. Also tried a long string of leading zeroes on the port number to verify that a ridiculously long target string is taken in stride.
Diffstat (limited to 'xgpsspeed')
-rwxr-xr-xxgpsspeed28
1 files changed, 20 insertions, 8 deletions
diff --git a/xgpsspeed b/xgpsspeed
index 29a6fc7d..612018f9 100755
--- a/xgpsspeed
+++ b/xgpsspeed
@@ -516,8 +516,9 @@ class NauticalSpeedometer(Speedometer):
class Main(object):
- def __init__(self, host='localhost', port='2947', device=None, debug=0,
- speed_unit=None, maxspeed=0, nautical=False, rotate=0.0):
+ def __init__(self, host='localhost', port=gps.GPSD_PORT, device=None,
+ debug=0, speed_unit=None, maxspeed=0, nautical=False,
+ rotate=0.0, target=[]):
self.host = host
self.port = port
self.device = device
@@ -529,7 +530,7 @@ class Main(object):
self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
if not self.window.get_display():
raise Exception("Can't open display")
- self.window.set_title('xgpsspeed')
+ self.window.set_title(' '.join(['xgpsspeed'] + target))
if self.nautical:
self.window.set_size_request(500, 550)
self.widget = NauticalSpeedometer(
@@ -690,14 +691,14 @@ if __name__ == '__main__':
parser.add_option(
'--host',
dest='host',
- default='localhost',
+ default=None,
help='The host to connect. [Default localhost]'
)
parser.add_option(
'--port',
dest='port',
- default='2947',
- help='The port to connect. [Default 2947]'
+ default=None,
+ help='The port to connect. [Default %s]' % gps.GPSD_PORT
)
parser.add_option(
'--device',
@@ -760,13 +761,24 @@ if __name__ == '__main__':
else:
parser.print_help()
sys.exit(0)
+ target = args[0:]
+ elif options.host or options.port or options.device:
+ target = [options.host or 'localhost']
+ if options.port or options.device:
+ target += [options.port or '']
+ if options.device:
+ target += [options.device]
+ target = [':'.join(target)]
+ else:
+ target = []
Main(
- host=options.host,
- port=options.port,
+ host=options.host or 'localhost',
+ port=options.port or gps.GPSD_PORT,
device=options.device,
speed_unit=options.speedunits,
maxspeed=options.maxspeed,
nautical=options.nautical,
debug=options.debug,
rotate=options.rotate,
+ target=target,
).run()