O script a seguir funciona perfeitamente. :)
#!/bin/bash
# Check to see if Chromium is already running.
# If it is not already running then it sleeps longer before recording the PID.
chrom_status=$(ps -e | grep chromium)
# Launch YouTube in Chromium
chromium-browser http://www.youtube.com &
# Display Xfce panel with clock
xfconf-query -c xfce4-panel -p /panels/panel-5/autohide-behavior -s 0
# Sleeping is essential here; otherwise the correct PID is not recorded.
# If you run the script and then immediately start opening up other Chromium windows and tabs, then the script will break.
if [ -z "$chrom_status" ]; then
sleep 20
else
sleep 5
fi
# Add YouTube PID to variable
ypid=$(ps -e | awk '/chromium/ { print $1 }' | tail -n1)
# Check every two seconds to make sure YouTube is still open
while true; do
# Without sleep CPU usage is really high.
sleep 2
ypid_status=$(ps -e | grep "$ypid")
if [ -z "$ypid_status" ]; then
xfconf-query -c xfce4-panel -p /panels/panel-5/autohide-behavior -s 2
exit 0
fi
done