Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a few configuration scripts that I run everytime I install a fresh version of Ubuntu. Recently, however, I migrated to Xubuntu. I would like to use the same script for both distros, since both of them are very similar, but I would also like some parts of the script to be executed only under Xubuntu, and others only under Ubuntu.

My question is: is there a way to tell these distros apart via shell script?

I tried using the lsb-release application, but it seems to not be implemented under Xubuntu; I also tried to read the contents of /etc/*-release, but the contents seem to be similar in both distros.

$ lsb_release 
No LSB modules are available.
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.04
DISTRIB_CODENAME=vivid
DISTRIB_DESCRIPTION="Ubuntu 15.04"
share|improve this question
    
If it's not implemented under Xubuntu, perhaps that itself is all the check you need? –  Eric Renouf May 25 at 19:11
    
I just typed lsb_relase -a in Xubuntu and it displayed the contents of /etc/*-release, saying that Xubuntu is Ubuntu. –  Douglas De Rizzo Meneghetti May 25 at 19:16
    
You could probably check the running processes to find out if xfwm or some-unity-window-manager is running. Not sure this will get you 100% result, cause system may be multiuser with multiple WMs running on different Xorg's. –  Mikhail Krutov May 25 at 19:51
    
well one could probably ps aux | grep xfce , right ? –  Serg May 25 at 20:57
    
echo $XDG_CURRENT_DESKTOP –  Costas May 25 at 22:57

1 Answer 1

It's impossible to tell Xubuntu from Ubuntu, because they are the same distribution. Xubuntu and Ubuntu are two different installers which set up different desktop environments, but after the initial installation, the administrator can install additional desktop environments. Users can run XFCE after an initial Ubuntu installation or Unity after an initial XFCE installation.

If you wanted to set up some things differently depending on the desktop environment, this is a per-user setting, not a global setting. Since users can run different desktop environments at different times, you should prepare for both (and for KDE, and for twm, etc.).

share|improve this answer
    
One might want to look for the Freedesktop.org specifiations and see if there's something you could use (like start at startup). –  Braiam May 25 at 19:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.