3

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"
  • If it's not implemented under Xubuntu, perhaps that itself is all the check you need? – Eric Renouf May 25 '15 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 '15 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 '15 at 19:51
  • well one could probably ps aux | grep xfce , right ? – Sergiy Kolodyazhnyy May 25 '15 at 20:57
  • 1
    echo $XDG_CURRENT_DESKTOP – Costas May 25 '15 at 22:57
5

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.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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