1#!/usr/bin/env python3

2

3 import gi

4 import sys

5

6 from argparse import ArgumentParser

7

8 gi.require_version("Gdk", "3.0")

9 from gi.repository import Gdk # noqa: E402

10

11

12 def check_resolution():

13 screen = Gdk.Screen.get_default()

14 n = screen.get_n_monitors()

15 for i in range(n):

16 geom = screen.get_monitor_geometry(i)

17 print("Monitor %d:" % (i + 1))

18 print(" %d x %d" % (geom.width, geom.height))

19

20

21 def compare_resolution(min_h, min_v):

22 # Evaluate just the primary display

23 screen = Gdk.Screen.get_default()

24 geom = screen.get_monitor_geometry(screen.get_primary_monitor())

25 print("Minimum acceptable display resolution: %d x %d" % (min_h, min_v))

26 print("Detected display resolution: %d x %d" % (geom.width, geom.height))

27 return geom.width >= min_h and geom.height >= min_v

28

29

30 def main():

31 parser = ArgumentParser()

32 parser.add_argument(

33 "--horizontal",

34 type=int,

35 default=0,

36 help="Minimum acceptable horizontal resolution.",

37 )

38 parser.add_argument(

39 "--vertical",

40 type=int,

41 default=0,

42 help="Minimum acceptable vertical resolution.",

43 )

44 args = parser.parse_args()

45

46 if (args.horizontal > 0) and (args.vertical > 0):

47 return not compare_resolution(args.horizontal, args.vertical)

48 else:

49 check_resolution()

50

51 return 0

52

53

54 if __name__ == "__main__":

55 sys.exit(main())