Follow up for #1950: some applications will set WM_COMMAND
, for others we have to parse /proc/$PID/cmdline
, then we can lookup the desktop file whose Exec
attribute matches the command.
The desktop file contains a list of Categories
which we can use to guess the content-type.
ie: this doesn't work well for google-chrome on Fedora:
$ xprop | grep PID _NET_WM_PID(CARDINAL) = 3656
$ cat /proc/3656/cmdline /opt/google/chrome-unstable/chrome
$ grep -r Exec= /usr/share/applications/google-chrome-unstable.desktop Exec=/usr/bin/google-chrome-unstable %U Exec=/usr/bin/google-chrome-unstable Exec=/usr/bin/google-chrome-unstable --incognito
/usr/bin/google-chrome-unstable
is a script that runs the actual /opt/google/chrome-unstable/chrome
.
So this would need fuzzy matching, or just continue with the existing heuristics from #1950.
For reference, the list of categories is pretty long, and some applications have two or more...
$ grep Categories /usr/share/applications/*desktop |awk -F Categories= '{print $2}' | xargs -n 1 -d ";" | grep -v "^X-" | sort -u 2DGraphics 3DGraphics Accessibility Application Applications Archiving Audio AudioVideo AudioVideoEditing Calculator Calendar Clock Compression ConsoleOnly ContactManagement Core Debugger DesktopSettings Development DiscBurning Documentation Education Electronics Email Emulator Engineering FileManager Filesystem FileTools FileTransfer Game GNOME Graphics GTK HardwareSettings IDE InstantMessaging Java KDE LogicGame Math Mixer Monitor Network Office P2P PackageManager ParallelComputing Player Printing Profiling Qt RasterGraphics Recorder RemoteAccess Scanning Science Security Settings Spreadsheet System TerminalEmulator TextEditor TrayIcon Utility Video Viewer WebBrowser WordProcessor
Done in r20700.
Still TODO:
this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1956