clock_window 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a68f2579815d0a4bf42ad1461d0e151701ac823
4
- data.tar.gz: 7950b4b9b16103050b2b3428f32e8b0dedb64490
3
+ metadata.gz: 789009a8034c0fcb56948acdf856fae333147663
4
+ data.tar.gz: 7b8ecd4e7cb8d76beef0190496c8543098a4291f
5
5
  SHA512:
6
- metadata.gz: 8f4dd5db4d0c2680c0d5d192dbeb3904fc71ed9948cffb48520e3ecae3de60f1497460688e5625d4f440aec229a50a0f08f19201f903da928b45b0f750cd6a9c
7
- data.tar.gz: 662320c654745e663372afff034009fe7a1d08ef7dadd36221be837040496b15467c470e0a720b68e0c27b20a753151e4467f2f40da0121dd46e88ac3e7a7391
6
+ metadata.gz: be813c91da26558ff6135443ac5acff49452d4359e6f57e643467077be053539fe1105ba0ec6216344b1ae4ad90aaa806756792f4b3cdb72be9b9a346086c13c
7
+ data.tar.gz: 6588562f821eb56492699ce73c88091a198c2d5b65486dfa17d3e1cf01603444ac6ff08b87602129682ee2c964563531f9fb99fac0a0c241c24fe6e60bc152dd
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'neatjson'
3
+ require 'clock_window'
4
4
  @hash = {}
5
5
  begin
6
6
  loop do
7
7
  sleep 15
8
- x = `xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) _NET_WM_NAME`
9
- x = x.match(/.*\"(.*)\"\n\z/)[1][0..60]
8
+ x = ClockWindow::ClockIt.new.active_window
10
9
  @hash[x] = @hash[x].to_f + 0.25
11
10
  end
12
11
  ensure
@@ -1,4 +1,39 @@
1
1
  require "clock_window/version"
2
2
 
3
3
  module ClockWindow
4
+ class ClockIt
5
+ # As this will get more sophisticated this class is the UI
6
+ def initialize
7
+ @os_cmd = OScommand.new
8
+ end
9
+
10
+ def active_window
11
+ exe, format = @os_cmd.active_window
12
+ format.call(`#{exe}`)
13
+ end
14
+ end
15
+
16
+ class OScommand
17
+ # As this will get more sophisticated this class is the Back End
18
+ def initialize
19
+ # Detect operating system
20
+ @os = "Linux"
21
+ end
22
+
23
+ # output will be a two parameter array
24
+ # the first will be an OS specific executable string
25
+ # the second will be formatting the return value from the executables output
26
+ def active_window
27
+ # Choose script to execute and format output to just window name
28
+ case @os
29
+ when "Linux"
30
+ exe = "xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) _NET_WM_NAME"
31
+ format = ->str{ str.match(/.*\"(.*)\"\n\z/)[1][0..60] }
32
+ [exe, format]
33
+ else
34
+ raise "Not implemented"
35
+ end
36
+ end
37
+ end
38
+ private_constant :OScommand
4
39
  end
@@ -1,3 +1,3 @@
1
1
  module ClockWindow
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clock_window
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark