Cleanup: Update README, remove old scripts

master
Taeyeon Mori 7 years ago
parent 67de196e8a
commit 5790ea24ca
  1. 101
      README.md
  2. 119
      bin/abs2
  3. 4
      bin/aur.sh
  4. 74
      bin/lns
  5. 136
      bin/superseded/aconvert
  6. 37
      bin/superseded/mpr
  7. 7
      zsh/zshrc

@ -1,16 +1,18 @@
Taeyeon's dotfiles (.files)
===========================
.files/install
--------------
A ZShell script to set up the dotfiles. It will also ask a few personal questions.
A ZShell script to set up the dotfiles. It will also ask a few questions.
Run this on a new system to set it up.
.files/zsh
----------
The ZSH part makes use of the Prezto framework (http://github.com/sorin-ionescu/prezto)
Configuration happens in the z\* files in .files/zsh:
##### ZSH configuration files
- zshenv : executed by all zsh instances
- zprofile : executed by any top-level shell
- zshrc : executed by interactive shells (loads prezto)
@ -18,27 +20,45 @@ Configuration happens in the z\* files in .files/zsh:
- zlogin : executed by login shells
- zlogout : executed when a login shell exits
- functions/ : Added to fpath
- prompt\_tae\_setup: `tae` prompt setup
- zplug/ : Zplug home directory
.files/bin
----------
Contains utility applications I'd hate to miss
Notable ones are:
- xconv : A simple, profile-based, batch-enabled "frontend" to ffmpeg.
- aconvert : Pre-advancedav version of xconv. Has profiles for extracting audio.
- ffpsp\* : Scripts to run HandBrakeCLI to convert videos for use with Sony's PSP.
- pulse-\* : Tools to be used with my pulse configuration in .files/config/pulse
- paloop : Loop a pulseaudio source to a sink
- aur.sh : More powerfull version of the popular aur.sh script.
- schedshut : Shutdown when a specific task/process finishes.
- mountpart : Mount a partition in a whole-disk imagefile.
- argshell : call the same application repeatedly, with a common set of arguments.
- fix-steam-runtime.sh : Fix Steam runtime on Arch Linux (And others with "too new" libstdc++ and friends)
- prepare\_steam : Manage Steam Library Folders on Removable Storage
- sm-song-package : Simplify creation of SM5-compliant song packages
- unpack\_shift : Unpack SHIFT-JIS archives
- stayawake : Pause music player when one falls asleep
- lns : Make symbolic links without thinking about relative paths too hard
- visualsleep : A sleep utility with visual feedback
#### (Z) Shell scripts
- argshell : Run the same program multiple times with a common prefix of arguments
- aur.sh : Quite sophisticated AUR helper
- ffpsp(-batch) : Use HandBrakeCLI to encode videos to be compatible with Sony's PSP.
- fix-steam-runtime.sh: Fix Steam runtime on Arch Linux (And others with "too new" libstdc++ and friends)
- force-run-elf : Try to execute a non-executable ELF file by passing it to the appropriate interpreter
- paloop : Loop a pulseaudio source to a sink.
- remembersong : Save the currently playing song name and artist to a text file.
- schedshut : Shutdown when a specific task/process finishes.
- start : Start a (graphical) app in the background; Like windows command of same name.
- syncfat : Copy files to a Windows volume while removing invalid characters from filenames.
- unpack\_shift : Unpack archives with different filename encoding
#### Python scripts
- animelib : Manually organize a collection of tv series
- animelib3 : Try to automagically organize tv series as best as possible
- fileinterp.py : Play back a python script file as if it had been entered into a prompt.
- mountpart : Mount a partition in a whole-disk raw image file.
- nosaver : Try to inhibit the screensaver.
- patchdir : Patch a folder structure with files from an archive.
- sm-song-package : Try to automatically create a .smzip of songs for StepMania.
- transportlinks : Fixup symlinks after moving the target files.
- videothumb : Create (PSP compatible) thumbnails for video files.
- visualsleep : Sleep command with countdown timer.
- xconv : A simple, profile-based, batch-enabled "frontend" to ffmpeg.
###### Broken
- mpr : Control and listen to mpd stream at the same time.
- prepare\_steam : Try to fix up steam libraries on removable media.
- stayawake : Pause media playback when user falls asleep.
.files/etc
@ -46,41 +66,60 @@ Notable ones are:
Contains configuration for those utilities
Currently contains:
- aur.conf : Configuration for aur.sh
- user-info : The user information entered at install time, in shell-readable form
- prepare\_steam.vdf : Config file for prepare\_steam
- aur.conf : Configuration for aur.sh
- user-info : The user information entered at install time, in shell-readable form
- prepare\_steam.vdf: Config file for prepare\_steam
.files/lib
----------
Contains support libraries
Currently, that entails:
#### (Z) Shell
- libsh-utils.sh : A collection of useful shell functions
- libzsh-utils.zsh : More utility shell functions, but using zsh-specific features
- libpulse-config.sh: Functions for working with the pulseaudio configs in .files/config/pulse
- libssh-agent.sh : Functions for working with the ssh-agent
As well as some python modules:
#### Python
- advancedav.py : A very overengineered way to construct complex ffmpeg commandlines
- animelib.py : Library version on animelib script
- vdfparser.py : A simple parser for Valve's VDF Key/Value format
- xconv/ : Supporting library for xconv media conversion utility
- profiles/ : (Virtual) package containing xconv profiles
.files/git
----------
Contains the git configuration (.files/git/config)
NOTE that changes made though git config WILL NOT BE RESPECTED,
because it writes to ~/.gitconfig, which is a proxy that includes .files/git/config .
Changes made through `git config --global` have to be manually applied to
.files/git/config (from ~/.gitconfig) to persist them
Also note that git uses its own version of user-info (.files/git/user-info)
.files/dotfiles
---------------
General dotfiles repository. Everything that doesn't need to be special-cased goes here.
Misc. dotfiles
- makepkg.conf : Arch/Pacman makepkg configuration. See also aur.sh and aur.conf
- vimrc : Original vim configuration
##### X11
- XCompose : Compose definitions
- xinputrc : X11 input device configuration
- xprofile : X11 startup script
.files/config
-------------
XDG configuration directory.
Items will be symlinked to ~/.config (NOT IMPLEMENTED)
XDG configuration directory
- systemd/user : Systemd user units
- ssh-agent : Service unit to keep a per-user ssh-agent instance
- nvim : NeoVim configuration
.files/texmf
------------
@ -89,11 +128,13 @@ Contains LaTeX classes
- Intridea beamer theme
- 'jatools' package with some Japanese-related things
$HOME
-----
All dotfiles are symlinked into the home directory or have a proxy file generated.
Known proxies: .gitconfig, .zshenv
Currently employed proxies: .gitconfig, .zshenv
\*.local
--------

@ -1,119 +0,0 @@
#!/usr/bin/env python3
# (c) 2014 Taeyeon MORI
import os
import argparse
import subprocess
import hashlib
import contextlib
import sys
import termios
import shutil
system = lambda *a: subprocess.check_call(a)
class Package:
def __init__(self, x):
self.fqn = x
self.repo, self.name = x.split("/")
def parse_args(argv):
parser = argparse.ArgumentParser(prog=argv[0])
def add_option(option, default, help=None):
parser.add_argument(option, default=default)
def add_switch(option, default=False, help=None):
parser.add_argument(option, default=default, action="store_const", const=not default)
parser.add_argument("package", type=Package)
add_option("-buildroot", "/tmp/abs-%i" % os.getuid())
add_option("-makepkg", "makepkg")
add_switch("-nobuild")
add_switch("-install")
return parser.parse_args(argv[1:])
def file_sha1(name):
with open(name, "rb") as f:
hash = hashlib.sha1()
while True:
data = f.read(2048)
if not data:
return hash.digest()
hash.update(data)
@contextlib.contextmanager
def rawinput(file):
fd = file.fileno() if hasattr(file, "fileno") else file
flags = save = termios.tcgetattr(fd)
flags[3] &= ~termios.ICANON
flags[6][termios.VMIN] = 1
flags[6][termios.VTIME] = 0
termios.tcsetattr(fd, termios.TCSADRAIN, flags)
yield
termios.tcsetattr(fd, termios.TCSADRAIN, save)
def yesno(prompt):
ch = ""
while ch not in "yYnN":
sys.stdout.write(prompt)
sys.stdout.write(" [Y/N] ")
sys.stdout.flush()
with rawinput(sys.stdin):
ch = sys.stdin.read(1)
sys.stdout.write("\r")
sys.stdout.write("\n")
return ch in "yY"
def main(argv):
args = parse_args(argv)
print("===> Synchronizing ABS")
system("sudo", "abs", args.package.fqn)
print("===> Updating build directory")
ABS_DIR = os.path.join("/var/abs", args.package.fqn)
if not os.path.exists(ABS_DIR):
print("=ERROR=> No such pacakge: %s" % args.package.fqn)
return 1
REPODIR = os.path.join(args.buildroot, args.package.repo)
PACKDIR = os.path.join(REPODIR, args.package.name)
if not os.path.exists(PACKDIR):
os.makedirs(PACKDIR)
for path, dirs, files in os.walk(ABS_DIR):
rel_path = os.path.relpath(path, ABS_DIR)
dest_path = os.path.join(PACKDIR, rel_path)
for dir in dirs:
dest = os.path.join(dest_path, dir)
os.path.exists(dest) or os.mkdir(dest)
for file in files:
source = os.path.join(path, file)
dest = os.path.join(dest_path, file)
(not os.path.exists(dest) or (file_sha1(source) != file_sha1(dest) and yesno("=> Overwrite %s?" % os.path.join(rel_path, file)))) and shutil.copy(source, dest)
yesno("=> Edit %s PKGBUILD?" % args.package.fqn) and system(os.environ.get("EDITOR", "vim"), os.path.join(PACKDIR, "PKGBUILD"))
if not args.nobuild:
print("===> Building Package %s" % args.package.fqn)
os.chdir(PACKDIR)
if args.install:
system(args.makepkg, "-i")
else:
system(args.makepkg)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))

