Is it possible to find out the title of the active process using Python or Bash?

enter image description here

enter image description here

  • one
    the process is not required to have any window at all. What is the context of the task? What is the desktop environment? How is the "active process" set? - jfs
  • For example, for example, is the VLC player how to find out the name of the window, on the 1 photo that was published in the question? preferably without using the web version of VLC - KyKyIIIKuH
  • one
    Do you want to know which video vlc loses? vlc has an API. It is possible both from Python and bash http requests to perform wiki.videolan.org/VLC_HTTP_requests - jfs
  • one
    @jts, if I'm not mistaken, then VLC can MPRISv2, i.e. no downloads via the web are needed. - 0andriy

1 answer 1

Solved the problem in the following way. Thanks @ 0andriy for the tip.

import dbus bus = dbus.SessionBus() player = dbus.SessionBus().get_object('org.mpris.MediaPlayer2.vlc', '/org/mpris/MediaPlayer2') metadata = player.Get('org.mpris.MediaPlayer2.Player', 'Metadata', bus_interface='org.freedesktop.DBus.Properties') title_serial = str(metadata['xesam:url']).split("/") duration = str(metadata['vlc:length']) len_array = len(title_serial) print title_serial[len_array-1] print duration