-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnds
executable file
·18 lines (14 loc) · 841 Bytes
/
snds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env fish
# snds - Get a list of programs using sound devices/libraries.
set -- script "$(path basename (status filename))"
argparse -n $script 'h/help' -- $argv
if set -q _flag_h
echo "$script - Get a list of programs using sound devices/libraries."
echo "Usage: $script [arguments]"
echo
echo " -h/--help - Print help and exit."
exit
end
# lsof's +c0 is supposed to cause the full command name to be printed, but linux limits it to only the first 16.
# -p "^PID" will exclude results from the process with the specified pid. this is necessary to avoid this script showing up in the results (since its name contains "snd").
lsof +c0 -p "^$fish_pid" 2>/dev/null | string match --entire --regex '^[^ ]+[ ]+.*snd.*' | string replace --regex '^(\S+)\s+.+\s+(\S+)$' '$1 $2' | sort | uniq | column -t -o ' '