More scripts..

master
Taeyeon Mori 9 years ago
parent 0be9347fd3
commit bb560c9e93
  1. 51
      bin/alsapiswitch
  2. 65
      bin/aur.sh
  3. 14
      bin/debug_gamelaunch
  4. 133
      bin/fileinterp.py
  5. 3
      bin/fix-steam-runtime.sh
  6. 6
      bin/paloop
  7. 42
      bin/syncfat
  8. 8
      bin/xconv
  9. 2
      dotfiles/makepkg.conf
  10. 6
      dotfiles/xprofile
  11. 3
      lib/libsh-utils.sh
  12. 4
      lib/python/advancedav.py

@ -0,0 +1,51 @@
#!/usr/bin/python
# (c) 2015 Taeyeon Mori
# Easily toggle the IEC958 In Phase Inverse of an ALSA card
# Useful for looping back audio from a PS3 through a CMedia card with IEC958-In
from PyQt5 import QtCore, QtGui, QtWidgets
import subprocess
import sys
class MainWindow(QtWidgets.QMainWindow):
amixer_args = ("-c", "2")
def __init__(self, parent=None):
super().__init__(parent)
self.l = QtWidgets.QHBoxLayout()
self.label = QtWidgets.QLabel()
self.label.setObjectName("MainWindow.label")
self.l.addWidget(self.label)
self.button = QtWidgets.QPushButton("Toggle")
self.button.setObjectName("MainWindow.button")
self.button.clicked.connect(self.on_button_clicked)
self.l.addWidget(self.button)
self.cw = QtWidgets.QWidget()
self.cw.setLayout(self.l)
self.setCentralWidget(self.cw)
self.sc = QtWidgets.QShortcut(QtGui.QKeySequence("t"), self)
self.sc.activated.connect(self.on_button_clicked)
self.get_state()
def call(self, *args):
return subprocess.check_output(("amixer",) + self.amixer_args + args).decode("utf-8")
def get_state(self):
self.label.setText(self.call("sget", "IEC958 In Phase Inverse"))
def on_button_clicked(self):
self.label.setText(self.call("sset", "IEC958 In Phase Inverse", "toggle"))
app = QtWidgets.QApplication(sys.argv)
win = MainWindow()
win.show()
app.exec()

