Raka
Raka

Reputation: 31

Is it possible to export a screenshot of a GRC flowgraph in commandline?

What is my problem?

Is it possible to export a screenshot of a gnuradio-companion flowgraph in commandline? The command grcc provides the ability to compile .grc flowgraph files into python files. But it doesn't provide the funtionality to export the graph as a screenshot, which is possible when you use the gnuradio-companion GUI (Using Ctrl-P).

What do I need this for?

I'm currently working with a bunch of .grc flowgraphs and I'm storing them in gitlab. I'd like to set up a pipeline of some sort, that generates a screenshot of those grc files so the people I am collaborating with can view the gnuradio flowgraph without needing to install gnuradio. So for this, I need to have some ability to generate screenshots from the commandline with a script of some sort.

Looking into the gnuradio source code this is the only reference to screen capture I find, and even if I find code that would generate the screen capture, I wouldn't know how use that to create an independent script that just generates a screen shot.

Upvotes: 1

Views: 179

Answers (1)

Raka
Raka

Reputation: 31

Ok, so a solution that kinda works for me now is using a virtual X server (with Xvfb) and manually executing the export functionality. The script looks like this:

#!/bin/bash

if [ -z "$1" ];
then
    echo "Usage: $1 [flowgraph .grc file]"
    echo "This script outputs an output.png file"
    exit 1
fi

DISPLAY=:2

echo "Starting Xvfb instance on display $DISPLAY"
Xvfb $DISPLAY &
echo "Starting GRC..."
gnuradio-companion $1 2>&1 1>/dev/null &
sleep 2
xdotool key ctrl+p
xdotool key ctrl+a
xdotool key BackSpace
xdotool type output.png
xdotool key Return
echo "Saving Screenshot..."
sleep 2
echo "Killing GRC..."
killall gnuradio-companion
echo "Killing Xvfb..."
killall Xvfb

The output of the script is called output.png and will be placed in the current directory. This is quite a hacky solution but nothing better currently comes to mind.

Upvotes: 2

Related Questions