ioled 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +9 -0
  3. data/bin/ioled +62 -0
  4. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8212ffb0d6a77810014825c72f3e64130bff30ae
4
+ data.tar.gz: 9c440c56fa25a6e6ebb19d45bd3c39a8c5ca5db4
5
+ SHA512:
6
+ metadata.gz: c606f0af3e7e551231e6ebabdb16ba185a9b7bc397cdac539cb982160c2df2fb6eb8cd327b2c0e1a959bc3cc6f23b8eabe199a1498ba8314f3ec57a4dea0e7f4
7
+ data.tar.gz: 5fa3af2ddd32d2261cc56613d803b99200940b52ec5e1570613301ffbc29e32371ab314a967801cd27ccc35fbbc30217289723a80b8d84a3dea99f05fb0a2702
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # About
2
+ This utility converts your keyboards's capslock led to a disk access indicator led. It only works on OS X and requires the use of fs_usage, which in turn requires root privileges. Hence, run with sudo or suggest some other method of monitoring disk access.
3
+
4
+ # Installation
5
+ `gem install ioled`
6
+
7
+ # Usage
8
+ `sudo ioled`
9
+
data/bin/ioled ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'maclight'
4
+
5
+
6
+ # what to monitor (fs_usage requires root privileges)
7
+ cmd = 'fs_usage -f diskio -w'
8
+
9
+ # which disk to match
10
+ diskln = '/dev/disk1'
11
+
12
+ # STATUS[:wason] is used to buffer the state, since calling MacLight
13
+ # in vain would cause quite high CPU utilization by this process
14
+ STATUS = {
15
+ :wason => true # just in case it's initially on for some reason
16
+ }
17
+
18
+ def off
19
+ if STATUS[:wason]
20
+ MacLight.all_leds(false)
21
+ STATUS[:wason] = false
22
+ end
23
+ end
24
+
25
+ def on
26
+ if not STATUS[:wason]
27
+ MacLight.all_leds(true)
28
+ STATUS[:wason] = true
29
+ end
30
+ end
31
+
32
+ # initally turn led off
33
+ off
34
+
35
+ # spawns fs_usage and turns led on, when the device matches:
36
+ Thread.new do
37
+ require 'pty'
38
+ PTY.spawn(cmd) do |stdout, stdin, pid|
39
+ begin
40
+ stdout.each do |line|
41
+ stripln = line.strip
42
+ splitln = stripln.split(' ').map do |part|
43
+ part.strip
44
+ end
45
+ on if splitln[4] == diskln
46
+ end
47
+ rescue Errno::EIO
48
+ puts 'EIO error'
49
+ end
50
+ end
51
+ end
52
+
53
+ # waits to be killed and turns the led off after 50ms:
54
+ while true do
55
+ begin
56
+ sleep 0.05
57
+ off
58
+ rescue Interrupt
59
+ off
60
+ exit
61
+ end
62
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ioled
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Juha-Jarmo Heinonen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This utility converts your keyboards's capslock led to a disk access
14
+ indicator led. It only works on OS X.
15
+ email: o@sorsacode.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - bin/ioled
22
+ homepage: http://github.com/jammi/ioled
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.5.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Blinks your capslock led on disk access (OS X)
46
+ test_files: []
47
+ has_rdoc: