17 lines
513 B
Text
17 lines
513 B
Text
|
#!/usr/bin/env python3
|
||
|
import subprocess, datetime, os
|
||
|
|
||
|
d = os.path.expanduser("~/files/pics/screenies")
|
||
|
os.makedirs(d, exist_ok=True)
|
||
|
f = f"screenshot_{datetime.datetime.now():%Y-%m-%d_%H-%M-%S}.png"
|
||
|
p = os.path.join(d, f)
|
||
|
|
||
|
r = subprocess.run(["slurp"], capture_output=True, text=True)
|
||
|
if r.returncode: exit(1)
|
||
|
|
||
|
subprocess.run(["grim", "-g", r.stdout.strip(), p])
|
||
|
with open(p, "rb") as image_file:
|
||
|
subprocess.run(["wl-copy"], stdin=image_file)
|
||
|
subprocess.run(["notify-send", "Screenshot saved", p])
|
||
|
print(p)
|