batalert 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3feaa732f29966e9653afe5b681052f30032f3cd8da488895e5efe10b89f693b
4
+ data.tar.gz: 4046045ed406ea8fc9d3d1336fc3007d5ac6d36046187443324facef29c79add
5
+ SHA512:
6
+ metadata.gz: f7dbe5328616bc9b0befdfe5c2eec4e9208cb389e39a21614615a3f16475089fd1e913ce81c47f1ff7523da5647d0e0f3e92e92ab9a61635d4306ad74ff1c602
7
+ data.tar.gz: 549aa01a8dbdb5266b9278e0a8aceb2bfb5f1b31ecb0f257452af81f5b770d226dc1738032ea050af60cf8a51a5cd5f43d5d898329340fe2fc65aff88d7c2f05
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+ ===========
3
+
4
+ Copyright (©) 2020 Utkarsh Gupta <utkarsh@debian.org>
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the "Software"), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require "batalert"
4
+ Batalert::Runner.new.main
@@ -0,0 +1,29 @@
1
+ require_relative "batalert/version"
2
+ require "espeak"
3
+ require "libnotify"
4
+
5
+ module Batalert
6
+ class Runner
7
+ def main
8
+ capacity = File.open('/sys/class/power_supply/BAT0/capacity', &:readline)
9
+ capacity = capacity.to_i
10
+
11
+ status = File.open('/sys/class/power_supply/BAT0/status', &:readline)
12
+ status = status.chomp
13
+
14
+ if capacity < 10 && status == 'Discharging'
15
+ notify = Libnotify.new(summary: "PUT ON CHARGING, YOUR BATTERY IS AT #{capacity}%.", timeout: 3, urgency: :critical)
16
+ notify.update
17
+ speech = ESpeak::Speech.new("put on charging, your battery is at #{capacity}%.")
18
+ speech.speak
19
+ end
20
+
21
+ if capacity > 90 && status == 'Charging'
22
+ notify = Libnotify.new(summary: "REMOVE CHARGING, YOUR BATTERY IS AT #{capacity}%.", timeout: 3, urgency: :critical)
23
+ notify.update
24
+ speech = ESpeak::Speech.new("remove charging, your battery is at #{capacity}%.")
25
+ speech.speak
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Batalert
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: batalert
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Utkarsh Gupta
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: espeak-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: libnotify
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: "Battery notifications/alerts so your battery never dies! \U0001F4AF"
56
+ email:
57
+ - utkarsh@debian.org
58
+ executables:
59
+ - batalert
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - LICENSE
64
+ - exe/batalert
65
+ - lib/batalert.rb
66
+ - lib/batalert/version.rb
67
+ homepage: https://github.com/utkarsh2102/batalert
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.3.0
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.1.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Battery notifications/alerts
90
+ test_files: []