termclock 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 746cefa7bb14ad6ea4c2886b3631047a1d28eaf65a23709f69dd53a1af139929
4
- data.tar.gz: 5f71dfabd6b0608b41f7707d89d09521b2d1121d8206f5279d67be242fd49850
3
+ metadata.gz: b642d436f341a05ce85e4203af397fe5b3bc37ffa0c562584c4239d986528949
4
+ data.tar.gz: 3352cdd08951821375f5fe6b177c3be8e68bab5af267bfdfead6448a30a8b293
5
5
  SHA512:
6
- metadata.gz: ac18271d58739a9061f6c582d031f2bcd8e329259069681e8abb253a14af60307fb3253ff8468509afdc01057e2f802cbe1c32ba7d08a91c5df2ab944b65adc3
7
- data.tar.gz: 83e4ebc5a42e09cc880bd11468730266d8807b8aee72a873b04e8acf1867bcc9ae6500e13909ed421a37b6888c6bcaea9e8764ab5b0d6c7f6f0c0e02374af75c
6
+ metadata.gz: '038ed7235df48c8770a3b3dd87e60ec15400b71b8ec25757e186f1ff2bd3ba6c028da1c21144a8295f3eda575ef6872d050594a1f4e49f3e7afae43967ac53a1'
7
+ data.tar.gz: 283724a271297ef9af4bd07efa055112f537a91827f4a662f4420754243b383d33981daab6c2ec524409bfff288fbc96e939d6598d3af4c56fad48215830fd9a
@@ -1,7 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'termclock'
3
+ $-v = nil
3
4
 
4
- $-v = true
5
+ if ARGV.any? { |x| x[/\A\-(\-help|h)\z/] }
6
+ puts <<~EOF
7
+ TermClock: A clock that runs on the LinuxTerminal!
8
+
9
+ Arguments:
10
+ --help|-h\t\t\tShows this help section
11
+ --character=|char=\t\tDraws specified character
12
+ --clean\t\t\t\tJust run the clean bare clock
13
+ --colour=|-c=\t\t\tSpecify hex colour (4 colours)
14
+ \t\t\t\t[ with or without # ]
15
+ --no-date|-nd\t\t\tShows no date
16
+ --no-message|-nm\t\tShows no messages
17
+ --no-sysinfo|-ni\t\tShows no system info
18
+ --text-colour|-tc\t\tSpecify text colour (2 colours)
19
+ EOF
20
+
21
+ exit 0
22
+ end
5
23
 
6
24
  begin
7
25
  print "\e[?25l"
@@ -24,16 +42,34 @@ begin
24
42
  }
25
43
 
26
44
  chars = ARGV.find { |x| x[/\A\-(\-character|char)=.*\z/] } &.split(?=) &.at(1)
27
- Termclock::ParseCharacters.transform_characters!(chars[0]) if chars
45
+ Termclock::ParseCharacters.transform_characters!(*chars) if chars
28
46
 
29
47
  _refresh_time = ARGV.find { |x| x[/\A\-(\-refresh|r)=.*\z/] } &.split(?=) &.at(1)
30
48
  refresh_time = _refresh_time ? _refresh_time.to_f : 0.1
31
49
 
32
50
  text_colours = ARGV.find { |x| x[/\A\-(\-text\-colour|tc)=.*\z/] } &.split(?=) &.at(1) &.split(?,)
33
-
34
51
  abort("Text colours need 2 colours. Example: -tc=55f,3ce3b5") if text_colours && text_colours.length != 2
35
52
 
