Mostra apenas um painel Xfce4 enquanto o YouTube é lançado

0

Meu monitor do meio tem um painel com um relógio na parte inferior. Quando estou em tela cheia no YouTube, é claro que o painel com o relógio não é visto. Eu quero criar um script que faça o seguinte:

Eu quero lançar os dois comandos a seguir juntos. Inicie o YouTube e também configure meu painel lateral direito com um relógio para ser exibido.

chromium-browser http://www.youtube.com
xfconf-query -c xfce4-panel -p /panels/panel-4/autohide-behavior -s 0

Quando fecho a guia ou janela do YouTube, esse comando é executado. Esconde o painel com o relógio.

xfconf-query -c xfce4-panel -p /panels/panel-4/autohide-behavior -s 2

Qualquer ajuda é muito apreciada. Obrigado.

    
por jbrock 01.03.2016 / 01:58

1 resposta

0

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
    
por jbrock 20.03.2016 / 03:31