Verifique o seguinte código
import os
os.system('/usr/bin/xdg-open /home/dinom/Documents/testfolder')
import time
time.sleep(1)
window.activate("testfolder",switchDesktop=True)
import subprocess
active_title =window.get_active_title()
time.sleep(1)
if (active_title == "testfolder"):
start_time = time.time()
keyboard.wait_for_keypress("n", timeOut=1)
if (time.time()-start_time < 0.9):
time.sleep(0.2)
keyboard.press_key("<ctrl>")
keyboard.press_key("<shift>")
keyboard.press_key("n")
keyboard.release_key("n")
keyboard.release_key("<ctrl>")
keyboard.release_key("<shift>")
time.sleep(4)
keyboard.send_keys("sample")
keyboard.send_keys("<enter>")
else:
subprocess.Popen(['notify-send', "Couldn't find testfolder"])
Use o este link para referência