Is it possible to know which recognized flavor I am running using terminal?
This is the command that I use. It works for me all the time:
cat /var/log/installer/media-info
Output (my system) Correctly tells that I am running Kubuntu
Kubuntu 14.04 LTS "Trusty Tahr" - Beta amd64 (20140326.2)
Maybe not a flavor like Kubuntu, Xubuntu, Lubuntu etc. Because as Oli & terdon comments you can install Kubuntu but running XFCE as Desktop.
So, you can get the value of the enviroment variable XDG_CURRENT_DESKTOP to know what the current desktop is running.
eg:
echo $XDG_CURRENT_DESKTOP
Note:
The values of the variable could be Unity,GNOME,XFCE,KDE,LXDE,Pantheon (Elementary os).
Hope this helps.
Set both. Set everything. Fire and forget.
The settings are exclusive enough not to affect other things so it should be safe... And it's a lot, lot easier to do than needing to work out what's being run... Working out what's installed is possible but that isn't an indication of what the user actually uses.