background
When asking for help with a software problem, it is usually good to identify not only what versions of that particular code one is running, but also characterize the application's platform. Querying hardware from CLI can be annoying, but fortunately hardware is often not part of one's etiology or is standard enough to be irrelevant. Querying the foundations of a Linux host via CLI is relatively straightforward (at least since LSB), so one can script general-purpose bash like this:
#!/usr/bin/env bash
### Attempt to create a high-level commandline-query for
### basic host configuration information (at least, for that
### part of the platform just above the hardware.
# constants------------------------------------------------------------
### "Marker file" paths for specific distros. TODO: complete the set.
DEBIAN_FILE='/etc/debian_version'
# code-----------------------------------------------------------------
### Absolute basics: kernel, distro
for CMD in \
'date' \
'uname -rsv' \
'lsb_release -ds' \
; do
echo -e "\$ ${CMD}"
eval "${CMD}"
done
### Distro details via marker file. TODO: extend to all major distros.
### Feel free to add stanzas for your distro's marker.
if [[ -r "${DEBIAN_FILE}" ]] ; then
for CMD in \
"cat ${DEBIAN_FILE}" \
; do
echo -e "\$ ${CMD}"
eval "${CMD}"
done
fi
### Other important non-graphical libraries, toolkits, etc.
for CMD in \
'gcc --version | head -n 1' \
; do
echo -e "\$ ${CMD}"
eval "${CMD}"
done
This produces output like
$ date
Sat Sep 17 14:18:28 MST 2016
$ uname -rsv
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02)
$ lsb_release -ds
LMDE 2 Betsy
$ cat /etc/debian_version
8.5
$ gcc --version | head -n 1
gcc (Debian 4.9.2-10) 4.9.2
question
What I don't know is, how to similarly script queries for important information about one's desktop stack? I know I'm running X, so can do
## Dunno why X:
## * throws error on `--version`
## * outputs version info to `stderr`
## * wants to include hostname in 'Current Operating System:' line
$ Xorg -version 2>&1 | grep -ve '^$\|^[[:space:]]\|Current Operating System:'
X.Org X Server 1.16.4
Release Date: 2014-12-20
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.16.0-4-amd64 x86_64 Debian
Kernel command line: BOOT_IMAGE=/vmlinuz-3.16.0-4-amd64 root=/dev/mapper/LVM2_crypt-root ro nomodeset nouveau.modeset=0
Build Date: 11 February 2015 12:32:02AM
xorg-server 2:1.16.4-1 (http://www.debian.org/support)
Current version of pixman: 0.32.6
$ x-window-manager --version | head -1
metacity 3.14.3
and I (just happen to) know I'm using the Cinnamon desktop and so can do
$ cinnamon --version
Cinnamon 3.0.6
but I have no idea about how to CLI-query for versions of things like GTK (which I know Cinnamon uses), or how to do similar high-level queries in "Qt world," or what to do for Wayland, or about what other parts of the WM/DE/GUI stack are generally important for problem descriptions. What commands can I use to get this information?