36
- Termclock.start(*colours, *text_colours, sleep: refresh_time)
53
+ bold = ARGV.any? { |x| x[/\A\-\-bold\z/] }
54
+ no_print_info = ARGV.any? { |x| x[/\A\-(\-no\-sysinfo|ni)\z/] }
55
+ no_print_message = ARGV.any? { |x| x[/\A\-(\-no\-message|nm)\z/] }
56
+ no_print_date = ARGV.any? { |x| x[/\A\-(\-no\-date|nd)\z/] }
57
+
58
+ clean = ARGV.any? { |x| x[/\A\-(\-clean)\z/] }
59
+
60
+ if clean
61
+ no_print_info = no_print_message = no_print_date = true
62
+ end
63
+
64
+ Termclock.start(
65
+ *colours,
66
+ *text_colours,
67
+ sleep: refresh_time,
68
+ bold: bold,
69
+ print_info: !no_print_info,
70
+ print_message: !no_print_message,
71
+ print_date: !no_print_date
72
+ )
37
73
  rescue Interrupt, SignalException
38
74
  print "\e[H\e[2J\e[3J"
39
75
  ensure
@@ -2,6 +2,7 @@ require 'linux_stat'
2
2
  require 'io/console'
3
3
  require_relative "termclock/string"
4
4
  require_relative "termclock/parse_characters"
5
+ require_relative "termclock/system_info"
5
6
  require_relative "termclock/main"
6
7
  require_relative "termclock/hex2rgb"
7
8
  require_relative "termclock/version"
@@ -2,7 +2,12 @@ module Termclock
2
2
  COLOURTERM = ENV.key?('COLORTERM')
3
3
  CLEAR = COLOURTERM ? "\e[H\e[2J\e[3J" : "\e[H"
4
4
 
5
- def self.start(colour1, colour2, colour3, colour4, textcolour1 = nil, textcolour2 = nil, sleep: 0.1)
5
+ def self.start(colour1, colour2, colour3, colour4, textcolour1 = nil,
6
+ textcolour2 = nil, sleep: 0.1, bold: false,
7
+ print_info: true, print_message: true,
8
+ print_date: true
9
+ )
10
+
6
11
  newline = ?\n.freeze
7
12
  space = ?\s.freeze
8
13
 
@@ -59,10 +64,14 @@ module Termclock
59
64
  current_net_usage_t = Thread.new { }
60
65
 
61
66
  message_time = Time.now.to_i - 5
67
+ message_counter = -1
62
68
  message = ''
69
+ message_final = ''
63
70
  message_temp = ''
64
71
  caret = "\u2588"
65
72
 
73
+ date, info = '', ''
74
+
66
75
  get_message = proc {
67
76
  case Time.now.hour
68
77
  when 5...12
@@ -80,27 +89,10 @@ module Termclock
80
89
  end
81
90
  }
82
91
 
83
- i = -1
84
92
  while true
85
- i += 1
86
93
  time_now = Time.now
87
94
  height, width = *STDOUT.winsize
88
95
 
89
- message_align = width - i % width + message.length / 2 - 4
90
-
91
- if (width - i % width <= message.length)
92
- message.replace(message[1..-1])
93
- message_align = width - i % width + 4
94
- else
95
- message.clear if width - i % width == width
96
- message_temp = get_message.call
97
-
98
- if message_temp != message
99
- message << message_temp[message.length..message.length + 1]
100
-
101
- end
102
- end
103
-
104
96
  if time_now.to_f./(0.5).to_i.even?
105
97
  splitter = ?:.freeze
106
98
  _caret = caret
@@ -109,81 +101,45 @@ module Termclock
109
101
  _caret = ''
110
102
  end
111
103
 
112
- time = time_now.strftime("%H %M %S %2N").split.join(splitter)
113
- art = Termclock::ParseCharacters.display(time).lines
114
-
115
- art_aligned = art.each_with_index do |x, i|
116
- chomped = x.chomp(''.freeze).+(newline)
117
- gr = chomped.gradient(*colours[i])
118
- x.replace(space.*(width./(2.0).-(chomped.length / 2.0).abs.to_i + 1) + gr)
119
- end.join
120
-
121
- vertical_gap = "\e[#{height./(2.0).-(art.length / 2.0).to_i + 1}H"
104
+ if print_message
105
+ message_counter += 1
106
+ message_align = width - message_counter % width + message.length / 2 - 4
107
+ if (width - message_counter % width <= message.length)
108
+ message.replace(message[1..-1])
109
+ message_align = width - message_counter % width + 4
110
+ else
111
+ message.clear if width - message_counter % width == width
112
+ message_temp = get_message.call
113
+
114
+ if message_temp != message
115
+ message << message_temp[message.length..message.length + 1]
116
+ end
117
+ end
122
118
 
