From e682c81a46d1f96e9f44a742e8f949d5935e5f79 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 21 Apr 2012 12:30:58 +0200 Subject: version number is not hard coded anymore --- lib/Loadbars/Constants.pm | 1 - lib/Loadbars/Main.pm | 3 +-- lib/Loadbars/Utils.pm | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Loadbars/Constants.pm b/lib/Loadbars/Constants.pm index adffc47..e21c93a 100644 --- a/lib/Loadbars/Constants.pm +++ b/lib/Loadbars/Constants.pm @@ -6,7 +6,6 @@ use warnings; use SDL::Color; use constant { - VERSION => 'loadbars v0.5.2.1', COPYRIGHT => '2010-2012 (c) Paul Buetow ', CONFFILE => $ENV{HOME} . '/.loadbarsrc', CSSH_CONFFILE => '/etc/clusters', diff --git a/lib/Loadbars/Main.pm b/lib/Loadbars/Main.pm index 5b8f161..199a2e4 100644 --- a/lib/Loadbars/Main.pm +++ b/lib/Loadbars/Main.pm @@ -295,8 +295,7 @@ sub loop ($@) { $C{width} = $C{barwidth}; my $app = SDL::App->new( - -title => Loadbars::Constants->VERSION - . ' (press h for help on stdout)', + -title => 'Loadbars ' . get_version . ' (press h for help on stdout)', -icon_title => Loadbars::Constants->VERSION, -width => $C{width}, -height => $C{height}, diff --git a/lib/Loadbars/Utils.pm b/lib/Loadbars/Utils.pm index bfb8027..df5e0f7 100644 --- a/lib/Loadbars/Utils.pm +++ b/lib/Loadbars/Utils.pm @@ -18,6 +18,7 @@ our @EXPORT = qw ( say sum trim + get_version ); sub say (@) { print "$_\n" for @_; return undef } @@ -38,4 +39,21 @@ sub display_info_no_nl ($) { print "==> " . (shift) . ' ' } sub display_info ($) { say "==> " . shift } sub display_warn ($) { say "!!! " . shift } +sub get_version () { + my $versionfile = do { + if ( -f '.version' ) { + '.version'; + } + else { + '/usr/share/loadbars/version'; + } + }; + + open my $fh, $versionfile or error("$!: $versionfile"); + my $version = <$fh>; + close $fh; + + return $version; +} + 1; -- cgit v1.2.3