hiiro 0.1.76 → 0.1.78
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/h +1 -1
- data/lib/hiiro/notification.rb +30 -5
- data/lib/hiiro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b02d82eafaf2fdc5a89635f5e9e33d35edd22254d19c23cae2544a5c8f746803
|
|
4
|
+
data.tar.gz: fb0c92ba92136c89f9bcc83963b517f6ad51880da1787dc5f1d1174d1962589a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 936baa6258b7a76df4cb0730cb154f849382df80a9cf8e75a4c93e99719fe924d96df94aefd717c09902b4d1b4acf2fcfb249e50a6d0c45e53e594f3864e9fcb
|
|
7
|
+
data.tar.gz: 3d7b2e749a478b514d5c75bf22c448f60a58ad513afbbe6bdde7b2eb1454a2b7d50566ad72b38381f4fa5a7f281e7020a7e89339e85267b6cf3416710568e7c9
|
data/exe/h
CHANGED
data/lib/hiiro/notification.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Hiiro
|
|
2
2
|
class Notification
|
|
3
|
-
def self.
|
|
3
|
+
def self.show(hiiro)
|
|
4
4
|
new(hiiro).send
|
|
5
5
|
end
|
|
6
6
|
|
|
@@ -11,18 +11,43 @@ class Hiiro
|
|
|
11
11
|
@original_args = hiiro.args.dup
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def options
|
|
15
|
+
@options ||= Options.parse(args) do
|
|
16
|
+
option(:sound, short: :s, default: 'basso', desc: 'sound name')
|
|
17
|
+
option(:title, short: :t, desc: 'title')
|
|
18
|
+
option(:message, short: :m, desc: 'message')
|
|
19
|
+
option(:link, short: :l, desc: 'link to open')
|
|
20
|
+
option(:command, short: :c, desc: 'command to run')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
14
24
|
def args
|
|
15
25
|
@args ||= hiiro.args
|
|
16
26
|
end
|
|
17
27
|
|
|
18
28
|
def sounds
|
|
19
|
-
system = Dir.glob('/System/Library/Sounds/*')
|
|
20
29
|
custom = Dir.glob(File.join(Dir.home, '.config/hiiro/sounds/*'))
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
all_sounds.each_with_object({}) do |fn, h|
|
|
31
|
+
@sounds ||= custom.each_with_object({}) do |fn, h|
|
|
24
32
|
basename = File.basename(fn, File.extname(fn))
|
|
25
|
-
|
|
33
|
+
h[basename.downcase] = fn
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def show
|
|
38
|
+
cmd = ['terminal-notifier']
|
|
39
|
+
cmd << ['-message', options.message] if options.message
|
|
40
|
+
cmd << ['-title', options.title.tr('()[]', '')] if options.title
|
|
41
|
+
cmd << ['-open', options.link] if options.link
|
|
42
|
+
cmd << ['-execute', options.command] if options.command
|
|
43
|
+
system(*cmd)
|
|
44
|
+
|
|
45
|
+
play_sound
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def play_sound
|
|
49
|
+
if options.sound && sounds[options.sound]
|
|
50
|
+
system('afplay', sounds[options.sound.downcase])
|
|
26
51
|
end
|
|
27
52
|
end
|
|
28
53
|
end
|
data/lib/hiiro/version.rb
CHANGED