Controlling application frames (windows) in linux

Signage Player is a program created by MediaSignage which is available for free and allows the user to set up linux or windows pcs that display advertisement or other sorts of content in slideshows etc. The player launches after the pc does and starts displaying its campaign in fullscreen. If you use an older version of linux it will automatically remove the gnome-panel (the taskbar) if you selected that option during installation. If you did not select that option or are using a new linux version with a more recent gnome ui, the player will not remove the panel. If the panel is not removed the player will still launch in full screen but the panel will be visible. The player can be brought to the front by clicking the mouse once, but naturally in a real environment you want it to launch into proper fullscreen because nobody will be there to click anything. What's needed is a script solution that will automatically give focus to the player window (which is what happens when you click inside that window manually) so the player will be brought to the front and the gnome panel will become invisible.
1 answer

Focusing linux frame on x server in shell script

The SignagePlayer executable in my installation was located in /opt/SignagePlayer/bin/SignagePlayer

I replaced the actual executable with a script of mine which gets autostarted instead of the player.
I moved the actual executable of the player into a different file.
The script once started, starts the actual player (which is now called SignagePlayerApp) and then uses a linux program which is called "xdotool" that allows you to perform all kinds of different options on open windows using the shell.

the following retrieves the window id of the player window by its title, which is "Signage Player"

xdotool search --onlyvisible --name "Signage Player"

the id is stored in a variable, if the player was not yet launched (so the window did not exist when the "search" was run) the script waits 1 second and then tries again and again until it finally finds the window

then the following line is executed on the id of the window to give it focus and bring it in front of the gnome panel


xdotool windowactivate $windowId

the entire script can be found here:

#!/bin/bash
#This script belongs into the signage player install directory
#ie /opt/SignagePlayer/bin

#start the player
sudo /opt/SignagePlayer/bin/SignagePlayerApp &
#wait for the window to spawn
while : ; do
windowId=`xdotool search --onlyvisible --name "Signage Player"`
if [ -n "$windowId" ]
then
#once spawned give it focus and exit the script
xdotool windowactivate $windowId
break
else
#if it is not yet spawned wait 1 sec until checking again
sleep 1
fi
done