diff options
| author | Paul Buetow <paul@buetow.org> | 2012-04-21 12:30:58 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2012-04-21 12:30:58 +0200 |
| commit | e682c81a46d1f96e9f44a742e8f949d5935e5f79 (patch) | |
| tree | d5cbc6490e0c6a728e281c991f829b16ef25ebcb /lib | |
| parent | 109b41b1368b44377f1d6228659bf920718cadf0 (diff) | |
version number is not hard coded anymore
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Loadbars/Constants.pm | 1 | ||||
| -rw-r--r-- | lib/Loadbars/Main.pm | 3 | ||||
| -rw-r--r-- | lib/Loadbars/Utils.pm | 18 |
3 files changed, 19 insertions, 3 deletions
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 <loadbars@mx.buetow.org>', 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; |
