-
Notifications
You must be signed in to change notification settings - Fork 5
/
VDockLite
executable file
·171 lines (136 loc) · 4.05 KB
/
VDockLite
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/python3
import sys
import time
import random
import subprocess
from os.path import exists
from NekoMimi import utils as nm
from NekoMimi import colourimi
__author__ = "NekoMimiOfficial"
__email__ = "nekomimi@tilde,team"
__version__ = "1.0.0"
class Pallet:
text = "#DDDDDD"
text2 = "#888888"
mochaBG = "#1E1E2E"
mochaFG = "#CDD6F4"
catBlue = "#799DDB"
catRed = "#F38BA8"
catCyan = "#89DCEB"
catPink = "#F5C2E7"
catYellow = "#F9E2AF"
catOrange = "#F3B993"
catGreen = "#A2DCAA"
catPurr = "#C6A1F0"
@staticmethod
def random():
slots = [
Pallet.text,
Pallet.text2,
Pallet.mochaFG,
Pallet.catYellow,
Pallet.catOrange,
Pallet.catBlue,
Pallet.catPurr,
Pallet.catRed,
Pallet.catCyan,
Pallet.catPink,
Pallet.catGreen,
]
return random.choice(slots)
__disclaimer__ = """
^ ^ VitaDockLite vXXXXX supports the PS Vita
=UwU= This app is provided with [ZERO] warranty
w w NekoMimi @ NekoLabs (2023) made with <3
"""
banner = nm.figlet("VDock Lite", "small")
__disclaimer__ = __disclaimer__.replace("XXXXX", __version__)
factory = colourimi.colourFactory()
def kprint(text: str, col=Pallet.text):
factory.text = text
factory.colour = col
factory.cinit()
factory.cprint()
return
kprint(banner, Pallet.mochaFG)
kprint(__disclaimer__, Pallet.text2)
# variables
FS = ["", "--fullscreen"]
PWD = subprocess.getoutput("pwd")
HOME = subprocess.getoutput("echo $HOME")
DEF_CONFIG = f"{HOME}/.config/VDockLite/settings.conf"
# argv handler
if "--version" in sys.argv:
kprint(f"VDockLite v{__version__}", Pallet.random())
exit(0)
# config processing
DEF_CONF = """
fullscreen 0
#sets whether the video streams open in fullscreen
"""
def conf_parse(conf):
data = nm.read(conf)
tks = {}
lines = data.split("\n")
for line in lines:
if not line.startswith("#"):
if len(line.split(" ", 1)) > 1:
tks[line.split(" ", 1)[0]] = line.split(" ", 1)[1]
return tks
def safeRules(rawTOKENS):
if "fullscreen" in rawTOKENS:
try:
val = int(rawTOKENS["fullscreen"])
rawTOKENS["fullscreen"] = val
if val < 0 or val > 1:
rawTOKENS["fullscreen"] = 0
except Exception:
rawTOKENS["fullscreen"] = 0
else:
rawTOKENS["fullscreen"] = 0
return rawTOKENS
if exists(DEF_CONFIG):
kprint("Loading from file", Pallet.catYellow)
flags = conf_parse(DEF_CONFIG)
flags = safeRules(flags)
else:
kprint("No config file found", Pallet.catRed)
subprocess.getoutput("mkdir ~/.config/VDockLite/")
nm.write(DEF_CONF, DEF_CONFIG)
flags = conf_parse(DEF_CONFIG)
flags = safeRules(flags)
class Options:
def __init__(self, tk) -> None:
self.full: int = 0
self.sets(tk)
def sets(self, tk):
if "fullscreen" in tk:
self.full = tk["fullscreen"]
def __str__(self):
return f"[fullscreen] {self.full}"
settings = Options(flags)
kprint(settings, Pallet.catPurr)
print("")
def mainProc():
kprint("Vita ready to connect", Pallet.catOrange)
while True:
devices = subprocess.getoutput("v4l2-ctl --list-devices")
lines = devices.split("\n")
i = 0
for line in lines:
i += 1
if line.startswith("PSVita"):
subprocess.getoutput("pkill mpv")
kprint("Vita plugged in!", Pallet.catBlue)
vdev = f"/dev/video{lines[i][-1]}"
kprint(f"Vita on> {vdev}", Pallet.catYellow)
print("\n===============================\n")
subprocess.getoutput(
f"mpv av://v4l2:{vdev} --profile=low-latency --untimed {FS[settings.full]}"
)
time.sleep(1)
if __name__ == "__main__":
mainProc()
else:
kprint("Please run this script via 'python3 -m' or invoke it directly from your shell './VDlite'", Pallet.catRed)
exit(89)