123
- unless cpu_usage_t.alive?
124
- cpu_usage_t = Thread.new { cpu_usage = LS::CPU.usage(0.25) }
119
+ message_final = message.rjust(message_align).+(_caret).gradient(tc1, tc2, exclude_spaces: true, bold: bold)
125
120
  end
126
121
 
127
- unless current_net_usage_t.alive?
128
- current_net_usage_t = Thread.new do
129
- _m = LS::Net.current_usage(0.25)
130
-
131
- _dl = LS::PrettifyBytes.convert_short_binary(_m[:received], precision: 0)
132
- _ul = LS::PrettifyBytes.convert_short_binary(_m[:transmitted], precision: 0)
133
-
134
- current_net_usage = "\u{1F4CA} Curr. DL/UL: #{sprintf "%-7s", _dl} | #{sprintf "%7s", _ul}"
135
- end
122
+ if print_info
123
+ info = system_info(width, tc1, tc2, bold)
136
124
  end
137
125
 
138
- cpu = "\u{1F9E0} CPU: #{sprintf "%5s", cpu_usage}% (#{LS::CPU.count_online} / #{LS::CPU.count})"
139
-
140
- battery = if LS::Battery.present?
141
- stat = LS::Battery.stat
142
- emoji = LS::Battery.charging? ? "\u{1F4A1}" : "\u{1F50B}"
143
- plug = LS::Battery.charging? ? "\u{1F50C} " : ''.freeze
144
- "#{emoji} Battery: #{stat[:charge].to_i}% (#{plug}#{stat[:status]})"
145
- else
146
- ''.freeze
126
+ if print_date
127
+ date = time_now.strftime('%a, %d %B %Y').center(width)
128
+ .gradient(tc1, tc2, bold: bold)
147
129
  end
148
130
 
149
- user = "\u{1F481} User: #{LS::User.get_current_user.capitalize}"
150
- hostname = "\u{1F4BB} Hostname: #{LS::OS.hostname}"
151
-
152
- _m = LS::Net.total_bytes
153
- ip = "\u{1F30F} IP Addr: #{LS::Net.ipv4_private}"
154
-
155
- net_usage = "\u{1F4C8} Totl. DL/UL: #{sprintf "%-7s", LS::PrettifyBytes.convert_short_binary(_m[:received], precision: 0)}"\
156
- " | #{sprintf "%7s", LS::PrettifyBytes.convert_short_binary(_m[:transmitted], precision: 0)}"
157
-
158
- _m = LS::Memory.stat
159
- memory = "\u{1F3B0} Mem: #{LS::PrettifyBytes.convert_short_binary(_m[:used].to_i * 1024)}"\
160
- " / #{LS::PrettifyBytes.convert_short_binary(_m[:total].to_i * 1024)}"\
161
- " (#{_m[:percent_used].to_i}%)"
162
-
163
- _m = LS::Swap.stat
164
- swap = "\u{1F300} Swap: #{LS::PrettifyBytes.convert_short_binary(_m[:used].to_i * 1024)}"\
165
- " / #{LS::PrettifyBytes.convert_short_binary(_m[:total].to_i * 1024)}"\
166
- " (#{_m[:percent_used].to_i}%)"
167
-
168
- _m = LS::Filesystem.stat
169
- fs = "\u{1F4BD} FS: #{LS::PrettifyBytes.convert_short_binary(_m[:used].to_i)}"\
170
- " / #{LS::PrettifyBytes.convert_short_binary(_m[:total].to_i)}"\
171
- " (#{_m[:used].to_i*(100).fdiv(_m[:total].to_i).round(2)}%)"
172
-
173
- process = "\u{1F9EE} Process: #{LS::Process.count}"
174
- message_final = message.rjust(message_align).+(_caret).gradient(tc1, tc2, exclude_spaces: true)
131
+ time = time_now.strftime('%H %M %S %2N').split.join(splitter)
132
+ art = Termclock::ParseCharacters.display(time).lines
175
133
 
