Compare commits

..
11 Commits
4 changed files with 95 additions and 26 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ import getopt
from subprocess import * from subprocess import *
def main(argv): def main(argv):
bitrate = 128 bitrate = 256
try: try:
opts, args = getopt.getopt(argv[1:], "b:") opts, args = getopt.getopt(argv[1:], "b:")
except getopt.GetoptError: except getopt.GetoptError:
+14 -25
View File
@@ -32,36 +32,25 @@ def run_dir
ENV["XDG_RUNTIME_DIR"] || "/tmp" ENV["XDG_RUNTIME_DIR"] || "/tmp"
end end
def launch(socket_path, pretty_name, path)
if File.exist?(socket_path)
# Server running, send it remote command
system("nvim", "--headless", "--server", socket_path, "--remote-tab-silent", path)
else
# Start the server
$started_server = true
system(EDITOR, path, "--", "--listen", socket_path)
end
end
if ARGV.empty? if ARGV.empty?
exec(EDITOR) exec(EDITOR)
else else
ARGV.each_with_index do |path, i| socket_name, pretty_name = find_proj_root(ARGV[0])
socket_name, pretty_name = find_proj_root(path) if socket_name
socket_path = "#{run_dir}/e-#{socket_name}.sock" socket_path = "#{run_dir}/e-#{socket_name}.sock"
if i == 1 if File.exist?(socket_path)
20.times do opencmds = ARGV.map do |path|
sleep(0.01) path = File.expand_path(path).gsub(" ", "\\ ")
break if File.exist?(socket_path) %[:tab drop #{path}<CR>]
end end.join
end exec("nvim", "--headless", "--server", socket_path, "--remote-send", "<Esc>#{opencmds}:call GuiForeground()<CR><C-l>")
launch(socket_path, pretty_name, path) else
if i == ARGV.length - 1 paths = ARGV.map do |path|
# This is the last argument. If the server was not started for any paths, File.expand_path(path)
# then request that the window take focus.
unless $server_started
system("nvim", "--headless", "--server", socket_path, "--remote-send", "<Esc>:call GuiForeground()<CR><C-l>")
end end
exec(EDITOR, "--", "--listen", socket_path, "--cmd", "let g:project_name = '#{pretty_name}'", "-p", *paths)
end end
else
exec(EDITOR, "--", "-p", *ARGV)
end end
end end
Executable
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env ruby
# Install: kid3-common
require "fileutils"
$stdout.sync = true
files = Dir.glob("*.mp3").sort
if files.empty?
$stderr.puts "No .mp3 files found"
exit 1
end
unless File.exist?("albumart.jpg")
$stderr.puts "albumart.jpg not found"
exit 1
end
unless File.exist?("info.txt")
$stderr.puts "info.txt not found"
exit 1
end
info = File.read("info.txt")
info =~ /^artist: (.*)$/
artist = $1
info =~ /^album: (.*)$/
album = $1
info =~ /^year: (.*)$/
date = $1
unless artist && album && date
$stderr.puts "invalid info.txt format"
exit 1
end
#$stdout.write("Release date (YYYY-MM-DD): ")
#date = gets.chomp
#unless date =~ /^\d{4}-\d{2}-\d{2}$/
# $stderr.puts "Unexpected date format"
# exit 1
#end
files.each do |file|
if file =~ /^(\d+)\s*(.*)\.mp3$/
track_number, title = $1.to_i, $2
command = %w[kid3-cli]
command += ["-c", "revert", "-c", "save"]
command += ["-c", %[set artist "#{artist}" 12]]
command += ["-c", %[set title "#{title}" 12]]
command += ["-c", %[set album "#{album}" 12]]
command += ["-c", %[set date "#{date}" 12]]
command += ["-c", %[set track "#{track_number}" 12]]
command += ["-c", %[set picture:albumart.jpg 'Front Cover' 2]]
command += ["-c", "save"]
command << file
system(*command)
else
$stderr.puts "Warning: skipping #{file}, unrecognized name format"
end
end
Executable
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env ruby
if ARGV.empty?
files = Dir["*.wav"].sort
else
files = ARGV
end
files.each do |infile|
outfile = infile.sub(".wav", ".mp3")
puts "Converting: #{infile} -> #{outfile}"
command = %W[lame -v -b 256 #{infile} #{outfile}]
system(*command)
end
puts "Conversion complete!"