mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
add very bad idea
This commit is contained in:
parent
6e7935abaf
commit
7e139288a6
27
bin/mtag/very-bad-idea.py
Executable file
27
bin/mtag/very-bad-idea.py
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
use copyparty to xdg-open anything that is posted to it
|
||||
|
||||
example copyparty config to use this:
|
||||
--urlform save,get -v.::w:c,e2d,e2t,mte=+a1:c,mtp=a1=ad,bin/mtag/very-bad-idea.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess as sp
|
||||
from urllib.parse import unquote_to_bytes as unquote
|
||||
|
||||
|
||||
def main():
|
||||
with open(os.path.abspath(sys.argv[1]), "rb") as f:
|
||||
txt = f.read()
|
||||
|
||||
txt = unquote(txt.replace(b"+", b" ")).decode("utf-8")[4:]
|
||||
|
||||
sp.call(["notify-send", "", txt])
|
||||
sp.call(["xdotool", "key", "ctrl+w"])
|
||||
sp.call(["xdg-open", txt])
|
||||
|
||||
|
||||
main()
|
Loading…
Reference in a new issue