feat: add script
This commit is contained in:
parent
c28408cabc
commit
09328660a0
@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
from urllib import request
|
||||
from shutil import which
|
||||
|
||||
def find_discord_asar(discord_exec: str) -> Path | None:
|
||||
dis_loc = which(discord_exec)
|
||||
if not dis_loc:
|
||||
return
|
||||
dis = Path(dis_loc)
|
||||
with dis.open("r") as f:
|
||||
try:
|
||||
content = f.read(256)
|
||||
except UnicodeDecodeError:
|
||||
# Official Discord app, the binary is hopefully symlink
|
||||
# e.g. /usr/bin/discord -> /opt/discord/Discord
|
||||
asar_path = dis.resolve().parent.joinpath("resources/app.asar")
|
||||
if asar_path.is_file():
|
||||
return asar_path
|
||||
else:
|
||||
# Discord wrapper script (Discord system Electron, etc.)
|
||||
for v in content.split():
|
||||
if "app.asar" not in v:
|
||||
continue
|
||||
# v is full path to app.asar
|
||||
# e.g. /usr/lib/discord-canary/app.asar
|
||||
return Path(v)
|
||||
|
||||
|
||||
def download_openasar():
|
||||
file, _ = request.urlretrieve("")
|
||||
return file
|
||||
|
||||
def main():
|
||||
print(find_discord_asar("discord-canary"))
|
||||
# print("Downloading OpenAsar (nightly)...")
|
||||
# file = request.urlretrieve("")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
3
os/linux/README.md
Normal file
3
os/linux/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Linux-only scripts
|
||||
|
||||
+ [automount.py](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/os/linux/automount.py) ([source](./automount.py)): Automatically creates directory defined in `/etc/fstab` and mount them with `mount -a`
|
26
os/linux/automount.py
Executable file
26
os/linux/automount.py
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
|
||||
fstab_txt = Path("/etc/fstab").read_text()
|
||||
for line in fstab_txt.splitlines():
|
||||
if line.startswith("#") or line.strip() == "":
|
||||
continue
|
||||
line_split = line.split(" ")
|
||||
if len(line_split) == 1:
|
||||
continue
|
||||
for text in line_split[1:]:
|
||||
if text.strip() == "":
|
||||
continue
|
||||
# text is probably the directory we wanted
|
||||
target_path = Path(text)
|
||||
if not target_path.is_dir():
|
||||
print(f"Touching directory: {target_path}")
|
||||
target_path.mkdir(parents=True, exist_ok=True)
|
||||
break
|
||||
|
||||
print("Mounting all directories...")
|
||||
process = Popen("mount -a", shell=True, stdout=PIPE, stderr=STDOUT)
|
||||
for line in iter(process.stdout.readline, b""):
|
||||
sys.stdout.write(line.decode())
|
@ -8,5 +8,6 @@ Useful UserScripts that I use everyday.
|
||||
+ [genshin-concert2022-wallpaper-mode.user.js](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/genshin-concert2022-wallpaper-mode.user.js) ([source](./genshin-concert2022-wallpaper-mode.user.js)): Wallpaper mode for https://genshin.hoyoverse.com/concert2022 (Genshin 2022 concert)
|
||||
+ [hidemy.name-free-ipport-export.user.js](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/hidemy.name-free-ipport-export.user.js) ([source](./hidemy.name-free-ipport-export.user.js)): Free export IP:Port button in hidemy.name
|
||||
+ [kgvn-8thang5-autofarm.user.js](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/kgvn-8thang5-autofarm.user.js) ([source](./kgvn-8thang5-autofarm.user.js)): Auto farm for a certain web event in AoV Vietnamese version.
|
||||
+ [pixiv-ai-notifier.user.js](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/pixiv-ai-notifier.user.js) ([source](./pixiv-ai-notifier.user.js)): Notifies you when the artwork you're viewing is an AI-generated one.
|
||||
+ [tiktok.user.js](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/tiktok.user.js) ([source](./tiktok.user.js)): Enhance TikTok experience on PC, currently only removes the "Download app" banner.
|
||||
+ [yt-noshorts.user.js](https://git.tretrauit.me/tretrauit/scripts/raw/branch/main/userscripts/yt-noshorts.user.js) ([source](./yt-noshorts.user.js)): Redirects Shorts to normal video webpage in YouTube.
|
||||
|
Loading…
Reference in New Issue
Block a user