176
- max_l = [hostname, process, ip, battery, current_net_usage, net_usage].map(&:length).max + 4
134
+ art_aligned = art.each_with_index do |x, i|
135
+ chomped = x.chomp(''.freeze).+(newline)
136
+ gr = chomped.gradient(*colours[i], bold: bold)
137
+ x.replace(space.*(width./(2.0).-(chomped.length / 2.0).abs.to_i + 1) + gr)
138
+ end.join
177
139
 
178
- info = <<~EOF.gradient(tc1, tc2, exclude_spaces: true)
179
- \s#{user}#{?\s.*(width.-(user.length + max_l).abs)}#{hostname}
180
- \s#{cpu}#{?\s.*(width.-(cpu.length + max_l).abs)}#{battery}
181
- \s#{memory}#{?\s.*(width.-(memory.length + max_l).abs)}#{ip}
182
- \s#{swap}#{?\s.*(width.-(swap.length + max_l).abs)}#{current_net_usage}
183
- \s#{fs}#{?\s.*(width.-(fs.length + max_l).abs)}#{net_usage}
184
- EOF
140
+ vertical_gap = "\e[#{height./(2.0).-(art.length / 2.0).to_i + 1}H"
185
141
 
186
- print "#{CLEAR}#{info}#{vertical_gap}#{art_aligned}\n#{message_final}"
142
+ print "#{CLEAR}#{info}#{vertical_gap}#{art_aligned}\n#{date}\n\n#{message_final}"
187
143
 
188
144
  if gc_compact && time_now.to_i > gc_compacted
189
145
  GC.compact
@@ -3,74 +3,74 @@ module Termclock
3
3
  NEWLINE = ?\n.freeze
4
4
  CHARACTERS = <<~EOF.freeze
5
5
  # 0
6
- ```````
7
- `` ``
8
- `` ``
9
- `` ``
10
- ```````
6
+ ````````
7
+ `` ``
8
+ `` ``
9
+ `` ``
10
+ ````````
11
11
 
12
12
  # 1
13
13
  ``
14
- ````
14
+ `````
15
15
  ``
16
16
  ``
17
- ```````
17
+ ````````
18
18
 
19
19
  # 2
20
- ```````
21
- ``
22
- ```````
20
+ ````````
21
+ ``
22
+ ````````
23
23
  ``
24
- ```````
24
+ ````````
25
25
 
26
26
  # 3
27
- ```````
28
- ``
29
- ```````
30
- ``
31
- ```````
27
+ ````````
28
+ ``
29
+ ````````
30
+ ``
31
+ ````````
32
32
 
33
33
  # 4
34
- `` ``
35
- `` ``
36
- ```````
37
- ``
38
- ``
34
+ `` ``
35
+ `` ``
36
+ ````````
37
+ ``
38
+ ``
39
39
 
40
40
  # 5
41
- ```````
41
+ ````````
42
42
  ``
43
- ```````
44
- ``
45
- ```````
43
+ ````````
44
+ ``
45
+ ````````
46
46
 
47
47
  # 6
48
- ```````
48
+ ````````
49
49
  ``
50
- ```````
51
- `` ``
52
- ```````
50
+ ````````
51
+ `` ``
52
+ ````````
53
53
 
54
54
  # 7
55
- ```````
56
- ``
57
- ``
58
- ``
59
- ``
55
+ ````````
56
+ ``
57
+ ``
58
+ ``
59
+ ``
60
60
 
61
61
  # 8