@ -391,7 +391,9 @@ collect_package() {
done
fi
AFFECTED_PKGS=("${AFFECTED_PKGS[@]}" "$p")
if ! (( $AFFECTED_PKGS[(I)$p] )); then # Don't add split packages depending on themselves multiple times. FIXME: Properly handle cycles
AFFECTED_PKGS=("${AFFECTED_PKGS[@]}" "$p")
fi
}
# Package processing

@ -1,74 +0,0 @@
#!/usr/bin/env python3
# (c) 2015 Taeyeon Mori
# A simple script to make ln -s less painful
#
# Because of how symbolic links work (they're just a pathname that the OS reads and follows),
# the link target path must always be relative to the symlink's containing directory, OR
# an absolute path altogether. Unfortunately, ln -s does not automatically solve this issue
# which makes it painful to create a relative symlink somewhere outside the current working
# directory (It screws up shell completion for instance)
# This script performs the path transformation before creating the link and can therefore be
# used without worries of creating broken symlinks because one forgot to apply the correct
# relative adjustment to the target path
#
# ex:
# $ lns -v some-file dir/some-link
# ln -s '../some-file' 'dir/some-link'
# $ lns -v file ../derp/link # inside a directory called 'herp'
# ln -s '../herp/file' '../derp/link'
import os
import argparse
def transport_relpath(path, old_anchor, new_anchor):
"""
:brief: Transport a relative path from one anchor to another
Anchors must both be absolute paths, path must be relative (to old_anchor)
"""
return os.path.relpath(os.path.normpath(os.path.join(old_anchor, path)), new_anchor)
def verbose_symlink(target, dest):
print("ln -s '%s' '%s'" % (target, dest))
return os.symlink(target, dest)
def main(argv):
# Command line interface to make_symlink()
parser = argparse.ArgumentParser(prog=argv[0],
description="A 'ln -s' command that automatically translates relative target paths to be relative to the resulting symlink's containing directory when necessary.")
parser.add_argument("target", help="The file(s) to create symlink(s) to", nargs="+")
parser.add_argument("destination", help="The path of the symbolic link(s) to create")
parser.add_argument("-v", "--verbose", help="Print every operation",
dest="symlink", const=verbose_symlink, action="store_const", default=os.symlink)
args = parser.parse_args(argv[1:])
# Multiple
if len(args.target) > 1:
if not os.path.isdir(args.destination):
print("Destination must be an existing directory when multiple targets are passed!")
for target in args.target:
dest = os.path.join(args.destination, os.path.basename(target))
args.symlink(target if os.path.isabs(target) else transport_relpath(target, os.curdir, args.destination), dest)
# One
else:
target = args.target[0]
dest = ldir = args.destination
if os.path.isdir(dest):
dest = os.path.join(dest, os.path.basename(target))
else:
ldir = os.path.dirname(dest)
args.symlink(target if os.path.isabs(target) else transport_relpath(target, os.curdir, ldir), dest)
return 0
if __name__ == "__main__":
import sys
sys.exit(main(sys.argv))

