hiiro 0.1.81 → 0.1.82

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.
data/bin/h-mic DELETED
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'hiiro'
4
-
5
- hiiro = Hiiro.init(*ARGV)
6
-
7
- SAVED_VOLUME_FILE = File.join(Dir.home, '.no-mic-saved-volume')
8
- DEFAULT_VOLUME = 75
9
-
10
- def get_input_volume
11
- `osascript -e 'input volume of (get volume settings)'`.strip.to_i
12
- end
13
-
14
- def set_input_volume(vol)
15
- system('osascript', '-e', "set volume input volume #{vol}")
16
- end
17
-
18
- def save_volume(vol)
19
- File.write(SAVED_VOLUME_FILE, vol.to_s) if vol > 0
20
- end
21
-
22
- def get_saved_volume
23
- if File.exist?(SAVED_VOLUME_FILE)
24
- File.read(SAVED_VOLUME_FILE).strip.to_i
25
- else
26
- DEFAULT_VOLUME
27
- end
28
- end
29
-
30
- hiiro.add_subcmd(:set) do |new_volume|
31
- old_volume = get_input_volume
32
- puts "Microphone muted (was at #{old_volume}%)"
33
-
34
- set_input_volume(new_volume)
35
-
36
- current_volume = get_input_volume
37
- puts "Microphone muted (set to #{current_volume}%)"
38
- end
39
-
40
- hiiro.add_subcmd(:mute) do
41
- current_volume = get_input_volume
42
-
43
- if current_volume == 0
44
- puts "Microphone is already muted"
45
- else
46
- save_volume(current_volume)
47
- set_input_volume(0)
48
- puts "Microphone muted (was at #{current_volume}%)"
49
- end
50
- end
51
-
52
- hiiro.add_subcmd(:unmute) do
53
- current_volume = get_input_volume
54
-
55
- if current_volume > 0
56
- puts "Microphone is already unmuted (currently at #{current_volume}%)"
57
- else
58
- restore_volume = get_saved_volume
59
- set_input_volume(restore_volume)
60
- puts "Microphone unmuted (restored to #{restore_volume}%)"
61
- end
62
- end
63
-
64
- hiiro.add_subcmd(:toggle) do
65
- current_volume = get_input_volume
66
-
67
- if current_volume == 0
68
- restore_volume = get_saved_volume
69
- set_input_volume(restore_volume)
70
- puts "Microphone unmuted (restored to #{restore_volume}%)"
71
- else
72
- save_volume(current_volume)
73
- set_input_volume(0)
74
- puts "Microphone muted (was at #{current_volume}%)"
75
- end
76
- end
77
-
78
- hiiro.add_subcmd(:status) do
79
- current_volume = get_input_volume
80
-
81
- if current_volume == 0
82
- puts "Microphone: MUTED"
83
- else
84
- puts "Microphone: ON (volume: #{current_volume}%)"
85
- end
86
- end
87
-
88
- hiiro.add_subcmd(:edit) do
89
- editor = ENV.fetch('EDITOR', 'nvim')
90
- system(editor, __FILE__)
91
- end
92
-
93
- hiiro.run
data/bin/h-note DELETED
@@ -1,119 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "hiiro"
4
- require "open3"
5
- require "pathname"
6
- require "tmpdir"
7
-
8
- hiiro = Hiiro.init(*ARGV)
9
-
10
- # Helper class for directory operations
11
- class Directory
12
- # Temporarily change to a directory, run block, then change back
13
- def self.temp_cd(dir, &block)
14
- original_dir = Dir.pwd
15
- Dir.chdir(dir)
16
- yield
17
- ensure
18
- Dir.chdir(original_dir)
19
- end
20
-
21
- # Print directory tree with indentation
22
- def self.dir_tree(dir, prefix = "", base_dir = nil)
23
- base_dir ||= dir
24
- entries = Dir.entries(dir).reject { |e| e.start_with?('.') }.sort
25
-
26
- entries.each do |entry|
27
- path = File.join(dir, entry)
28
- relative_path = Pathname.new(path).relative_path_from(base_dir)
29
-
30
- if File.directory?(path)
31
- puts "#{prefix}#{entry}/"
32
- dir_tree(path, prefix + " ", base_dir)
33
- else
34
- puts "#{prefix}#{relative_path}"
35
- end
36
- end
37
- end
38
- end
39
-
40
- notes_dir = ENV['NOTES_DIR'] || File.join(Dir.home, 'notes')
41
-
42
- hiiro.add_subcmd(:edit) { |*args|
43
- system(ENV['EDITOR'] || 'nvim', __FILE__)
44
- }
45
-
46
- hiiro.add_subcmd(:new) { |*args|
47
- unless Dir.exist?(notes_dir)
48
- Dir.mkdir(notes_dir)
49
- end
50
-
51
- Directory.temp_cd(notes_dir) {
52
- system(ENV['EDITOR'] || 'vim', '-O', *args)
53
- }
54
- }
55
-
56
- hiiro.add_subcmd(:categories) { |*args|
57
- unless Dir.exist?(notes_dir)
58
- Dir.mkdir(notes_dir)
59
- end
60
-
61
- Directory.temp_cd(notes_dir) {
62
- Directory.dir_tree(notes_dir)
63
- }
64
- }
65
-
66
- hiiro.add_subcmd(:tagged_files) { |*args|
67
- unless Dir.exist?(notes_dir)
68
- Dir.mkdir(notes_dir)
69
- end
70
-
71
- Directory.temp_cd(notes_dir) {
72
- args.each do |tag|
73
- tag = tag.sub(/^#+/, '')
74
- tag_pattern = format('#%s\\b', tag)
75
- cmd = format('rg -S %s %s', tag_pattern.inspect, notes_dir)
76
- out, err, status = Open3.capture3(cmd)
77
-
78
- if status.success?
79
- puts format('#%s', tag)
80
- puts format('#%s', tag).gsub(/./, ?-)
81
- out.lines.each do |line|
82
- file = line.sub(/:.*/, '')
83
- puts Pathname.new(file).relative_path_from(notes_dir)
84
- end
85
- end
86
-
87
- puts
88
- end
89
- }
90
- }
91
-
92
- hiiro.add_subcmd(:ls) { |*args|
93
- unless Dir.exist?(notes_dir)
94
- Dir.mkdir(notes_dir)
95
- end
96
-
97
- Directory.temp_cd(notes_dir) {
98
- Dir.glob('**/*').each(&method(:puts))
99
- }
100
- }
101
-
102
- hiiro.add_subcmd(:tags) { |*args|
103
- unless Dir.exist?(notes_dir)
104
- Dir.mkdir(notes_dir)
105
- end
106
-
107
- Directory.temp_cd(notes_dir) {
108
- tag_pattern = '#[^#[:space:]]+'
109
- cmd = format('rg -SI %s %s', tag_pattern.inspect, notes_dir)
110
- out, err, status = Open3.capture3(cmd)
111
-
112
- if status.success?
113
- puts out.scan(Regexp.new(tag_pattern)).sort.uniq
114
- end
115
- }
116
- }
117
-
118
- hiiro.run
119
-