To main page

Read Awesome's stdout and stderr with strace

December 01, 2017
Sometimes you may need to read the stdout and stderr of awesome process, e.g. when you're debugging Lua code. One way to do this is to create a new X instance with Xephyr and launch awesome inside, but there's another, hacky way: you can trace awesome syscalls with strace and parse out what you need.

Bash example:


pid=$(ps -ef | awk '$8=="awesome" {print $2}')

strace -e trace=write -s${max_str_length} -p${pid} 2>&1 \
    | grep --line-buffered --color=no "write([12], " \
    | sed -u 's/write([12], "\(.*\)", [0-9]\+) \+= [0-9]\+$/\1/g' \
    | sed -u 's/\\n/\n/g' \
    | sed -u 's/\\t/\t/g'

This was tested on Linux with strace 4.16.

mailto: me at ch1p dot com