Compare commits
14 Commits
2019-03-20
...
2020-06-21
Author | SHA1 | Date | |
---|---|---|---|
129ca17ccd | |||
3bf21a54e6 | |||
4890ff8aaa | |||
5537227fc0 | |||
79ccd05105 | |||
bdf236d067 | |||
bfdf513154 | |||
c377f57173 | |||
343df18c83 | |||
b6d2c0b38b | |||
a39f4c9c51 | |||
f2a45a7ca3 | |||
61250fed0d | |||
af39e1d81e |
48
audiotrim.sh
48
audiotrim.sh
@ -1,48 +0,0 @@
|
|||||||
#!/usr/bin/bash
|
|
||||||
# Trim an audio file given a startpoint and an endpoint
|
|
||||||
# Dependencies: ffmpeg
|
|
||||||
|
|
||||||
printHelp() {
|
|
||||||
cat << EOF
|
|
||||||
Usage: audiotrim [input file] [start time] [stop time] [output file]
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-h show this help page
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
case "${1}" in
|
|
||||||
'-h'|'--help')
|
|
||||||
printHelp
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
--)
|
|
||||||
shift
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
printf '%s\n' "Unknown option: ${1}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ ! -x '/usr/bin/ffmpeg' ]]; then
|
|
||||||
printf '%s\n' 'ffmpeg program is not installed' >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
readonly infile="${1}"
|
|
||||||
readonly starttime="${2}"
|
|
||||||
readonly stoptime="${3}"
|
|
||||||
readonly outfile="${4}"
|
|
||||||
readonly format="${1%.*}"
|
|
||||||
|
|
||||||
[[ -z "${infile}" ]] && printf '%s\n' "No file entered." >&2 exit 2
|
|
||||||
[[ ! -f "${infile}" ]] && printf '%s\n' "Not a file: ${infile}" >&2 exit 3
|
|
||||||
|
|
||||||
ffmpeg -i "${infile}" -ss "${starttime}" -to "${stoptime}" -c copy "${outfile:-"${outfile%.*}-trimmed.${format}"}"
|
|
0
cptemplate.sh
Normal file → Executable file
0
cptemplate.sh
Normal file → Executable file
2
ddusb.py
Normal file → Executable file
2
ddusb.py
Normal file → Executable file
@ -8,7 +8,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# ========== Constants ==========
|
# ========== Constants ==========
|
||||||
COMMENT_PATTERN = "^[#;]"
|
COMMENT_PATTERN = r"^[#;]"
|
||||||
EXCLUDE_FILE = "/etc/helper-scripts/ddusb-exclude.conf"
|
EXCLUDE_FILE = "/etc/helper-scripts/ddusb-exclude.conf"
|
||||||
|
|
||||||
E_BLOCKDEVICE_ERROR = 1
|
E_BLOCKDEVICE_ERROR = 1
|
||||||
|
57
dlaudio.py
57
dlaudio.py
@ -1,57 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
"""Download audio using youtube-dl.
|
|
||||||
|
|
||||||
Dependencies:
|
|
||||||
=============
|
|
||||||
* youtube-dl
|
|
||||||
"""
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import pathlib
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
# =========== Constants ==========
|
|
||||||
YOUTUBE_DL_BIN = shutil.which("youtube-dl")
|
|
||||||
DEFAULT_FILENAME = f"{pathlib.Path.home()}/Music/%(title)s.%(ext)s"
|
|
||||||
|
|
||||||
# ========== Error Codes ==========
|
|
||||||
E_NOURLS = 2
|
|
||||||
|
|
||||||
# ========== Main Script ==========
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("-b", "--batchfile", help="provide the links from a text file")
|
|
||||||
parser.add_argument(
|
|
||||||
"-f", "--format", type=str, default="opus", help="the format to use"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-n", "--filename", type=str, help="downloaded filename (without extension)"
|
|
||||||
)
|
|
||||||
parser.add_argument("urls", nargs="*", help="video URLs")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
dl_opts = [
|
|
||||||
YOUTUBE_DL_BIN,
|
|
||||||
"--no-part",
|
|
||||||
"--no-continue",
|
|
||||||
"--extract-audio",
|
|
||||||
f"--audio-format={args.format}",
|
|
||||||
]
|
|
||||||
|
|
||||||
# filename handling
|
|
||||||
# if -b is used, DEFAULT_FILENAME must take precedence
|
|
||||||
if args.filename is not None and args.batchfile is None:
|
|
||||||
dl_opts.append(f"--output={args.filename}")
|
|
||||||
else:
|
|
||||||
dl_opts.append(f"--output={DEFAULT_FILENAME}")
|
|
||||||
|
|
||||||
# URL handling
|
|
||||||
if args.batchfile is not None:
|
|
||||||
dl_opts.append(f"--batch-file={args.batchfile}")
|
|
||||||
elif args.urls is not None:
|
|
||||||
dl_opts.extend(args.urls)
|
|
||||||
else:
|
|
||||||
print("URLs are required")
|
|
||||||
exit(E_NOURLS)
|
|
||||||
|
|
||||||
subprocess.run(dl_opts)
|
|
5
drivetemp.py
Normal file → Executable file
5
drivetemp.py
Normal file → Executable file
@ -54,10 +54,7 @@ def convert_to_celsius(mkel_temp):
|
|||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"device",
|
"device", help="device node to retrieve the temperature for", metavar="dev"
|
||||||
help="device node to retrieve\
|
|
||||||
the temperature for",
|
|
||||||
metavar="dev",
|
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
31
fedit.py
Normal file → Executable file
31
fedit.py
Normal file → Executable file
@ -13,26 +13,40 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from sys import platform
|
||||||
|
|
||||||
# ========== Constants ==========
|
# ========== Constants ==========
|
||||||
# ----- Paths -----
|
# ----- Paths -----
|
||||||
BOOT_DIR = "/boot"
|
BOOT_DIR = "/boot"
|
||||||
ETC_DIR = "/etc"
|
ETC_DIR = "/etc"
|
||||||
|
|
||||||
# ----- Exit Codes -----
|
# ----- Exit Codes -----
|
||||||
|
E_INTERRUPT = 1
|
||||||
E_NOEDITORFOUND = 2
|
E_NOEDITORFOUND = 2
|
||||||
E_NOFILESELECTED = 3
|
E_NOFILESELECTED = 3
|
||||||
|
|
||||||
# ----- Commands -----
|
# ----- Commands -----
|
||||||
FIND_CMD = "/usr/bin/fd"
|
|
||||||
|
# Options: show hidden files, null terminator, files only
|
||||||
|
# Optional arguments: show vcs files, show every file
|
||||||
|
FIND_CMD = shutil.which("fd")
|
||||||
FIND_OPTS = ["--hidden", "--print0", "--type", "f"]
|
FIND_OPTS = ["--hidden", "--print0", "--type", "f"]
|
||||||
EXTRA_FIND_OPTS = {"no_ignore_vcs": "--no-ignore", "no_ignore": "--no-ignore-vcs"}
|
EXTRA_FIND_OPTS = {"no_ignore_vcs": "--no-ignore", "no_ignore": "--no-ignore-vcs"}
|
||||||
|
|
||||||
LOCATE_CMD = "/usr/bin/locate"
|
# Options: null terminator, ignore case, print names matching all non-option arguments
|
||||||
LOCATE_OPTS = ["--all", "--ignore-case", "--null"]
|
LOCATE_CMD = shutil.which("locate")
|
||||||
|
|
||||||
FZF_CMD = "/usr/bin/fzf"
|
# Options: read null terminator, auto-select if one option, exit if no options, print null terminator
|
||||||
|
FZF_CMD = shutil.which("fzf")
|
||||||
FZF_OPTS = ["--read0", "--select-1", "--exit-0", "--print0"]
|
FZF_OPTS = ["--read0", "--select-1", "--exit-0", "--print0"]
|
||||||
|
|
||||||
|
# Platform-specific options
|
||||||
|
# macOS doesn't support GNU-style long options
|
||||||
|
if platform == "linux":
|
||||||
|
LOCATE_OPTS = ["--all", "--ignore-case", "--null"]
|
||||||
|
elif platform == "darwin":
|
||||||
|
LOCATE_OPTS = ["-0", "-i"]
|
||||||
|
|
||||||
# ----- Misc. -----
|
# ----- Misc. -----
|
||||||
LOCALE = "utf-8"
|
LOCALE = "utf-8"
|
||||||
|
|
||||||
@ -138,6 +152,10 @@ def locate_files(patterns):
|
|||||||
|
|
||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# This script doesn't support Windows
|
||||||
|
if platform == "windows":
|
||||||
|
sys.exit(E_INTERRUPT)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-b",
|
"-b",
|
||||||
@ -200,7 +218,10 @@ if __name__ == "__main__":
|
|||||||
else locate_files(args.patterns)
|
else locate_files(args.patterns)
|
||||||
)
|
)
|
||||||
|
|
||||||
selected_file = run_fzf(files)
|
try:
|
||||||
|
selected_file = run_fzf(files)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
exit(E_INTERRUPT)
|
||||||
|
|
||||||
if selected_file != "":
|
if selected_file != "":
|
||||||
cmd = gen_editor_cmd(selected_file)
|
cmd = gen_editor_cmd(selected_file)
|
||||||
|
0
getweather.py
Normal file → Executable file
0
getweather.py
Normal file → Executable file
0
lsgroups.sh
Normal file → Executable file
0
lsgroups.sh
Normal file → Executable file
0
lsusers.sh
Normal file → Executable file
0
lsusers.sh
Normal file → Executable file
0
misc/quickdel.sh
Normal file → Executable file
0
misc/quickdel.sh
Normal file → Executable file
4
quickdel.py
Normal file → Executable file
4
quickdel.py
Normal file → Executable file
@ -33,7 +33,7 @@ from termcolor import colored
|
|||||||
FD_BIN = "/usr/bin/fd"
|
FD_BIN = "/usr/bin/fd"
|
||||||
FD_OPTS = ["--hidden"]
|
FD_OPTS = ["--hidden"]
|
||||||
# Matches 'y' or 'yes' only, ignoring case
|
# Matches 'y' or 'yes' only, ignoring case
|
||||||
USER_RESPONSE_YES = "^[Yy]{1}([Ee]{1}[Ss]{1})?$"
|
USER_RESPONSE_YES = r"^[Yy]{1}([Ee]{1}[Ss]{1})?$"
|
||||||
|
|
||||||
E_NO_RESULTS = 1
|
E_NO_RESULTS = 1
|
||||||
E_USER_RESPONSE_NO = 2
|
E_USER_RESPONSE_NO = 2
|
||||||
@ -137,7 +137,7 @@ if __name__ == "__main__":
|
|||||||
for ext in args.extensions:
|
for ext in args.extensions:
|
||||||
FD_OPTS.extend(["--extension", ext])
|
FD_OPTS.extend(["--extension", ext])
|
||||||
|
|
||||||
files = {}
|
files = set()
|
||||||
for pattern in args.patterns:
|
for pattern in args.patterns:
|
||||||
cmd = [FD_BIN, *FD_OPTS, pattern]
|
cmd = [FD_BIN, *FD_OPTS, pattern]
|
||||||
files.update(
|
files.update(
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#compdef dlaudio
|
|
||||||
|
|
||||||
# zsh completions for 'dlaudio'
|
|
||||||
local arguments
|
|
||||||
|
|
||||||
arguments=(
|
|
||||||
{-h,--help}'[show this help message and exit]'
|
|
||||||
{-b,--batch-dl}'[provide the links from a text file]'
|
|
||||||
{-f,--format}'[the format to use (default:flac)]'
|
|
||||||
{-n,--filename}'[the name of the downloaded file (without extension)]'
|
|
||||||
'*:filename:_files'
|
|
||||||
)
|
|
||||||
|
|
||||||
_arguments -s $arguments
|
|
@ -1,15 +1,15 @@
|
|||||||
# Fuzzy find a file and then edit it
|
# Fuzzy find a file and then edit it
|
||||||
|
|
||||||
_fedit() {
|
_run_fedit() {
|
||||||
/usr/bin/fedit && zle reset-prompt
|
fedit && zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
_etcedit() {
|
_run_etcedit() {
|
||||||
/usr/bin/fedit --etc && zle reset-prompt
|
fedit --etc && zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N _fedit
|
zle -N _run_fedit
|
||||||
bindkey -M viins '^o' _fedit
|
bindkey -M viins '^o' _run_fedit
|
||||||
|
|
||||||
zle -N _etcedit
|
zle -N _run_etcedit
|
||||||
bindkey -M viins '^e' _etcedit
|
bindkey -M viins '^e' _run_etcedit
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Fuzzy-find a file and open it in less
|
# Fuzzy-find a file and open it in less
|
||||||
fless() {
|
_run_fless() {
|
||||||
/usr/bin/fless && zle reset-prompt
|
/usr/bin/fless && zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N fless
|
zle -N _run_fless
|
||||||
bindkey -M viins '^n' fless
|
bindkey -M viins '^n' _run_fless
|
||||||
|
Reference in New Issue
Block a user