Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat exampleOf2Inputs
- 2 sink input(s) available.
- index: 144
- driver: <protocol-native.c>
- flags:
- state: RUNNING
- sink: 4 <alsa_output.pci-0000_05_00.0.analog-stereo>
- volume: front-left: 15728 / 24% / -37.19 dB, front-right: 15728 / 24% / -37.19 dB
- balance 0.00
- muted: no
- current latency: 70.48 ms
- requested latency: 210.00 ms
- sample spec: float32le 2ch 44100Hz
- channel map: front-left,front-right
- Stereo
- resample method: copy
- module: 13
- client: 245 <MPlayer>
- properties:
- media.name = "UNREAL! Tetris Theme on Violin and Guitar-TnDIRr9C83w.webm"
- application.name = "MPlayer"
- native-protocol.peer = "UNIX socket client"
- native-protocol.version = "32"
- application.process.id = "1543"
- application.process.user = "mmucha"
- application.process.host = "vbDesktop"
- application.process.binary = "mplayer"
- application.language = "C"
- window.x11.display = ":0"
- application.process.machine_id = "720184179caa46f0a3ce25156642f7a0"
- application.process.session_id = "2"
- module-stream-restore.id = "sink-input-by-application-name:MPlayer"
- index: 145
- driver: <protocol-native.c>
- flags:
- state: RUNNING
- sink: 4 <alsa_output.pci-0000_05_00.0.analog-stereo>
- volume: front-left: 24903 / 38% / -25.21 dB, front-right: 24903 / 38% / -25.21 dB
- balance 0.00
- muted: no
- current latency: 70.50 ms
- requested latency: 210.00 ms
- sample spec: float32le 2ch 48000Hz
- channel map: front-left,front-right
- Stereo
- resample method: speex-float-1
- module: 13
- client: 251 <MPlayer>
- properties:
- media.name = "Trombone Shorty At Age 13 - 2nd Line-k9YUi3UhEPQ.webm"
- application.name = "MPlayer"
- native-protocol.peer = "UNIX socket client"
- native-protocol.version = "32"
- application.process.id = "2831"
- application.process.user = "mmucha"
- application.process.host = "vbDesktop"
- application.process.binary = "mplayer"
- application.language = "C"
- window.x11.display = ":0"
- application.process.machine_id = "720184179caa46f0a3ce25156642f7a0"
- application.process.session_id = "2"
- module-stream-restore.id = "sink-input-by-application-name:MPlayer"
- cat exampleOf2Inputs | awk '
- BEGIN { print "[" }
- function print_record() {
- if (count++) {
- print " {"
- printf " %s,\n", print_number("pid")
- printf " %s,\n", print_number("index")
- printf " %s,\n", print_string("appname")
- printf " %s\n", print_string("medianame")
- print " },"
- }
- delete record
- }
- function print_number(key) { return sprintf("\"%s\": %d", key, record[key]) }
- function print_string(key) { return sprintf("\"%s\": \"%s\"", key, record[key]) }
- function get_quoted_value() {
- if (match($0, /[^"]+"$/)) {
- return substr($0, RSTART, RLENGTH-1)
- else
- return "?"
- }
- $1 == "index:" { print_record(); record["index"] = $2 }
- $1 == "application.process.id" { record["pid"] = get_quoted_value() }
- $1 == "application.name" { record["appname"] = get_quoted_value() }
- $1 == "media.name" { record["medianame"] = get_quoted_value() }
- END { print_record(); print "]" }
- ' | tac | awk '/},$/ && !seen++ {sub(/,$/,"")} 1' | tac
- awk: cmd. line:19: else
- awk: cmd. line:19: ^ syntax error
- awk: cmd. line:22: $1 == "index:" { print_record(); record["index"] = $2 }
- awk: cmd. line:22: ^ syntax error
- awk: cmd. line:23: $1 == "application.process.id" { record["pid"] = get_quoted_value() }
- awk: cmd. line:23: ^ syntax error
- awk: cmd. line:24: $1 == "application.name" { record["appname"] = get_quoted_value() }
- awk: cmd. line:24: ^ syntax error
- awk: cmd. line:25: $1 == "media.name" { record["medianame"] = get_quoted_value() }
- awk: cmd. line:25: ^ syntax error
- awk: cmd. line:26: END { print_record(); print "]" }
- awk: cmd. line:26: ^ syntax error
- awk: cmd. line:26: END { print_record(); print "]" }
- awk: cmd. line:26: ^ unexpected newline or end of string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement