Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- import subprocess
- from PIL import Image, ImageDraw, ImageFont
- def getscreenresolution():
- cmd = ['xrandr']
- cmd2 = ['grep', '*']
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- p2 = subprocess.Popen(cmd2, stdin=p.stdout, stdout=subprocess.PIPE)
- p.stdout.close()
- resolution_string, junk = p2.communicate()
- resolution = resolution_string.split()[0]
- width, height = resolution.split('x')
- return int(width), int(height)
- def drawscreenbackround(width, height, text):
- img = Image.new("RGB", (width, height), "black")
- fnt = ImageFont.truetype('LiberationSans-Bold.ttf', 47)
- d = ImageDraw.Draw(img)
- d.text((width / 2, height / 2), text, font=fnt, fill=(255, 255, 0))
- img.save('image.png') # Path?
- if __name__ == "__main__":
- myhost = os.uname()[1]
- res = getscreenresolution()
- drawscreenbackround(res[0], res[1], myhost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement