0

I have developed an application time tracking app in python for linux, I am using xprop to get the active window, then it's PID , window name and process name. This app sends the tracking data to a remote server and so with all the dependencies i make a linux package using pyinstaller.

I'm currently working in CentOS 7. I have written a service which will keep the application open ( i made all the required changes for the service to run in user's desktop environment ).

while testing the service I saw that after a reboot with a fresh desktop, the service is running fine, but the data is not getting collected on the server. But as soon as i open a terminal everything works fine.

Is it necessary to have a terminal open for subprocess.check_output / subprocess.Popen() if the code is as follows :

active_win = subprocess.check_output(["xprop", "-root", "_NET_ACTIVE_WINDOW"]).decode('utf-8').split('#')[1].strip()

or

root = Popen( ['xprop', '-root', '_NET_ACTIVE_WINDOW'], stdout = PIPE )
stdout, stderr = root.communicate()
m = re.search( b'^_NET_ACTIVE_WINDOW.* ([\w]+)$', stdout )
if m is not None:
    window_id   = m.group( 1 )
Wasim Afser
  • 48
  • 10
  • ``subprocess`` is not dependent on a terminal. It appears this question is primarily about the behaviour of ``xprop``. – MisterMiyagi Sep 02 '20 at 13:39
  • Also see https://unix.stackexchange.com/questions/486178/what-is-the-meaning-of-ownership-of-a-process-on-a-window and https://stackoverflow.com/questions/151407/how-to-get-an-x11-window-from-a-process-id . –  Sep 02 '20 at 14:46
  • @Roadowl, what to see specifically ? the implementation ? cause my implementation seems to work fine with a terminal openend – Wasim Afser Sep 03 '20 at 15:51

0 Answers0