62
- ```````
63
- `` ``
64
- ```````
65
- `` ``
66
- ```````
62
+ ````````
63
+ `` ``
64
+ ````````
65
+ `` ``
66
+ ````````
67
67
 
68
68
  # 9
69
- ```````
70
- `` ``
71
- ```````
72
- ``
73
- ```````
69
+ ````````
70
+ `` ``
71
+ ````````
72
+ ``
73
+ ````````
74
74
 
75
75
  # :
76
76
  \u2B29\u2B29
@@ -86,88 +86,88 @@ module Termclock
86
86
  \s\s
87
87
  \s\s
88
88
  # A
89
- ```````
90
- `` ``
91
- ```````
92
- `` ``
93
- `` ``
89
+ ````````
90
+ `` ``
91
+ ````````
92
+ `` ``
93
+ `` ``
94
94
 
95
95
  # B
96
- ``````
97
- `` ``
98
- ``````
99
- `` ``
100
- ``````
96
+ ````````
97
+ `` ``
98
+ ````````
99
+ `` ``
100
+ ````````
101
101
 
102
102
  # C
103
- ```````
103
+ ````````
104
104
  ``
105
105
  ``
106
106
  ``
107
- ```````
107
+ ````````
108
108
 
109
109
  # D
110
- `````
111
- `` ``
112
- `` ``
113
- `` ``
114
- `````
110
+ ````````
111
+ `` ``
112
+ `` ``
113
+ `` ``
114
+ ````````
115
115
 
116
116
  # E
117
- ```````
117
+ ````````
118
118
  ``
119
- ```````
119
+ ````````
120
120
  ``
121
- ```````
121
+ ````````
122
122
 
123
123
  # F
124
- ```````
124
+ ````````
125
125
  ``
126
- ```````
126
+ ````````
127
127
  ``
128
128
  ``
129
129
 
130
130
  # G
131
- ```````
131
+ ````````
132
132
  ``
133
133
  ``
134
- `` ```
134
+ `` ````
135
135
  ````````
136
136
 
137
137
  # H
138
- `` ``
139
- `` ``
140
- ```````
141
- `` ``
142
- `` ``
138
+ `` ``
139
+ `` ``
140
+ ````````
141
+ `` ``
142
+ `` ``
143
143
 
144
144
  # I
145
- ```````
145
+ ````````
146
146
  `
147
147
  `
148
148
  `
149
- ```````
149
+ ````````
150
150
 
151
151
  # J
152
- ```````
153
- ``
154
- ``
155
- `` ``
156
- ``````
152
+ ````````
153
+ ``
154
+ ``
155
+ `` ``
156
+ ```````
157
157
 
158
158
  # K
159
- `` ``
160
- `` ``
161
- ````
162
- `` ``
163
- `` ``
159
+ `` ``
160
+ `` ``
161
+ `````
162
+ `` ``
163
+ `` ``
164
164
 
165
165
  # L
166
166
  ``
167
167
  ``
168
168
  ``
169
169
  ``
170
- ``````
170
+ ````````
171
171
 
172
172
  # M
173
173
  ``` ```
@@ -177,11 +177,11 @@ module Termclock
177
177
  `` ``
178
178
 
179
179
  # N
180
- ```` ``
181
- `` ` ``
182
- `` ` ``
183
- `` ` ``
184
- `` ```
180
+ ```` ``
181
+ `` `` ``
182
+ `` `` ``
183
+ `` `` ``
184
+ `` ````
185
185
 
186
186
  # O
187
187
  ````````
@@ -198,25 +198,25 @@ module Termclock
198
198
  ``
199
199
 
200
200
  # Q
201
- ```````
202
- `` ``
203
- ```````
204
- ``
205
- ``
201
+ ````````
202
+ `` ``
203
+ ````````
204
+ ``
205
+ ``
206
206
 
207
207
  # R
208
- ```````
208
+ ````````
209
+ `` ``
210
+ ````````
211
+ `````
209
212
  `` ``
210
- ```````
211
- ````
212
- `` ``
213
213
 
214
214
  # S
215
- ```````
215
+ ````````
216
216
  ``
