User Tools

Site Tools


check_if_x_windows_is_running

If you want to send us your comments, please do so. Thanks
More on comments


Check if X windows is running

Check if $HOME/.xsession-errors exists. When you are logined in graphically, stderr is redirected there. This log file starts with

Xsession: X session started for user at Sat may 9 08:43:07 UTC 2015\\

So it always exists when X is started. Run

[[ -f $HOME/.xsession-errors1 ]] && echo running || echo "not running"

to check if the file exists

Other solutions

xset q &>/dev/null
echo $?

If the output of the echo command is 0 X windows is running

pidof X &> /dev/null
echo $?

If the output of the echo command is 0 X windows is running
Use the w command and check for the xfce4-terminal

[[ `w | grep xfce4-terminal` ]] && echo "X is running"
[ -z "$PS1" ] && echo "X windows is not running" || echo "X windows is running"
if [ -t 0 ]; then "X windows is not running"; fi

-t fd True if file descriptor fd is open and refers to a terminal.

[[ -f /run/lightdm/${USER}/xauthority ]] && continue

echo $DISPLAY

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
check_if_x_windows_is_running.txt · Last modified: 23-05-2016 01:36 by wim