summaryrefslogtreecommitdiff
path: root/.local/bin/scripts/screenshot.py
blob: 752924b21bcbedff120bc88d6302473ce8a857e9 (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
#!/bin/python3
import sys
import re
import subprocess

def shoot(arg, dst):
    print(f"{tool_name} {arg} | {dst}")


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)