Compare commits
10 Commits
2019-02-13
...
2019-03-02
Author | SHA1 | Date | |
---|---|---|---|
71264172f2 | |||
8da5be2c19 | |||
9d46615a56 | |||
aaea526054 | |||
13257f07e6 | |||
fc101fb30b | |||
45aac4e39b | |||
bbfff16b44 | |||
43013af49f | |||
475eaebd96 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
*.pkg.tar.xz*
|
*.pkg.tar.xz*
|
||||||
helper-scripts
|
helper-scripts
|
||||||
|
helper-scripts.spec
|
||||||
PKGBUILD
|
PKGBUILD
|
||||||
pkg
|
pkg
|
||||||
src
|
src
|
||||||
|
21
dlaudio.py
21
dlaudio.py
@ -8,10 +8,11 @@ Dependencies:
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# =========== Constants ==========
|
# =========== Constants ==========
|
||||||
YOUTUBE_DL_BIN = '/usr/bin/youtube-dl'
|
YOUTUBE_DL_BIN = shutil.which('youtube-dl')
|
||||||
DEFAULT_FILENAME = f"{pathlib.Path.home()}/Music/%(title)s.%(ext)s"
|
DEFAULT_FILENAME = f"{pathlib.Path.home()}/Music/%(title)s.%(ext)s"
|
||||||
|
|
||||||
# ========== Error Codes ==========
|
# ========== Error Codes ==========
|
||||||
@ -20,8 +21,6 @@ E_NOURLS = 2
|
|||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-b', '--batchfile',
|
parser.add_argument('-b', '--batchfile',
|
||||||
type=str,
|
|
||||||
nargs=1,
|
|
||||||
help='provide the links from a text file')
|
help='provide the links from a text file')
|
||||||
parser.add_argument('-f', '--format',
|
parser.add_argument('-f', '--format',
|
||||||
type=str,
|
type=str,
|
||||||
@ -39,22 +38,22 @@ dl_opts = [YOUTUBE_DL_BIN,
|
|||||||
'--no-part',
|
'--no-part',
|
||||||
'--no-continue',
|
'--no-continue',
|
||||||
'--extract-audio',
|
'--extract-audio',
|
||||||
'--audio-format={args.format}']
|
f"--audio-format={args.format}"]
|
||||||
|
|
||||||
# filename handling
|
# filename handling
|
||||||
# if -b is used, DEFAULT_FILENAME must take precedence
|
# if -b is used, DEFAULT_FILENAME must take precedence
|
||||||
if args.filename:
|
if args.filename is not None and args.batchfile is None:
|
||||||
dl_opts.append('--output={args.filename}')
|
dl_opts.append(f"--output={args.filename}")
|
||||||
else:
|
else:
|
||||||
dl_opts.append('--output={DEFAULT_FILENAME}')
|
dl_opts.append(f"--output={DEFAULT_FILENAME}")
|
||||||
|
|
||||||
# URL handling
|
# URL handling
|
||||||
if args.batchfile:
|
if args.batchfile is not None:
|
||||||
dl_opts.append(f"--batch-file={args.batchfile}")
|
dl_opts.append(f"--batch-file={args.batchfile}")
|
||||||
elif not args.urls:
|
elif args.urls is not None:
|
||||||
|
dl_opts.extend(args.urls)
|
||||||
|
else:
|
||||||
print("URLs are required")
|
print("URLs are required")
|
||||||
exit(E_NOURLS)
|
exit(E_NOURLS)
|
||||||
else:
|
|
||||||
dl_opts.extend(args.urls)
|
|
||||||
|
|
||||||
subprocess.run(dl_opts)
|
subprocess.run(dl_opts)
|
||||||
|
@ -35,7 +35,7 @@ def retrieve_smart_temp(device_node):
|
|||||||
:returns: output of skdump in mKelvin
|
:returns: output of skdump in mKelvin
|
||||||
:rtype: float
|
:rtype: float
|
||||||
"""
|
"""
|
||||||
temp = subprocess.run(DUMP_CMD + device_node,
|
temp = subprocess.run(DUMP_CMD + [device_node],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True).stdout
|
text=True).stdout
|
||||||
return float(temp)
|
return float(temp)
|
||||||
|
13
fedit.py
13
fedit.py
@ -50,15 +50,20 @@ def select_editor(editor_override=None):
|
|||||||
:rtype: str
|
:rtype: str
|
||||||
:raises: FileNotFoundError if an editor could not be resolved
|
:raises: FileNotFoundError if an editor could not be resolved
|
||||||
"""
|
"""
|
||||||
|
editor = None
|
||||||
|
|
||||||
if editor_override is not None:
|
if editor_override is not None:
|
||||||
return shutil.which(editor_override)
|
editor = shutil.which(editor_override)
|
||||||
elif 'EDITOR' in os.environ:
|
elif 'EDITOR' in os.environ:
|
||||||
return shutil.which(os.environ.get('EDITOR'))
|
editor = shutil.which(os.environ.get('EDITOR'))
|
||||||
elif shutil.which('vim') is not None:
|
elif shutil.which('vim') is not None:
|
||||||
return shutil.which('vim')
|
editor = shutil.which('vim')
|
||||||
else:
|
|
||||||
|
if editor is None:
|
||||||
raise FileNotFoundError('An editor could not be resolved')
|
raise FileNotFoundError('An editor could not be resolved')
|
||||||
|
|
||||||
|
return editor
|
||||||
|
|
||||||
|
|
||||||
def gen_editor_cmd(filename):
|
def gen_editor_cmd(filename):
|
||||||
"""Generate a command line to run for editing a file based on
|
"""Generate a command line to run for editing a file based on
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#compdef cptemplate
|
#compdef cptemplate
|
||||||
|
|
||||||
# zsh completions for 'cptemplate'
|
# ========== Completions ==========
|
||||||
# automatically generated with http://github.com/RobSis/zsh-completion-generator
|
|
||||||
local arguments
|
local arguments
|
||||||
|
|
||||||
arguments=(
|
arguments=(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#compdef dlaudio
|
#compdef dlaudio
|
||||||
|
|
||||||
# zsh completions for 'dlaudio'
|
# zsh completions for 'dlaudio'
|
||||||
# automatically generated with http://github.com/RobSis/zsh-completion-generator
|
|
||||||
local arguments
|
local arguments
|
||||||
|
|
||||||
arguments=(
|
arguments=(
|
||||||
|
14
zsh/completions/_fedit
Normal file
14
zsh/completions/_fedit
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#compdef fedit
|
||||||
|
local arguments
|
||||||
|
|
||||||
|
arguments=(
|
||||||
|
$argument_list
|
||||||
|
{-h, --help}'[show this help message and exit]'
|
||||||
|
{-b, --boot}'[edit a file in /boot]'
|
||||||
|
{-d, --dir}'[edit a file in a given directory]'
|
||||||
|
{-E, --etc}'[edit a file in /etc]'
|
||||||
|
{-e, --editor}'[use a given editor]'
|
||||||
|
'*:filename:_files'
|
||||||
|
)
|
||||||
|
|
||||||
|
_arguments -s $arguments
|
@ -1,7 +1,6 @@
|
|||||||
#compdef open
|
#compdef open
|
||||||
|
|
||||||
# zsh completions for 'open'
|
# ========== Completions ==========
|
||||||
# automatically generated with http://github.com/RobSis/zsh-completion-generator
|
|
||||||
local arguments
|
local arguments
|
||||||
|
|
||||||
arguments=(
|
arguments=(
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#compdef quickdel
|
#compdef quickdel
|
||||||
|
|
||||||
# zsh completions for 'quickdel'
|
# ========== Completions ==========
|
||||||
# automatically generated with http://github.com/RobSis/zsh-completion-generator
|
|
||||||
local arguments
|
local arguments
|
||||||
|
|
||||||
arguments=(
|
arguments=(
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
# Fuzzy cd from anywhere
|
# Fuzzy cd from anywhere
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# - fzf
|
# * fzf
|
||||||
# - mlocate
|
# * mlocate
|
||||||
|
|
||||||
|
# ========== Shortcuts ==========
|
||||||
cf() {
|
cf() {
|
||||||
[[ -z "${*}" ]] && return 1
|
[[ -z "${*}" ]] && return 1
|
||||||
[[ ! -x /usr/bin/fzf ]] && return 1
|
[[ ! -x /usr/bin/fzf ]] && return 1
|
@ -1,13 +1,16 @@
|
|||||||
# call the fedit script
|
# Fuzzy find a file and then edit it
|
||||||
|
|
||||||
_fedit() {
|
_fedit() {
|
||||||
/usr/bin/fedit
|
/usr/bin/fedit
|
||||||
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
_etcedit() {
|
_etcedit() {
|
||||||
/usr/bin/fedit -E
|
/usr/bin/fedit --etc
|
||||||
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N fedit
|
zle -N _fedit
|
||||||
bindkey -M viins '^o' _fedit
|
bindkey -M viins '^o' _fedit
|
||||||
|
|
||||||
zle -N _etcedit
|
zle -N _etcedit
|
@ -1,6 +1,7 @@
|
|||||||
# key bindings for fless script
|
# Fuzzy-find a file and open it in less
|
||||||
fless() {
|
fless() {
|
||||||
/usr/bin/fless
|
/usr/bin/fless
|
||||||
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N fless
|
zle -N fless
|
Reference in New Issue
Block a user