217
- ```````
218
- ``
219
- ```````
217
+ ````````
218
+ ``
219
+ ````````
220
220
 
221
221
  # T
222
222
  ````````
@@ -226,32 +226,32 @@ module Termclock
226
226
  ``
227
227
 
228
228
  # U
229
- `` ``
230
- `` ``
231
- `` ``
232
- `` ``
233
- ```````
229
+ `` ``
230
+ `` ``
231
+ `` ``
232
+ `` ``
233
+ ````````
234
234
 
235
235
  # V
236
- `` ``
237
- `` ``
238
- `` ``
236
+ `` ``
237
+ `` ``
238
+ `` ``
239
239
  `` ``
240
240
  `
241
241
 
242
242
  # W
243
- `` ``
244
- `` ``
245
- `` ``
246
- `` ` ``
247
- `````````
243
+ `` ``
244
+ `` ``
245
+ `` ``
246
+ `` ` ``
247
+ ````````
248
248
 
249
249
  # X
250
- `` ``
251
- `` ``
252
- ``
253
- `` ``
254
- `` ``
250
+ ` `
251
+ ` `
252
+ `
253
+ ` `
254
+ ` `
255
255
 
256
256
  # Y
257
257
  `` ``
@@ -283,9 +283,23 @@ module Termclock
283
283
  end.freeze
284
284
 
285
285
  def transform_characters!(arg)
286
+ @@transformed ||= nil
287
+ fail RuntimeError, 'Characters already transformed!' if @@transformed
288
+ @@transformed ||= true
289
+
286
290
  @@characters.values.each { |x|
287
291
  stripped = x.strip[0]
288
- x.gsub!(stripped, arg) if stripped
292
+ chars = arg.chars.rotate(-1)
293
+
294
+ if stripped
295
+ replace_with = x.chars.map { |y|
296
+ chars = arg.chars.rotate(-1) if y == ?\n
297
+ next(y) if y != stripped
298
+ chars.rotate!(1)[0]
299
+ }.join
300
+
301
+ x.replace(replace_with)
302
+ end
289
303
  }
290
304
  end
291
305
 
@@ -1,5 +1,5 @@
1
1
  class String
2
- def gradient(*all_rgbs, bg: false, exclude_spaces: false)
2
+ def gradient(*all_rgbs, bg: false, exclude_spaces: false, bold: false)
3
3
  temp = ''
4
4
 
5
5
  r, g, b = all_rgbs[0]
@@ -45,6 +45,8 @@ class String
45
45
  _g = _g.send(g_op, g_val * -1) if g_op
46
46
  _b = _b.send(b_op, b_val * -1) if b_op
47
47
 
48
+ temp << "\e[1m" if bold
49
+
48
50
  i = -1
49
51
  while (i += 1) < len
50
52
  _c = c[i]
