scripts/screenshot.py

58 lines
1.5 KiB
Python
Raw Normal View History

#!/usr/bin/python
"""
screenshot.py to create screenshots using external tools. Designed for multiple displays.
-h help
-r [--rate] the rate in which frames are extracted (default: 10 fps)
"""
import getopt
import sys
import subprocess
from subprocess import call
import lib.helpers as helpers
from Xlib import X, display
from Xlib.ext import randr
__author__ = 'lanxu <jukka.lankinen@gmail.com>'
def main(argv):
scrot_available = helpers.is_exe("/usr/bin/scrot")
maim_available = helpers.is_exe("/usr/bin/maim")
try:
opts, args = getopt.getopt(argv,"h", [])
except getopt.GetoptError:
print('screenshot.py')
sys.exit(1)
try:
#command = ['scrot',]
#ps = subprocess.Popen(command_ffmpeg, stdout=subprocess.PIPE)
#val = call(command_convert, stdin=ps.stdout)
d = display.Display()
print(d.get_display_name())
for n in range(d.screen_count()):
s = d.screen(n)
print(str(n))
w = s.root.create_window(0, 0, 1, 1, 1, s.root_depth)
res = randr.get_screen_resources(w)
for m in res.modes:
print(m.id)
print(str(m.width) + 'x' + str(m.height))
for o in res.outputs:
output = screen.get_output_by_id(o)
print(output)
#print(res.outputs)
#print(res.crtcs)
#print(res)
except:
print("lol")
if __name__ == "__main__":
main(sys.argv[1:])