@ -1,4 +1,5 @@
#!/bin/zsh
# (c) 2014-2015 Taeyeon Mori
# vim: ft=sh:ts=2:sw=2:et
# Load libraries and configuraion
@ -16,15 +17,60 @@ build="${BUILDDIR:-$tmpbuild}"
test -d "$build" || mkdir -p "$build" || exit 1
# Parse commandline: anything prefixed with - is a makepkg option
packages=(${@##-*})
makepkg_flags=(${@##[^\-]*})
packages=()
flags=()
aur_get=aur_get_old # new one not working yet
DL_ONLY=false
if echo "${makepkg_flags[*]}" | grep -q "\\-X"; then
warn "[AUR] Building was disabled (-X)"
DL_ONLY=true
else
DL_ONLY=false
fi
for cx in "$@"; do
case "$cx" in
--old-aur)
warn "[AUR] Using old AUR (--old-aur)"
aur_get=aur_get_old;;
-X|--download-only)
warn "[AUR] Building was disabled (-X)"
DL_ONLY=true;;
-h|--help)
echo "Usage $0 [-h] [-X] [makepkg options] <packages>"
echo
echo "aur.sh options:"
echo " -h, --help Display this message"
echo " -X, --download-only"
echo " Only download the PKGBUILDs from AUR, don't build"
echo " --old-aur Use the old (non-git) AUR"
echo
echo "Useful makepkg options:"
echo " -i Install package after building it"
echo " -s Install dependencies from official repos"
;;
-*)
makepkg_flags=("${makepkg_flags[@]}" "$cx");;
*)
packages=("${packages[@]}" "$cx");;
esac
done
# aur functions
aur_get_old() {
[ -d "$1/.git" ] && error "Local copy of $1 is from AUR4. Cannot use --old-aur with it!" && return 32
curl https://aur.archlinux.org/packages/${1:0:2}/$1/$1.tar.gz | tar xz
}
aur_get_aur4() {
if [ -d "$1/.git" ]; then (
cd "$1"
git pull
) else
if [ -e "$1" ]; then
warn "$1 PKGBUILD directory exists but is not a git clone."
ans=n
ask "Overwrite $1?" ans
[ "$ans" = "y" ] || [ "$ans" = "yes" ] || [ "$ans" = "Y" ] || return 32
rm -rf $1
fi
git clone https://aur4.archlinux.org/$1.git/
fi
}
# Print some info
msg "[AUR] AURDIR=$AURDIR; PKGDEST=$PKGDEST"
@ -44,8 +90,7 @@ for p in "${packages[@]}"; do
grep -q "#CUSTOMPKG" $p/PKGBUILD && \
warn "[AUR] $p: Found #CUSTOMPKG; not updating PKGBUILD from AUR!" \
} || \
{ curl https://aur.archlinux.org/packages/${p:0:2}/$p/$p.tar.gz | tar xz } || \
throw 2 "[AUR] $p: Couldn't download package"
$aur_get $p || throw 2 "[AUR] $p: Couldn't download package"
if $DL_ONLY; then continue; fi

@ -0,0 +1,14 @@
#!/bin/zsh
# Use "debug_gamelaunch %command%" in Steam SET LAUNCH OPTIONS
GAME_ARGV=("$@")
GAME_PATH="$1"
shift
GAME_ARGS=("$@")
echo -e "\033[33mGame path: $GAME_PATH\nGame arguments: $GAME_ARGS\nSee variables \$GAME_ARGV \$GAME_PATH \$GAME_ARGS\033[0m"
export GAME_ARGV GAME_PATH GAME_ARGS
export PROMPT="steam:%d> "
exec /bin/zsh -i

@ -0,0 +1,133 @@
#!/usr/bin/python
# (c) 2015 Taeyeon Mori
# execute a python file as if the lines were entered into an interactive prompt
import sys
import io
import code
try:
import pygments, pygments.lexers, pygments.formatters
except:
hl = None
else:
pyg_lex = pygments.lexers.PythonLexer()
pyg_fmt = pygments.formatters.Terminal256Formatter()
def hl(code):
return pygments.highlight(code, pyg_lex, pyg_fmt)
class IOIPythonPrefix:
def __init__(self, init=1):
self.count = init
self.ctx = ""
self.__enter__()
def inc(self, by=1):
self.count += by
def __call__(self, ctx):
self.ctx = ctx
return self
def __enter__(self):
self.prefix = "%s\033[0m[\033[31m%2d\033[0m] " % (self.ctx, self.count)
def __exit__(self, *a):
pass
class IOPrefixWrapper:
def __init__(self, parent, pfx):
self.parent = parent
self.prefix = pfx
self.nl = True
def write(self, text):
lines = text.splitlines(True)
if lines:
if self.nl:
self.parent.write(self.prefix.prefix)
self.parent.write(lines[0])
for line in lines[1:]:
self.parent.write(self.prefix.prefix)
self.parent.write(line)
self.nl = lines[-1].endswith("\n")
def flush(self):
return self.parent.flush()
xcount = IOIPythonPrefix()
sys.stdout = IOPrefixWrapper(sys.stdout, xcount)
interp = code.InteractiveInterpreter()
def print_in_x(cmd_lines):
with xcount("\033[34mIn "):
print(">>>", cmd_lines[0], end="")
for line in cmd_lines[1:]:
print("...", line, end="")
def print_in_hl(cmd_lines):
print_in_x(hl("".join(cmd_lines)).splitlines(True))
if hl:
print_in = print_in_hl
else:
print_in = print_in_x
def compile_lines(lines):
return code.compile_command("".join(lines))
def isindent(c):
return c in " \t"
with open(sys.argv[1]) as f:
ln = 0
peekbuf = []
def readline():
global ln, peekbuf
ln += 1
if peekbuf:
l = peekbuf.pop(0)
else:
l = f.readline()
if not l:
raise SystemExit()
return l
def peekline(n=0):
global peekbuf
while len(peekbuf) <= n:
peekbuf.append(f.readline())
return peekbuf[n]
def peekindent():
i = 0
while not peekline(i).strip():
i += 1
return isindent(peekline(i)[0])
while True:
cmd_lines = [readline()]
c = compile_lines(cmd_lines)
if not c:
while not c:
cmd_lines.append(readline())
while peekindent():
cmd_lines.append(readline())
c = compile_lines(cmd_lines)
print_in(cmd_lines)
with xcount("\033[33mOut"):
interp.runcode(c)
#sys.stdout.parent.write("\n")
xcount.inc()

@ -1 +1,2 @@
find "$HOME/.steam/root/" ( -name libgcc_s.so* -o -name libstdc++.so* -o -name libxcb.so* ) -print -delete
#!/bin/sh
find "$HOME/.steam/root/" \( -name libgcc_s.so* -o -name libstdc++.so* -o -name libxcb.so* \) -print -delete

@ -0,0 +1,6 @@
#!/bin/sh
# Create a playback loop from source $1 to the default sink
test -n "$1" && loopdev="-d $1"
test -n "$2" && rate="$2" || rate="44100"
pacat -r $loopdev --rate 44100 --passthrough --client-name "paloop" | pacat -p --rate "$rate" --raw --latency-msec=1 --client-name "paloop"

@ -0,0 +1,42 @@
#!/bin/zsh
# (c) 2015 Taeyeon Mori
# Sync files while making sure to replace characters invalid on FAT
# Hidden files (.*) are ignored
# Useful for copying music to a music player or smartphone sd-card
source "$DOTFILES/lib/libzsh-utils.zsh"
if [[ -z "$1" || -z "$2" || "$1" == "--help" || "$1" == "-h" || "$1" == "help" ]]; then
echo "Usage: $0 <source_dir> <dest_dir> [cp-opts]"
exit 1
fi
set -e
destination=`realpath "$2"`
cd "$1"
IFS=$'\0'
function sanitize {
local temp
temp="${*#./}" # Remove ./
echo ${temp//[:?<>*|^]/_} # Replace invalid characters
}
msg "Creating structure..."
for dir in $(find . -not -path "*/.*" -type d -print0); do
target="$destination/$(sanitize $dir/)"
test -d "$target" || mkdir "$target"
done
msg "Copying files..."
for source in $(find . -not -path "*/.*" -type f -print0); do
target="$destination/$(sanitize $source)"
if [[ ! -e "$target" || "$target" -ot "$source" || $(stat -c%s "$source") -ne $(stat -c%s "$target") ]]; then
color 31 cp $3 "$source" "$target"
elif [[ "$3" =~ "-v" ]]; then
color 33 echo "OK $target"
fi
done

@ -29,6 +29,7 @@ from argparse import ArgumentParser
from abc import ABCMeta, abstractmethod
from itertools import chain
from os.path import isdir, join as build_path, basename, splitext, exists
from os import environ
# == Profile Decorators ==
profiles = {}
@ -48,16 +49,21 @@ def output(container="matroska", ext="mkv"):
# == Profile definitions ==
keepres = bool(environ.get("XCONV_KEEPRES", None))
@profile
@output(container="matroska", ext="mkv")
def laptop(task):
# enable experimental aac codec
task.options["strict"] = "-2"
print(list(task.iter_video_streams()), list(task.iter_audio_streams()), list(task.iter_subtitle_streams()))
# add first video stream
for s in task.iter_video_streams():
print(s, s.codec)
os = task.map_stream(s)
os.options["codec"] = "libx264"
os.options["vf"] = "scale='if(gt(a,16/10),1280,-1)':'if(gt(a,16/10),-1,800)'" # scale to 1280x800, keeping the aspect ratio
if not keepres:
os.options["vf"] = "scale='if(gt(a,16/10),1280,-1)':'if(gt(a,16/10),-1,800)'" # scale to 1280x800, keeping the aspect ratio
os.options["tune"] = "fastdecode", "animation"
os.options["profile"] = "main"
os.options["preset"] = "fast"

@ -15,7 +15,7 @@ CFLAGS="`fix_march $CFLAGS`"
CXXFLAGS="`fix_march $CXXFLAGS`"
LDFLAGS="$LDFLAGS"
#MAKEFLAGS="-j`grep "cpu cores" /proc/cpuinfo | cut -d: -f2`"
#MAKEFLAGS="-j`grep "cpu cores" /proc/cpuinfo | cut -d: -f2 | tail -1`"
MAKEFLAGS="-j6"
# Store stuff

@ -0,0 +1,6 @@
#!/bin/sh
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

@ -14,8 +14,9 @@ color() {
local COLOR=$1 && shift
echo -en "\e[${COLOR}m"
"$@"
local res=$?
echo -en "\e[0m"
return $?
return $res
}
# Append to array

@ -240,8 +240,8 @@ class InputFile(File):
# -- Probe streams
_reg_probe_streams = re.compile(
r"Stream #0:(?P<id>\d+)(?:\((?P<lang>\w+)\))?: (?P<type>\w+): (?P<codec>\w+)"
r"(?: \((?P<profile>[^\)]+)\))?(?P<extra>.+)?"
r"Stream #0:(?P<id>\d+)(?:\((?P<lang>[^\)]+)\))?: (?P<type>\w+): (?P<codec>\w+)"
r"(?: \((?P<profile>[^\)]+)\))?\s*(?P<extra>.+)?"
)
def _initialize_streams(self, probe: str=None) -> Iterator:

Loading…
Cancel
Save