diff --git a/locale/en.json b/locale/en.json index e45a2fa1..2215c02c 100644 --- a/locale/en.json +++ b/locale/en.json @@ -44,5 +44,6 @@ "using_ephemeral": "Staring ephemeral Tor hidden service and awaiting publication", "gui_download_progress_complete": "%p%, Time Elapsed: {0:s}", "gui_download_progress_starting": "{0:s}, %p% (Computing ETA)", - "gui_download_progress_eta": "{0:s}, ETA: {1:s}, %p%" + "gui_download_progress_eta": "{0:s}, ETA: {1:s}, %p%", + "version_string": "Onionshare {0:s} | https://onionshare.org/" } diff --git a/onionshare/helpers.py b/onionshare/helpers.py index c2c4793f..43dd7819 100644 --- a/onionshare/helpers.py +++ b/onionshare/helpers.py @@ -58,7 +58,7 @@ def get_html_path(filename): """ Returns the path of the html files. """ - p = platform.system() + p = get_platform() if p == 'Darwin': prefix = os.path.join(osx_resources_dir, 'html') else: @@ -66,6 +66,20 @@ def get_html_path(filename): return os.path.join(prefix, filename) +def get_version(): + """ + Returns the version of OnionShare that is running. + """ + p = get_platform() + if p == 'Linux': + version_filename = os.path.join(sys.prefix, 'share/onionshare/version') + elif p == 'Darwin': + version_filename = os.path.join(helpers.osx_resources_dir, 'version') + else: + version_filename = os.path.join(os.path.dirname(helpers.get_onionshare_dir()), 'version') + return open(version_filename).read().strip() + + def constant_time_compare(val1, val2): """ Compares two values in constant time. diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index edc74693..e10fe65d 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -97,6 +97,7 @@ def main(cwd=None): onionshare uses. """ strings.load_strings() + print strings._('version_string').format(helpers.get_version()) # onionshare CLI in OSX needs to change current working directory (#132) if helpers.get_platform() == 'Darwin': diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 9f2eea70..31f6cea6 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -111,6 +111,9 @@ class OnionShareGui(QtGui.QWidget): # status bar self.status_bar = QtGui.QStatusBar() self.status_bar.setSizeGripEnabled(False) + version_label = QtGui.QLabel('v{0:s}'.format(helpers.get_version())) + version_label.setStyleSheet('color: #666666;') + self.status_bar.addPermanentWidget(version_label) # main layout self.layout = QtGui.QVBoxLayout() @@ -260,6 +263,7 @@ def main(): The main() function implements all of the logic that the GUI version of onionshare uses. """ strings.load_strings() + print strings._('version_string').format(helpers.get_version()) # start the Qt app global qtapp diff --git a/setup.py b/setup.py index f56ff834..21ef0906 100644 --- a/setup.py +++ b/setup.py @@ -90,6 +90,7 @@ if system == 'Linux': (os.path.join(sys.prefix, 'share/applications'), ['install/onionshare.desktop']), (os.path.join(sys.prefix, 'share/appdata'), ['install/onionshare.appdata.xml']), (os.path.join(sys.prefix, 'share/pixmaps'), ['install/onionshare80.xpm']), + (os.path.join(sys.prefix, 'share/onionshare'), ['version']), (os.path.join(sys.prefix, 'share/onionshare/images'), images), (os.path.join(sys.prefix, 'share/onionshare/locale'), locale) ]