@ -1,136 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import subprocess
import argparse
def main():
try:
return main_()
except SystemExit as e:
try:
return int(e.code)
except:
print(e.code)
return 1
def kvpair(x):
if x == "YES":
return True
elif x == "NO":
return False
elif x == "\\YES":
return "YES"
elif x == "\\NO":
return "NO"
else:
return x
def main_():
argp = argparse.ArgumentParser()
argp.add_argument("source", nargs="+")
argp.add_argument("destination")
argp.add_argument("-p", "--profile", choices=["aac", "m4a", "ogg", "wav", "wma"])
argp.add_argument("-u", "--update", help="Only process new files", action="store_true")
argp.add_argument("--avconv", default="avconv")
argp.add_argument("-m", nargs=2, action="append", type=kvpair, default=[])
argp.add_argument("-i", nargs=2, action="append", type=kvpair, default=[])
argp.add_argument("-o", nargs=2, action="append", type=kvpair, default=[])
args = argp.parse_args()
i_flags = dict()
o_flags = dict()
m_flags = dict()
# no video
o_flags["vn"] = True
m_flags["update"] = args.update
# capability checks
s = subprocess.check_output([args.avconv, "-codecs"], stderr=subprocess.DEVNULL)
if b"faac" in s:
aac = {"acodec": "faac"}
else:
aac = {"acodec": "aac", "strict": "experimental"}
if b"libvorbis" in s:
vorbis = {"acodec": "libvorbis"}
else:
vorbis = {"acodec": "vorbis", "strict": "experimental"}
# profiles
m_flags["fileext"] = "raw"
if args.profile == "aac":
m_flags["fileext"] = "aac"
o_flags.update(aac)
elif args.profile == "m4a":
m_flags["fileext"] = "m4a"
o_flags.update(aac)
elif args.profile == "ogg":
m_flags["fileext"] = "ogg"
o_flags.update(vorbis)
elif args.profile == "wav":
m_flags["fileext"] = "wav"
o_flags["acodec"] = "pcm_f32le"
elif args.profile == "wma":
m_flags["fileext"] = "wma"
o_flags["acodec"] = "wmav2"
o_flags["ac"] = 2
i_flags.update(dict(args.i))
o_flags.update(dict(args.o))
m_flags.update(dict(args.m))
if len(args.source) > 1:
run_multiple(m_flags, args.avconv, i_flags, args.source, o_flags, args.destination)
else:
run_once(m_flags, args.avconv, i_flags, args.source[0], o_flags, args.destination)
return 0
def make_destfile(source, m, destination):
if not os.path.isdir(destination):
return destination
stem, ext = os.path.splitext(source)
destfile = ".".join((stem, m["fileext"]))
return os.path.join(destination, destfile)
def add_args(argv, argdict):
for k,v in argdict.items():
argv.append("-%s" % k)
if v is not True:
argv.append(str(v))
def make_argv(m, avconv, i, source, o, destination):
argv = [avconv]
add_args(argv, i)
argv.append("-i")
argv.append(source)
add_args(argv, o)
argv.append(make_destfile(source, m, destination))
return argv
def run_once(m, avconv, i, source, o, destination):
dest = make_destfile(source, m, destination)
if m["update"] and os.path.exists(dest) and os.stat(dest).st_mtime >= os.stat(source).st_mtime:
return
try:
subprocess.check_call(make_argv(m, avconv, i, source, o, destination))
except subprocess.CalledProcessError as e:
raise SystemExit("Worker avconv process exited with nonzero return code: %i\nCommand was: %s\nAborting." % (e.returncode, e.cmd))
def run_multiple(m, avconv, i, sources, o, destination):
if not os.path.isdir(destination):
os.mkdir(destination)
for source in sources:
run_once(m, avconv, i, source, o, destination)
if __name__ == "__main__":
main()

