Command to determine whether a fullscreen application is running?

Kind of extreme overkill as a shell script, but it should do the trick:

#!/bin/bash
WINDOW=$(echo $(xwininfo -id $(xdotool getactivewindow) -stats | \
                egrep '(Width|Height):' | \
                awk '{print $NF}') | \
         sed -e 's/ /x/')
SCREEN=$(xdpyinfo | grep -m1 dimensions | awk '{print $2}')
if [ "$WINDOW" = "$SCREEN" ]; then
    exit 0
else
    exit 1
fi

Then you can check it:

if is-full-screen ; then echo yup, full screen ; fi

As pointed out below, you'll need to install xdotool first:

sudo apt-get install xdotool

I feel obligated to make a few comments (simplifications):

  1. The above shell code uses the anti-pattern ... | grep | awk. Whenever you see grep | awk, you can replace it with a single invocation of awk. I see this anti-pattern frequently in online help posts/forums. My sense is that most know this and that in real-world code, most people know better, but that, for some reason, it is viewed as pedagogically superior to write it this way (i.e., as grep | awk. But it still annoys me to see it.

  2. I think the above idea can be simplified to:

    # Initializations section of your shell script:
    root_geo="$(xwininfo -root | grep geometry)"
    
    # In the loop:
    [ "$(xwininfo -id $(xdotool getactivewindow) | grep geometry)" = "$root_geo" ] && echo "Running fullscreen"