diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-02-11 03:10:06 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-02-11 03:10:06 +0900 |
| commit | 13d4d6752b2086c0bf9ff38d1fa8408f4a5aae5f (patch) | |
| tree | de2b5e3b26e7d00b1fcf53fe761ae58e880e3823 /ar/.local | |
| parent | e79f665eba1fd69aa56162e826313ce1c7446ed4 (diff) | |
modified qutebrowser/config.py, modified bin/bookmarks, deleted bin/umpv, created userscripts/
Diffstat (limited to 'ar/.local')
| -rwxr-xr-x | ar/.local/bin/bookmarks | 7 | ||||
| -rwxr-xr-x | ar/.local/bin/umpv | 103 |
2 files changed, 3 insertions, 107 deletions
diff --git a/ar/.local/bin/bookmarks b/ar/.local/bin/bookmarks index c365095..1e5cfbf 100755 --- a/ar/.local/bin/bookmarks +++ b/ar/.local/bin/bookmarks @@ -122,10 +122,9 @@ openinbrowser() { case "$BROWSER" in *qutebrowser*) sqlite_query=" - SELECT DISTINCT h.title - FROM History h - WHERE h.redirect=1 - ORDER BY h.atime DESC + SELECT substr(h.title, 1, $cols) || ' | ' || h.url AS bookmark + FROM CompletionHistory h + ORDER BY h.last_atime DESC LIMIT 100; " ;; diff --git a/ar/.local/bin/umpv b/ar/.local/bin/umpv deleted file mode 100755 index da4a767..0000000 --- a/ar/.local/bin/umpv +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python3 - -""" -This script emulates "unique application" functionality. When starting -playback with this script, it will try to reuse an already running instance of -mpv (but only if that was started with umpv). Other mpv instances (not started -by umpv) are ignored, and the script doesn't know about them. - -This only takes filenames as arguments. Custom options can't be used; the script -interprets them as filenames. If mpv is already running, the files passed to -umpv are appended to mpv's internal playlist. If a file does not exist or is -otherwise not playable, mpv will skip the playlist entry when attempting to -play it (from the GUI perspective, it's silently ignored). - -If mpv isn't running yet, this script will start mpv and let it control the -current terminal. It will not write output to stdout/stderr, because this -will typically just fill ~/.xsession-errors with garbage. - -mpv will terminate if there are no more files to play, and running the umpv -script after that will start a new mpv instance. - -Note: you can supply custom mpv path and options with the MPV environment - variable. The environment variable will be split on whitespace, and the - first item is used as path to mpv binary and the rest is passed as options - _if_ the script starts mpv. If mpv is not started by the script (i.e. mpv - is already running), this will be ignored. -""" - -import os -import shlex -import socket -import string -import subprocess -import sys -from collections.abc import Iterable -from typing import BinaryIO - - -def is_url(filename: str) -> bool: - parts = filename.split("://", 1) - if len(parts) < 2: - return False - # protocol prefix has no special characters => it's an URL - allowed_symbols = string.ascii_letters + string.digits + "_" - prefix = parts[0] - return all(c in allowed_symbols for c in prefix) - -def get_socket_path() -> str: - if os.name == "nt": - return r"\\.\pipe\umpv" - - base_dir = ( - os.getenv("UMPV_SOCKET_DIR") or - os.getenv("XDG_RUNTIME_DIR") or - os.getenv("HOME") or - os.getenv("TMPDIR") - ) - - if not base_dir: - raise Exception("Could not determine a base directory for the socket. " - "Ensure that one of the following environment variables is set: " - "UMPV_SOCKET_DIR, XDG_RUNTIME_DIR, HOME or TMPDIR.") - - return os.path.join(base_dir, ".umpv") - -def send_files_to_mpv(conn: socket.socket | BinaryIO, files: Iterable[str]) -> None: - try: - send = conn.send if isinstance(conn, socket.socket) else conn.write - for f in files: - f = f.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n") - send(f'raw loadfile "{f}" append-play\n'.encode()) - except Exception: - print("mpv is terminating or the connection was lost.", file=sys.stderr) - sys.exit(1) - -def start_mpv(files: Iterable[str], socket_path: str) -> None: - mpv = "mpv" if os.name != "nt" else "mpv.exe" - mpv_command = shlex.split(os.getenv("MPV", mpv)) - mpv_command.extend([ - "--profile=builtin-pseudo-gui", - f"--input-ipc-server={socket_path}", - "--", - ]) - mpv_command.extend(files) - subprocess.Popen(mpv_command, start_new_session=True) - -def main() -> None: - files = (os.path.abspath(f) if not is_url(f) else f for f in sys.argv[1:]) - socket_path = get_socket_path() - - try: - if os.name == "nt": - with open(socket_path, "r+b", buffering=0) as pipe: - send_files_to_mpv(pipe, files) - else: - with socket.socket(socket.AF_UNIX) as sock: - sock.connect(socket_path) - send_files_to_mpv(sock, files) - except (FileNotFoundError, ConnectionRefusedError): - start_mpv(files, socket_path) - -if __name__ == "__main__": - main() |
