-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrecall.py
73 lines (57 loc) · 1.84 KB
/
librecall.py
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
import sys
if __name__ != "__main__":
print("no. why")
sys.exit(1)
if "--wayland-tools" in sys.argv:
print("""
List of screenshotting tools on wayland supported by librecall:
- flameshot
- grim
- spectacle
- scrot
- gnome-screenshot
- grimblast
You can download any of these with your package manager, and
make sure it actually works under your compositor.
gnome-screenshot does a shutter sound effect each screenshot.
This is preventable, but would require root access. Maybe in
the future, ok?
""")
sys.exit(0)
from SystemInfo import SystemInfo
import os
import shutil
sysInfo = SystemInfo()
if not os.path.exists(sysInfo.dataDir):
os.makedirs(sysInfo.dataDir)
import firstTimeDialogue
import screenshotProcess
import window
legacyPaths: list[str] = [
os.path.join(sysInfo.fileLocation, ".last.librerecall"),
os.path.join(sysInfo.fileLocation, ".firsttime.lck"),
os.path.join(sysInfo.fileLocation, "settings.json"),
os.path.join(sysInfo.fileLocation, "images.db")
]
for path in legacyPaths:
if os.path.exists(path):
ind = path.rindex("/")
file = path[ind+1:]
newPath = os.path.join(sysInfo.dataDir, file)
if sysInfo.info:
print(f"Moving old file to data directory\t{file} -> data/{file}")
shutil.move(path, newPath)
openCfg = "-c" in sys.argv or "--config" in sys.argv
firstTimeLockFile = f"{sysInfo.dataDir}/.firsttime.lck"
firstTime = not os.path.exists(firstTimeLockFile)
if firstTime and not "-s" in sys.argv:
firstTimeResponse = firstTimeDialogue.doUI()
if firstTimeResponse == "quit":
sys.exit(0)
with open(firstTimeLockFile, "w"):
pass
openCfg = True
if openCfg:
window.createSettingsWindow()
else:
screenshotProcess.doWork()