I have a program that monitors for new screenshots but however, I had to change the default screenshot directory to /screenshots instead of the in com.apple.screencapture

How can I obtain the directory set within com.apple.screencapture from within Python so that the program can run on any MacOS computer without having to manually change the screenshot directory location first.

Example code (currently after changing dir):

path = os.path.join(os.path.curdir, 'screenshots')
observer = Observer()
event_handler = ScreenshotEventHandler()
# Create a watchdog to watch <current_dir>/screenshots directory
observer.schedule(event_handler, path)
  • The answer is pipe = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) path = pipe.stdout.read().rstrip() – Chinmay Apr 4 '18 at 23:10

You must log in to answer this question.

Browse other questions tagged .