Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[Core] Mahewinwmfsstatus: Reorganize the code.

  • Loading branch information...
commit c521fc380f2305cd2c27c1fdb588f4596d32ee78 1 parent 7870ef9
hobbestigrou authored

Showing 1 changed file with 36 additions and 36 deletions. Show diff stats Hide diff stats

  1. +36 36 lib/MahewinWmfsStatus.pm
72 lib/MahewinWmfsStatus.pm
@@ -2,9 +2,9 @@ package MahewinWmfsStatus;
2 2
3 3 use Moose;
4 4
  5 +use Config::IniFiles;
5 6 use Sys::Statistics::Linux;
6 7 use Sys::Statistics::Linux::DiskUsage;
7   -use Config::IniFiles;
8 8
9 9 has _file_path => (
10 10 is => 'ro',
@@ -72,6 +72,41 @@ sub _build_lxs {
72 72 Sys::Statistics::Linux->new( memstats => 1, );
73 73 }
74 74
  75 +sub run {
  76 + my ($self) = @_;
  77 +
  78 + my $timing = $self->_config->val( 'misc', 'timing' ) || 1;
  79 +
  80 + while (1) {
  81 + sleep($timing);
  82 + $self->status();
  83 + }
  84 +}
  85 +
  86 +sub status {
  87 + my ($self) = @_;
  88 +
  89 + my $cfg = $self->_config;
  90 + my @call;
  91 +
  92 + my @sections = $self->_config->Sections();
  93 + my $dispatch = {
  94 + memory => $self->free(),
  95 + disk => $self->disk_space(),
  96 + date => $self->time_date(),
  97 + name => $self->name()
  98 + };
  99 +
  100 + foreach my $section (@sections) {
  101 + next if $section eq 'misc';
  102 +
  103 + $call[ $cfg->val( $section, 'position' ) ] = $dispatch->{$section}
  104 + if $cfg->val( $section, 'display' );
  105 + }
  106 +
  107 + `wmfs -c status "default @call"`;
  108 +}
  109 +
75 110 sub free {
76 111 my ($self) = @_;
77 112
@@ -148,30 +183,6 @@ sub name {
148 183 return $self->_stringify( 'name', $name[0] );
149 184 }
150 185
151   -sub status {
152   - my ($self) = @_;
153   -
154   - my $cfg = $self->_config;
155   - my @call;
156   -
157   - my @sections = $self->_config->Sections();
158   - my $dispatch = {
159   - memory => $self->free(),
160   - disk => $self->disk_space(),
161   - date => $self->time_date(),
162   - name => $self->name()
163   - };
164   -
165   - foreach my $section (@sections) {
166   - next if $section eq 'misc';
167   -
168   - $call[ $cfg->val( $section, 'position' ) ] = $dispatch->{$section}
169   - if $cfg->val( $section, 'display' );
170   - }
171   -
172   - `wmfs -c status "default @call"`;
173   -}
174   -
175 186 sub _stringify {
176 187 my ( $self, $type, $string ) = @_;
177 188
@@ -185,15 +196,4 @@ sub _stringify {
185 196 return "^s[right;$color;$string ]";
186 197 }
187 198
188   -sub run {
189   - my ($self) = @_;
190   -
191   - my $timing = $self->_config->val( 'misc', 'timing' ) || 1;
192   -
193   - while (1) {
194   - sleep($timing);
195   - $self->status();
196   - }
197   -}
198   -
199 199 1;

0 comments on commit c521fc3

Please sign in to comment.
Something went wrong with that request. Please try again.