Debian Codegraph @

plyer/platforms/linux/screenshot.py

raw symbols SCIP
1 import subprocess
2 from os.path import join
3 from plyer.facades import Screenshot
4 from plyer.utils import whereis_exe
5 from plyer.platforms.linux.storagepath import LinuxStoragePath
6
7
8 class LinuxScreenshot(Screenshot):
9 def __init__(self, file_path=None):
10 default_path = join(
11 LinuxStoragePath().get_pictures_dir(),
12 'screenshot.xwd'
13 )
14 super().__init__(file_path or default_path)
15
16 def _capture(self):
17 # call xwd and redirect bytes from stdout to file
18 with open(self.file_path, 'wb') as fle:
19 subprocess.call([
20 # quiet, full screen root window
21 'xwd', '-silent', '-root',
22 ], stdout=fle)
23
24
25 def instance():
26 if whereis_exe('xwd'):
27 return LinuxScreenshot()
28 else:
29 return Screenshot()