sps_messenger 0.1.0 → 0.2.0
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
- checksums.yaml.gz.sig +0 -0
- data/lib/sps_messenger.rb +37 -6
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 134322327d440891bcf7bfccf87822e02f03a0a5
|
4
|
+
data.tar.gz: 0fe0b79ddea6cb3fba3093313b3c9c38a46ae4d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e99ddeee19c691d19570835b9e892ce22572418ba5215c8f5958805ff2b796b903a0ded3eae39839c24196683d69415d49b2eb1db541021828ffbe7a18ba1da1
|
7
|
+
data.tar.gz: 269847fad9def20f8e04860eae5ba0f8ad12353a5e88653d75ada3c662a867b490a281b117e3cddb4630dfb5e4f6ad0b037c40bc7c49e5b792082ac7f7f7fceb
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/sps_messenger.rb
CHANGED
@@ -14,7 +14,9 @@
|
|
14
14
|
# * price of Bitcoin
|
15
15
|
# * latest RSS headlines etc.
|
16
16
|
|
17
|
+
require "socket"
|
17
18
|
require 'sps-sub'
|
19
|
+
require 'sps-pub'
|
18
20
|
require "curses"
|
19
21
|
include Curses
|
20
22
|
|
@@ -22,12 +24,10 @@ include Curses
|
|
22
24
|
|
23
25
|
class SPSMessenger < SPSSub
|
24
26
|
|
25
|
-
def onmessage(msg)
|
26
|
-
clear_screen()
|
27
|
-
puts msg
|
28
|
-
end
|
29
27
|
|
30
|
-
def start(
|
28
|
+
def start(watchx: false, pub_host: 'sps', pub_port: '59000',
|
29
|
+
client_id: Socket.gethostname)
|
30
|
+
|
31
31
|
Curses.init_screen
|
32
32
|
#x = Curses.cols / 2 # We will center our text
|
33
33
|
x = 0
|
@@ -39,8 +39,11 @@ class SPSMessenger < SPSSub
|
|
39
39
|
init_pair(COLOR_YELLOW,COLOR_YELLOW,COLOR_BLACK)
|
40
40
|
attron(color_pair(COLOR_GREEN)|A_NORMAL){ addstr('ready ') }
|
41
41
|
refresh()
|
42
|
+
|
43
|
+
Thread.new { watch_xset(pub_host, pub_port, client_id) } if watchx
|
42
44
|
|
43
|
-
subscribe()
|
45
|
+
subscribe(topic: 'messenger | ' + client_id + '/messenger')
|
46
|
+
|
44
47
|
end
|
45
48
|
|
46
49
|
private
|
@@ -69,6 +72,34 @@ class SPSMessenger < SPSSub
|
|
69
72
|
end
|
70
73
|
|
71
74
|
end
|
75
|
+
|
76
|
+
# Monitors the state of the monitor (either On or Off).
|
77
|
+
# To use this feature you must be using X Windows and have DPMS enabled.
|
78
|
+
# To enable DPMS, go to the screensaver settings, click on the *advanced*
|
79
|
+
# tab and enable power management. Note: This only enables the power
|
80
|
+
# management of the monitor.
|
81
|
+
#
|
82
|
+
def watch_xset(host, port, client_id)
|
83
|
+
|
84
|
+
pub = SPSPub.new host: host, port: port
|
85
|
+
pub.notice 'sps_messenger: publisher ready'
|
86
|
+
old_state = 'on'
|
87
|
+
|
88
|
+
loop do
|
89
|
+
|
90
|
+
state = `xset -q`[/(?<=Monitor is )\w+/].downcase
|
91
|
+
|
92
|
+
if state != old_state then
|
93
|
+
pub.notice "monitor/%s/%s: Display monitor for %s is now %s " % \
|
94
|
+
[state, client_id.downcase,client_id.downcase, state]
|
95
|
+
old_state = state
|
96
|
+
end
|
97
|
+
|
98
|
+
sleep 1
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
72
103
|
|
73
104
|
end
|
74
105
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sps_messenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
w49j6lo3SYntBH8faZClS/o2IYpidKzYdUljN0rBk2csvAD/Xzhm5Sh6toNo7V7G
|
31
31
|
fpc=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-02-
|
33
|
+
date: 2018-02-03 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: sps-sub
|
metadata.gz.sig
CHANGED
Binary file
|