-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.hardstatusrc
81 lines (63 loc) · 1.71 KB
/
.hardstatusrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'json'
require 'socket'
require 'timeout'
right '#{irssi}#{email}#{hackers}#{processor}#{temperature}#{wireless}#{battery}'
def wrap (string)
"\005{= r}[\005{+b W}#{string}\005{= dr}] "
end
backtick :irssi, every: second do
notifications = File.read(File.expand_path('~/.irssi/notifications')).gsub(':', '@').split(/, /)
unless notifications.empty?
wrap "IRC\005{-b r}|" + notifications.map {|n|
"\005{+b rW}#{n}\005{-b dd}"
}.join(' ')
end
end
backtick :email, every: second do
socket = TCPSocket.new('localhost', '9001')
socket.puts '* list unread'
notifications = JSON.parse(socket.gets)
unless notifications.empty?
wrap "Mail\005{-b r}|" + notifications.map {|name|
"\005{+b rW}#{name}\005{-b dd}"
}.join(' ')
end
end
backtick :hackers, every: 5.seconds do
end
backtick :processor, every: 5.seconds do
wrap `(cpupower -c 0 frequency-info; cpupower -c 1 frequency-info) |
grep "current CPU" |
head -n 1 |
sed 's/^.*is //' |
sed 's/\.$//' |
tr -d '\n'`
end
backtick :temperature, every: 5.seconds do
`sensors`.match(/temp1:\s+([\d+\-.]+)/) { |m|
wrap(if m.to_i > 100
'STACCA STACCA STACC-'
else
"#{m} C"
end)
}
end
backtick :wireless, every: 5.seconds do
state = `iwconfig wlan0`
next if state =~ /No such device/
essid = state.match(/ESSID:"(.*?)"/)[1]
quality = state.match(/Quality=(.*?) /)[1]
if quality
wrap "#{essid}\005{-b r}|\005{+b W}#{quality}"
end
end
backtick :battery, every: 5.seconds do
state = `acpitool -B`
next if state =~ /100\.0%/
current = state.match(/([^\s]+%.*)$/)[1].sub(/, /, "\005{-b r}|\005{+b W}")
if state.match(/discharging/i)
wrap "\005{-b r}v|\005{+b W}#{current}"
else
wrap "^\005{-b r}|\005{+b W}#{current}"
end
end