@@ -0,0 +1,73 @@
1
+ module Termclock
2
+ @@cpu_usage = 0
3
+ @@cpu_usage_t = Thread.new { }
4
+
5
+ @@current_net_usage = ''
6
+ @@current_net_usage_t = Thread.new { }
7
+
8
+ class << self
9
+ def system_info(width, tc1, tc2, bold)
10
+ unless @@cpu_usage_t.alive?
11
+ @@cpu_usage_t = Thread.new { @@cpu_usage = LS::CPU.usage(0.25) }
12
+ end
13
+
14
+ unless @@current_net_usage_t.alive?
15
+ @@current_net_usage_t = Thread.new do
16
+ _m = LS::Net.current_usage(0.25)
17
+
18
+ _dl = LS::PrettifyBytes.convert_short_binary(_m[:received], precision: 0)
19
+ _ul = LS::PrettifyBytes.convert_short_binary(_m[:transmitted], precision: 0)
20
+
21
+ @@current_net_usage = "\u{1F4CA} Curr. DL/UL: #{sprintf "%-7s", _dl} | #{sprintf "%7s", _ul}"
22
+ end
23
+ end
24
+
25
+ cpu = "\u{1F9E0} CPU: #{sprintf "%5s", @@cpu_usage}% (#{LS::CPU.count_online} / #{LS::CPU.count})"
26
+
27
+ battery = if LS::Battery.present?
28
+ stat = LS::Battery.stat
29
+ emoji = LS::Battery.charging? ? "\u{1F4A1}" : "\u{1F50B}"
30
+ plug = LS::Battery.charging? ? "\u{1F50C} " : ''.freeze
31
+ "#{emoji} Battery: #{stat[:charge].to_i}% (#{plug}#{stat[:status]})"
32
+ else
33
+ ''.freeze
34
+ end
35
+
36
+ user = "\u{1F481} User: #{LS::User.get_current_user.capitalize}"
37
+ hostname = "\u{1F4BB} Hostname: #{LS::OS.hostname}"
38
+
39
+ _m = LS::Net.total_bytes
40
+ ip = "\u{1F30F} IP Addr: #{LS::Net.ipv4_private}"
41
+
42
+ net_usage = "\u{1F4C8} Totl. DL/UL: #{sprintf "%-7s", LS::PrettifyBytes.convert_short_binary(_m[:received], precision: 0)}"\
43
+ " | #{sprintf "%7s", LS::PrettifyBytes.convert_short_binary(_m[:transmitted], precision: 0)}"
44
+
45
+ _m = LS::Memory.stat
46
+ memory = "\u{1F3B0} Mem: #{LS::PrettifyBytes.convert_short_binary(_m[:used].to_i * 1024)}"\
47
+ " / #{LS::PrettifyBytes.convert_short_binary(_m[:total].to_i * 1024)}"\
48
+ " (#{_m[:percent_used].to_i}%)"
49
+
50
+ _m = LS::Swap.stat
51
+ swap = "\u{1F300} Swap: #{LS::PrettifyBytes.convert_short_binary(_m[:used].to_i * 1024)}"\
52
+ " / #{LS::PrettifyBytes.convert_short_binary(_m[:total].to_i * 1024)}"\
53
+ " (#{_m[:percent_used].to_i}%)"
54
+
55
+ _m = LS::Filesystem.stat
56
+ fs = "\u{1F4BD} FS: #{LS::PrettifyBytes.convert_short_binary(_m[:used].to_i)}"\
57
+ " / #{LS::PrettifyBytes.convert_short_binary(_m[:total].to_i)}"\
58
+ " (#{_m[:used].to_i*(100).fdiv(_m[:total].to_i).round(2)}%)"
59
+
60
+ process = "\u{1F9EE} Process: #{LS::Process.count}"
61
+
62
+ max_l = [hostname, process, ip, battery, @@current_net_usage, net_usage].map(&:length).max + 4
63
+
64
+ <<~EOF.gradient(tc1, tc2, exclude_spaces: true, bold: bold)
65
+ \s#{user}#{?\s.*(width.-(user.length + max_l).abs)}#{hostname}
66
+ \s#{cpu}#{?\s.*(width.-(cpu.length + max_l).abs)}#{battery}
67
+ \s#{memory}#{?\s.*(width.-(memory.length + max_l).abs)}#{ip}
68
+ \s#{swap}#{?\s.*(width.-(swap.length + max_l).abs)}#{@@current_net_usage}
69
+ \s#{fs}#{?\s.*(width.-(fs.length + max_l).abs)}#{net_usage}
70
+ EOF
71
+ end
72
+ end
73
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Termclock
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termclock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sourav Goswami
@@ -38,6 +38,7 @@ files:
38
38
  - lib/termclock/main.rb
39
39
  - lib/termclock/parse_characters.rb
40
40
  - lib/termclock/string.rb
41
+ - lib/termclock/system_info.rb
41
42
  - lib/termclock/version.rb
42
43
  homepage: https://github.com/souravgoswami/termclock
43
44
  licenses: