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 +4 -4
- data/exe/clock_window +2 -3
- data/lib/clock_window.rb +35 -0
- data/lib/clock_window/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 789009a8034c0fcb56948acdf856fae333147663
|
4
|
+
data.tar.gz: 7b8ecd4e7cb8d76beef0190496c8543098a4291f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be813c91da26558ff6135443ac5acff49452d4359e6f57e643467077be053539fe1105ba0ec6216344b1ae4ad90aaa806756792f4b3cdb72be9b9a346086c13c
|
7
|
+
data.tar.gz: 6588562f821eb56492699ce73c88091a198c2d5b65486dfa17d3e1cf01603444ac6ff08b87602129682ee2c964563531f9fb99fac0a0c241c24fe6e60bc152dd
|
data/exe/clock_window
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'clock_window'
|
4
4
|
@hash = {}
|
5
5
|
begin
|
6
6
|
loop do
|
7
7
|
sleep 15
|
8
|
-
x =
|
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
|
data/lib/clock_window.rb
CHANGED
@@ -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
|
data/lib/clock_window/version.rb
CHANGED