Skip to content

Commit bb899ed

Browse files
committed
Linux: better handling of the display keyword
1 parent d88fd94 commit bb899ed

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

docs/source/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Into the Python's console
7777
.. code:: python
7878
7979
>>> from mss import mss
80-
>>> sct = mss(display=b':0')
80+
>>> sct = mss(display=':0')
8181
8282
# Retrieve monitors informations
8383
>>> displays = sct.enum_display_monitors()

mss/linux.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def __init__(self, display=None):
114114
except KeyError:
115115
err = '$DISPLAY not set. Stopping to prevent segfault.'
116116
raise ScreenshotError(err)
117+
elif not isinstance(display, bytes):
118+
display = bytes(display, 'utf-8')
117119

118120
x11 = find_library('X11')
119121
if not x11:

test-linux.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def main():
1212
''' Usage example with specified display. '''
1313

14-
display = b':0.0'
14+
display = ':0.0'
1515
try:
1616
with MSS(display=display) as screenshotter:
1717
print('Screenshot of display "{0}"'.format(display))

0 commit comments

Comments
 (0)