parent
0be9347fd3
commit
bb560c9e93
12 changed files with 321 additions and 16 deletions
@ -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() |
||||
|
@ -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 |
||||
|
@ -0,0 +1,6 @@ |
||||
#!/bin/sh |
||||
|
||||
export GTK_IM_MODULE=fcitx |
||||
export QT_IM_MODULE=fcitx |
||||
export XMODIFIERS=@im=fcitx |
||||
|
Loading…
Reference in new issue