from time import time from pathlib import Path from subprocess import run, PIPE from . import qtile_func @qtile_func def screenshot(save: bool=True, copy: bool=True) -> None: shot = run(['maim'], stdout=PIPE) if save: path = Path.home() / 'Pictures' path /= f'screenshot_{str(int(time() * 100))}.png' with open(path, 'wb') as sc: sc.write(shot.stdout) if copy: run('xclip -sel clip -t image/png'.split(), input=shot.stdout)