dtas.git  about / heads / tags
duct tape audio suite for *nix
blob bf9702084433e536a216948fa2ffec9987e5e517 1037 bytes (raw)
$ git show v0.1.I:bin/dtas-sinkedit	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
#!/usr/bin/env ruby
# -*- encoding: binary -*-
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net>
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require 'dtas/edit_client'
include DTAS::EditClient
c = client_socket
sinks = c.req('sink ls') || "(unknown)"
usage = "Usage: #{DTAS_PROGNAME} SINKNAME\n" \
        "available SINKNAME values: #{sinks}"
ARGV.size == 1 or abort usage
name = ARGV[0]

tmp = tmpyaml
buf = c.req(%W(sink cat #{name}))
abort(buf) if buf =~ /\AERR/
orig = YAML.load(buf)

tmp.write(buf << DTAS_DISCLAIMER)
cmd = "#{editor} #{tmp.path}"
system(cmd) or abort "#{cmd} failed: #$?"
tmp.rewind
sink = YAML.load(tmp.read)

cmd = %W(sink ed #{name})
update_cmd_env(cmd, orig, sink)

# both of these default to false
%w(nonblock active).each do |field|
  cmd << "#{field}=#{sink[field] ? 'true' : 'false'}"
end

%w(prio pipe_size).each do |field|
  value = sink[field] and cmd << "#{field}=#{value}"
end

# nil OK
%w(command).each do |field|
  cmd << "#{field}=#{sink[field]}"
end

c.req_ok(cmd)

git clone git://80x24.org/dtas.git
git clone https://80x24.org/dtas.git