blob: 3b880d63f76d9f237a26c78318e8973256c8573a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/python3
import sys
import re
import subprocess
from subprocess import check_output as cout
def shoot(arg, dst):
print(f"{tool_name} {arg} | {dst}")
# def get_path():
# with open("~/.cache/")
# p = cout(["dmenu"], input="".encode()).decode().strip()
tool_name = "maim"
default_tool = "area"
default_dest = "clip"
file_path = "~/pictures"
file_name = "screenshot_$(date +%Y-%m-%d_%H-%M-%S).png"
tool = {
"area": "-u -s -m 1",
"window": "-B -u -i $(xdotool getactivewindow)",
"screen": "-u",
}
dest = {
"file": f"tee {file_path}/{file_name}",
"clip": "xclip -selection clipboard -t image/png",
}
args = sys.argv[1:]
if len(args) == 0:
shoot(tool[default_tool], dest[default_dest])
elif len(args) == 1:
if args[0] in tool:
shoot(tool[args[0]], dest[default_dest])
else:
print("Wrong arguments")
quit(1)
elif len(args) == 2:
if args[0] == "to" and args[1] in dest:
shoot(tool[default_tool], dest[args[1]])
else:
print("Wrong arguments")
quit(1)
elif len(args) == 3:
if args[1] == "to" and args[0] in tool and args[2] in dest:
shoot(tool[args[0]], dest[args[2]])
else:
print("Wrong arguments")
quit(1)
|