-
Notifications
You must be signed in to change notification settings - Fork 2
/
screen-eat
executable file
·100 lines (80 loc) · 2.64 KB
/
screen-eat
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /bin/python3
import argparse
import os
import platform
import signal
import tempfile
import gi
gi.require_version('Gtk', '3.0') # NOQA -- disable pep8 E402 warning
gi.require_version('Gdk', '3.0') # NOQA -- disable pep8 E402 warning
from gi.repository import Gdk, GObject
from screen_eat.config import Config
from screen_eat.windows.main_window import MainWindow
def parse():
HOME = os.path.expanduser("~")
config_path = os.path.join(HOME, '.screen-eat.conf')
parser = argparse.ArgumentParser(
"screen-eat",
description="screenshot made delicious "
)
optype = parser.add_mutually_exclusive_group()
optype.add_argument('-a',
'--active',
dest='eat_active_screen',
help='Screenshot active region',
action='store_const',
const=True)
optype.add_argument('-c',
'--cropped',
dest='eat_cropped_screen',
help='Screenshot cropped region',
action='store_const',
const=True)
parser.add_argument('-C',
'--config',
dest='config_path',
help='Path to configuration file',
metavar='configuration file',
type=str,
default=config_path,
required=False)
return parser.parse_args()
def main():
args = parse()
# Register OS signals
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Initialize threads for Gdk
GObject.threads_init()
if platform.system() == 'Linux':
Gdk.threads_init()
# Load configurations
privateauth_filename = os.path.join(args.config_path, "privateauth.json")
publicauth_filename = os.path.join(args.config_path, "publicauth.json")
config_filename = os.path.join(args.config_path, "config.json")
# Load all configuration files
privateauth_config = Config(privateauth_filename)
publicauth_config = Config(
publicauth_filename,
{"client_id": "9695b8de1e85072"}
)
screen_eat_config = Config(
config_filename,
{
"authmode": 0,
"autoupload": False,
"autocopy": True,
"quality": "98"
}
)
temp_dir = tempfile.gettempdir()
main = MainWindow(
args.eat_active_screen,
args.eat_cropped_screen,
temp_dir,
screen_eat_config,
privateauth_config,
publicauth_config,
)
main.load()
if __name__ == "__main__":
main()