@ -1,37 +0,0 @@
#!/bin/sh
# connect to the mpd httpd and open ncmpcpp
# Requirements: vlc, mpc, ncmpcpp
# Use MPD_HOST, MPD_PORT, MPD_HTTP_SINK, MPD_HTTP_PORT environment variables instead of arguments
: ${MPD_HOST:=127.0.0.1} ${MPD_PORT:=6600}
: ${MPD_HTTP_SINK:=1} ${MPD_HTTP_PORT:=8080}
export MPD_HOST
export MPD_PORT
# Find programs
mpc=`which mpc 2>/dev/null`
vlc=`which vlc 2>/dev/null`
client=`which ncmpcpp 2>/dev/null || which ncmpc 2>/dev/null`
if [ -z "$mpc" ]; then
echo "ERROR: mpc (MusicPlayerClient) not found on the system"
elif [ -z "$vlc" ]; then
echo "ERROR: VLC is required for local stream playback"
elif [ -z "$client" ]; then
echo "ERROR: No MPD client installed (ncmpcpp or ncmpc)"
else
# Enable Stream
mpc enable $MPC_HTTP_SINK
# Play Stream (have vlc on fd:3)
vlc --repeat http://$MPD_HOST:$MPD_HTTP_PORT/mpd.ogg -I dummy 2>/dev/null &
vlc_pid=$!
# Launch client in pty
"$client" -h $MPD_HOST -p $MPD_PORT
# Stop stream playback
kill $vlc_pid
fi

@ -65,7 +65,7 @@ function gupf {
#
# rsync
#
alias rsync="rsync -aXzPvihs -e ssh"
alias rsync="rsync -aXzzPvihs -e ssh"
#
@ -93,6 +93,11 @@ if (( $+commands[busybox] )); then
done
fi
#
# Misc.
#
alias lns="ln -sr"
#
# Local overrides

Loading…
Cancel
Save