Add ~/bin

This commit is contained in:
frankdelange 2022-06-26 20:20:31 +02:00
parent 49133cc8a6
commit ecd79740fd
199 changed files with 22598 additions and 0 deletions

BIN
bin/.make_web_videos.swp Normal file

Binary file not shown.

Binary file not shown.

BIN
bin/.sketchup.swo Normal file

Binary file not shown.

BIN
bin/.swallow_gimp.swp Normal file

Binary file not shown.

BIN
bin/.www.unternet.org.swp Normal file

Binary file not shown.

1
bin/1 Normal file
View file

@ -0,0 +1 @@
0

1
bin/2 Normal file
View file

@ -0,0 +1 @@
0

236
bin/2048.sh Normal file
View file

@ -0,0 +1,236 @@
#!/bin/bash
#important variables
declare -ia board # array that keeps track of game status
declare -i pieces # number of pieces present on board
declare -i flag_skip # flag that prevents doing more than one operation on
# single field in one step
declare -i moves # stores number of possible moves to determine if player lost
# the game
declare ESC=$'\e' # escape byte
declare header="Bash 2048 v1.0 RC1 (bugs: https://github.com/mydzor/bash2048/issues)"
#default config
declare -i board_size=4
declare -i target=2048
# print currect status of the game, last added pieces are marked red
function print_board {
clear
echo $header pieces=$pieces target=$target
echo
printf '/------'
for l in $(seq 1 $index_max); do
printf '|------'
done
printf '\\\n'
for l in $(seq 0 $index_max); do
printf '| '
for m in $(seq 0 $index_max); do
if let ${board[l*$board_size+m]}; then
if let '(last_added==(l*board_size+m))|(first_round==(l*board_size+m))'; then
printf '\033[1m\033[31m%4d \033[0m| ' ${board[l*$board_size+m]}
else
printf '%4d | ' ${board[l*$board_size+m]}
fi
else
printf ' | '
fi
done
let l==$index_max || {
printf '\n|------'
for l in $(seq 1 $index_max); do
printf '|------'
done
printf '|\n'
}
done
printf '\n\\------'
for l in $(seq 1 $index_max); do
printf '|------'
done
printf '/\n'
}
# Generate new piece on the board
# inputs:
# $board - original state of the game board
# $pieces - original number of pieces
# outputs:
# $board - new state of the game board
# $pieces - new number of pieces
function generate_piece {
while true; do
let pos=RANDOM%fields_total
let board[$pos] || {
let value=RANDOM%10?2:4
board[$pos]=$value
last_added=$pos
break;
}
done
let pieces++
}
# perform push operation between two pieces
# inputs:
# $1 - push position, for horizontal push this is row, for vertical column
# $2 - recipient piece, this will hold result if moving or joining
# $3 - originator piece, after moving or joining this will be left empty
# $4 - direction of push, can be either "up", "down", "left" or "right"
# $5 - if anything is passed, do not perform the push, only update number
# of valid moves
# $board - original state of the game board
# outputs:
# $change - indicates if the board was changed this round
# $flag_skip - indicates that recipient piece cannot be modified further
# $board - new state of the game board
function push_pieces {
case $4 in
"up")
let "first=$2*$board_size+$1"
let "second=($2+$3)*$board_size+$1"
;;
"down")
let "first=(index_max-$2)*$board_size+$1"
let "second=(index_max-$2-$3)*$board_size+$1"
;;
"left")
let "first=$1*$board_size+$2"
let "second=$1*$board_size+($2+$3)"
;;
"right")
let "first=$1*$board_size+(index_max-$2)"
let "second=$1*$board_size+(index_max-$2-$3)"
;;
esac
let ${board[$first]} || {
let ${board[$second]} && {
if test -z $5; then
board[$first]=${board[$second]}
let board[$second]=0
let change=1
else
let moves++
fi
return
}
return
}
let ${board[$second]} && let flag_skip=1
let "${board[$first]}==${board[second]}" && {
if test -z $5; then
let board[$first]*=2
let "board[$first]==$target" && end_game 1
let board[$second]=0
let pieces-=1
let change=1
else
let moves++
fi
}
}
function apply_push {
for i in $(seq 0 $index_max); do
for j in $(seq 0 $index_max); do
flag_skip=0
let increment_max=index_max-j
for k in $(seq 1 $increment_max); do
let flag_skip && break
push_pieces $i $j $k $1 $2
done
done
done
}
function check_moves {
let moves=0
apply_push up fake
apply_push down fake
apply_push left fake
apply_push right fake
}
function key_react {
let change=0
read -d '' -sn 1
test "$REPLY" = "$ESC" && {
read -d '' -sn 1 -t1
test "$REPLY" = "[" && {
read -d '' -sn 1 -t1
case $REPLY in
A) apply_push up;;
B) apply_push down;;
C) apply_push right;;
D) apply_push left;;
esac
}
}
}
function end_game {
print_board
echo GAME OVER
let $1 && {
echo "Congratulations you have achieved $target"
exit 0
}
echo "You have lost, better luck next time."
exit 0
}
function help {
cat <<END_HELP
Usage: $1 [-b INTEGER] [-t INTEGER] [-h]
-b specify game board size (sizes 3-9 allowed)
-t specify target score to win (needs to be power of 2)
-h this help
END_HELP
}
#parse commandline options
while getopts "b:t:h" opt; do
case $opt in
b ) board_size="$OPTARG"
let '(board_size>=3)&(board_size<=9)' || {
echo "Invalid board size, please choose size between 3 and 9"
exit -1
};;
t ) target="$OPTARG"
echo "obase=2;$target" | bc | grep -e '^1[^1]*$'
let $? && {
echo "Invalid target, has to be power of two"
exit -1
};;
h ) help $0
exit 0;;
\?) echo "Invalid option: -"$OPTARG", try $0 -h" >&2
exit 1;;
: ) echo "Option -"$OPTARG" requires an argument, try $0 -h" >&2
exit 1;;
esac
done
#init board
let fields_total=board_size*board_size
let index_max=board_size-1
for i in $(seq 0 $fields_total); do board[$i]="0"; done
let pieces=0
generate_piece
first_round=$last_added
generate_piece
while true; do
print_board
key_react
let change && generate_piece
first_round=-1
let pieces==fields_total && {
check_moves
let moves==0 && end_game 0 #lose the game
}
done

407
bin/a2dp.py Normal file
View file

@ -0,0 +1,407 @@
#! /usr/bin/env python3
"""Fixing bluetooth stereo headphone/headset problem in debian distros.
Workaround for bug: https://bugs.launchpad.net/ubuntu/+source/indicator-sound/+bug/1577197
Run it with python3.5 or higher after pairing/connecting the bluetooth stereo headphone.
This will be only fixes the bluez5 problem mentioned above .
Licence: Freeware
Install with:
curl "https://gist.githubusercontent.com/pylover/d68be364adac5f946887b85e6ed6e7ae/raw/install.sh" | sh
Shorthands:
$ alias speakers="a2dp.py 10:08:C1:44:AE:BC"
$ alias headphones="a2dp.py 00:22:37:3D:DA:50"
$ alias headset="a2dp.py 00:22:37:F8:A0:77 -p hsp"
$ speakers
See ``a2dp.py -h`` for help.
Check here for updates: https://gist.github.com/pylover/d68be364adac5f946887b85e6ed6e7ae
Thanks to:
* https://github.com/DominicWatson, for adding the ``-p/--profile`` argument.
* https://github.com/IzzySoft, for mentioning wait before connecting again.
* https://github.com/AmploDev, for v0.4.0
* https://github.com/Mihara, for autodetect & autorun service
* https://github.com/dabrovnijk, for systemd service
Change Log
----------
- 0.6.2
* Fix program name inside the help message.
- 0.6.1
* Fix Py warning
- 0.6.0
* Install script
- 0.5.2
* Increasing the number of tries to 15.
- 0.5.2
* Optimizing waits.
- 0.5.1
* Increasing WAIT_TIME and TRIES
- 0.5.0
* Autodetect & autorun service
- 0.4.1
* Sorting device list
- 0.4.0
* Adding ignore_fail argument by @AmploDev.
* Sending all available streams into selected sink, after successfull connection by @AmploDev.
- 0.3.3
* Updating default sink before turning to ``off`` profile.
- 0.3.2
* Waiting a bit: ``-w/--wait`` before connecting again.
- 0.3.0
* Adding -p / --profile option for using the same script to switch between headset and A2DP audio profiles
- 0.2.5
* Mentioning [mac] argument.
- 0.2.4
* Removing duplicated devices in select device list.
- 0.2.3
* Matching ANSI escape characters. Tested on 16.10 & 16.04
- 0.2.2
* Some sort of code enhancements.
- 0.2.0
* Adding `-V/--version`, `-w/--wait` and `-t/--tries` CLI arguments.
- 0.1.1
* Supporting the `[NEW]` prefix for devices & controllers as advised by @wdullaer
* Drying the code.
"""
import sys
import re
import asyncio
import subprocess as sb
import argparse
__version__ = '0.6.2'
HEX_DIGIT_PATTERN = '[0-9A-F]'
HEX_BYTE_PATTERN = '%s{2}' % HEX_DIGIT_PATTERN
MAC_ADDRESS_PATTERN = ':'.join((HEX_BYTE_PATTERN, ) * 6)
DEVICE_PATTERN = re.compile('^(?:.*\s)?Device\s(?P<mac>%s)\s(?P<name>.*)' % MAC_ADDRESS_PATTERN)
CONTROLLER_PATTERN = re.compile('^(?:.*\s)?Controller\s(?P<mac>%s)\s(?P<name>.*)' % MAC_ADDRESS_PATTERN)
WAIT_TIME = 2.25
TRIES = 15
PROFILE = 'a2dp'
_profiles = {
'a2dp': 'a2dp_sink',
'hsp': 'headset_head_unit',
'off': 'off'
}
# CLI Arguments
parser = argparse.ArgumentParser()
parser.add_argument('-e', '--echo', action='store_true', default=False,
help='If given, the subprocess stdout will be also printed on stdout.')
parser.add_argument('-w', '--wait', default=WAIT_TIME, type=float,
help='The seconds to wait for subprocess output, default is: %s' % WAIT_TIME)
parser.add_argument('-t', '--tries', default=TRIES, type=int,
help='The number of tries if subprocess is failed. default is: %s' % TRIES)
parser.add_argument('-p', '--profile', default=PROFILE,
help='The profile to switch to. available options are: hsp, a2dp. default is: %s' % PROFILE)
parser.add_argument('-V', '--version', action='store_true', help='Show the version.')
parser.add_argument('mac', nargs='?', default=None)
# Exceptions
class SubprocessError(Exception):
pass
class RetryExceededError(Exception):
pass
class BluetoothctlProtocol(asyncio.SubprocessProtocol):
def __init__(self, exit_future, echo=True):
self.exit_future = exit_future
self.transport = None
self.output = None
self.echo = echo
def listen_output(self):
self.output = ''
def not_listen_output(self):
self.output = None
def pipe_data_received(self, fd, raw):
d = raw.decode()
if self.echo:
print(d, end='')
if self.output is not None:
self.output += d
def process_exited(self):
self.exit_future.set_result(True)
def connection_made(self, transport):
self.transport = transport
print('Connection MADE')
async def send_command(self, c):
stdin_transport = self.transport.get_pipe_transport(0)
# noinspection PyProtectedMember
stdin_transport._pipe.write(('%s\n' % c).encode())
async def search_in_output(self, expression, fail_expression=None):
if self.output is None:
return None
for l in self.output.splitlines():
if fail_expression and re.search(fail_expression, l, re.IGNORECASE):
raise SubprocessError('Expression "%s" failed with fail pattern: "%s"' % (l, fail_expression))
if re.search(expression, l, re.IGNORECASE):
return True
async def send_and_wait(self, cmd, wait_expression, fail_expression='fail'):
try:
self.listen_output()
await self.send_command(cmd)
while not await self.search_in_output(wait_expression.lower(), fail_expression=fail_expression):
await wait()
finally:
self.not_listen_output()
async def disconnect(self, mac):
print('Disconnecting the device.')
await self.send_and_wait('disconnect %s' % ':'.join(mac), 'Successful disconnected')
async def connect(self, mac):
print('Connecting again.')
await self.send_and_wait('connect %s' % ':'.join(mac), 'Connection successful')
async def trust(self, mac):
await self.send_and_wait('trust %s' % ':'.join(mac), 'trust succeeded')
async def quit(self):
await self.send_command('quit')
async def get_list(self, command, pattern):
result = set()
try:
self.listen_output()
await self.send_command(command)
await wait()
for l in self.output.splitlines():
m = pattern.match(l)
if m:
result.add(m.groups())
return sorted(list(result), key=lambda i: i[1])
finally:
self.not_listen_output()
async def list_devices(self):
return await self.get_list('devices', DEVICE_PATTERN)
async def list_paired_devices(self):
return await self.get_list('paired-devices', DEVICE_PATTERN)
async def list_controllers(self):
return await self.get_list('list', CONTROLLER_PATTERN)
async def select_paired_device(self):
print('Selecting device:')
devices = await self.list_paired_devices()
count = len(devices)
if count < 1:
raise SubprocessError('There is no connected device.')
elif count == 1:
return devices[0]
for i, d in enumerate(devices):
print('%d. %s %s' % (i+1, d[0], d[1]))
print('Select device[1]:')
selected = input()
return devices[0 if not selected.strip() else (int(selected) - 1)]
async def wait(delay=None):
return await asyncio.sleep(WAIT_TIME or delay)
async def execute_command(cmd, ignore_fail=False):
p = await asyncio.create_subprocess_shell(cmd, stdout=sb.PIPE, stderr=sb.PIPE)
stdout, stderr = await p.communicate()
stdout, stderr = \
stdout.decode() if stdout is not None else '', \
stderr.decode() if stderr is not None else ''
if p.returncode != 0 or stderr.strip() != '':
message = 'Command: %s failed with status: %s\nstderr: %s' % (cmd, p.returncode, stderr)
if ignore_fail:
print('Ignoring: %s' % message)
else:
raise SubprocessError(message)
return stdout
async def execute_find(cmd, pattern, tries=0, fail_safe=False):
tries = tries or TRIES
message = 'Cannot find `%s` using `%s`.' % (pattern, cmd)
retry_message = message + ' Retrying %d more times'
while True:
stdout = await execute_command(cmd)
match = re.search(pattern, stdout)
if match:
return match.group()
elif tries > 0:
await wait()
print(retry_message % tries)
tries -= 1
continue
if fail_safe:
return None
raise RetryExceededError('Retry times exceeded: %s' % message)
async def find_dev_id(mac, **kw):
return await execute_find('pactl list cards short', 'bluez_card.%s' % '_'.join(mac), **kw)
async def find_sink(mac, **kw):
return await execute_find('pacmd list-sinks', 'bluez_sink.%s' % '_'.join(mac), **kw)
async def set_profile(device_id, profile):
print('Setting the %s profile' % profile)
try:
return await execute_command('pactl set-card-profile %s %s' % (device_id, _profiles[profile]))
except KeyError:
print('Invalid profile: %s, please select one one of a2dp or hsp.' % profile, file=sys.stderr)
raise SystemExit(1)
async def set_default_sink(sink):
print('Updating default sink to %s' % sink)
return await execute_command('pacmd set-default-sink %s' % sink)
async def move_streams_to_sink(sink):
streams = await execute_command('pacmd list-sink-inputs | grep "index:"', True)
for i in streams.split():
i = ''.join(n for n in i if n.isdigit())
if i != '':
print('Moving stream %s to sink' % i)
await execute_command('pacmd move-sink-input %s %s' % (i, sink))
return sink
async def main(args):
global WAIT_TIME, TRIES
if args.version:
print(__version__)
return 0
mac = args.mac
# Hacking, Changing the constants!
WAIT_TIME = args.wait
TRIES = args.tries
exit_future = asyncio.Future()
transport, protocol = await asyncio.get_event_loop().subprocess_exec(
lambda: BluetoothctlProtocol(exit_future, echo=args.echo), 'bluetoothctl'
)
try:
if mac is None:
mac, _ = await protocol.select_paired_device()
mac = mac.split(':' if ':' in mac else '_')
print('Device MAC: %s' % ':'.join(mac))
device_id = await find_dev_id(mac, fail_safe=True)
if device_id is None:
print('It seems device: %s is not connected yet, trying to connect.' % ':'.join(mac))
await protocol.trust(mac)
await protocol.connect(mac)
device_id = await find_dev_id(mac)
sink = await find_sink(mac, fail_safe=True)
if sink is None:
await set_profile(device_id, args.profile)
sink = await find_sink(mac)
print('Device ID: %s' % device_id)
print('Sink: %s' % sink)
await set_default_sink(sink)
await wait()
await set_profile(device_id, 'off')
if args.profile == 'a2dp':
await protocol.disconnect(mac)
await wait()
await protocol.connect(mac)
device_id = await find_dev_id(mac)
print('Device ID: %s' % device_id)
await wait(2)
await set_profile(device_id, args.profile)
await set_default_sink(sink)
await move_streams_to_sink(sink)
except (SubprocessError, RetryExceededError) as ex:
print(str(ex), file=sys.stderr)
return 1
finally:
print('Exiting bluetoothctl')
await protocol.quit()
await exit_future
# Close the stdout pipe
transport.close()
if args.profile == 'a2dp':
print('"Enjoy" the HiFi stereo music :)')
else:
print('"Enjoy" your headset audio :)')
if __name__ == '__main__':
sys.exit(asyncio.get_event_loop().run_until_complete(main(parser.parse_args())))

3
bin/abb-download Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
tm -a $(abb-magnet $1)

3
bin/abb-magnet Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
echo 'magnet:?xt=urn:btih:'$1'&tr=udp%3A%2F%2Ftracker%2Eleechers-paradise%2Eorg%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce&tr=http%3A%2F%2Ftracker2.dler.org%3A80%2Fannounce'

17
bin/add-blacklist-patches Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
base=/home/frank/cyanogenmod
pushd
cd $base/frameworks/base
git pull http://review.cyanogenmod.org/CyanogenMod/android_frameworks_base refs/changes/23/45523/4
cd $base/frameworks/opt/telephony
git pull http://review.cyanogenmod.org/CyanogenMod/android_frameworks_opt_telephony refs/changes/26/45526/5
cd $base/packages/apps/Settings
git pull http://review.cyanogenmod.org/CyanogenMod/android_packages_apps_Settings refs/changes/20/45520/9
cd $base/packages/apps/Mms
git pull http://review.cyanogenmod.org/CyanogenMod/android_packages_apps_Mms refs/changes/22/45522/10
cd $base/frameworks/base
patch -p1 < /var/src/PATCHES/cyanogenmod-getuuid.patch
popd

18
bin/any2djvu Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
outfile=$1
while shift;do
echo processing $1...
infile=$1
pbmfile=$(basename $infile).pbm
djvufile=$(basename $infile).djvu
convert $infile $pbmfile
cjb2 -clean $pbmfile $djvufile
if test -f $outfile; then
djvm -i $outfile $djvufile
else
djvm -c $outfile $djvufile
fi
done

27
bin/backlight Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
root=/sys/class/backlight/radeon_bl0
control=$root/brightness
max=$(cat $root/max_brightness)
actual=$(cat $control)
min=8
step=8
bset () {
if [[ -n "$1" ]] && [[ $1 -ge $min ]] && [[ $1 -le $max ]]; then
echo $1 > $control
fi
}
case "$1" in
u|U)
bset $((actual+step))
;;
d|D)
bset $((actual-step))
;;
*)
bset "$1"
;;
esac

1521
bin/books Executable file

File diff suppressed because it is too large Load diff

1
bin/books-all Symbolic link
View file

@ -0,0 +1 @@
/home/frank/bin/books

171
bin/books_functions Normal file
View file

@ -0,0 +1,171 @@
# shellcheck shell=bash disable=SC2154
# UTITLITIES
# find tool, returns the first|one|found, exit with error message if none found
find_tool () {
IFS='|' read -ra tools <<< "$*"
found=0
for tool in "${tools[@]}"; do
if [[ -n $(which "$tool") ]]; then
found=1
break
fi
done
if [[ "$found" -eq 0 ]]; then
if [[ ${#tools[@]} -gt 1 ]]; then
exit_with_error "missing programs: $*; install at least one of these: ${tools[*]} and try again"
else
exit_with_error "missing program: $1; please install and try again"
fi
fi
echo "$tool"
}
url_available () {
url="$1"
dl_tool=$(find_tool "curl|wget")
case "$dl_tool" in
curl)
${torsocks:-} curl --output /dev/null --silent --fail -r 0-0 "$url"
;;
wget)
${torsocks:-} wget -q --spider "$url"
;;
*)
exit_with_error "unknown download tool ${dl_tool}"
;;
esac
}
add_cron_job () {
job="$*"
(crontab -l ; echo "*/1 * * * * $job") 2>/dev/null | sort | uniq | crontab -
}
# leave <br> and <pre> to enable some simple formatting tasks
strip_html () {
#echo "$*"|sed -e 's/<br>/\n/g;s/<[^>]*>//g;s/\n/<br>/g'
echo "$*"
}
is_true () {
val="${1,,}"
if [[ "${val:0:1}" == "y" || "$val" -gt 0 ]]; then
true
else
false
fi
}
# dummmy cleanup function
cleanup () {
true
}
# echo error message to stderr and terminate main
exit_with_error () {
echo -e "$(basename "$0"): $*" >&2
kill -s TERM "$TOP_PID"
}
trap_error () {
cleanup
exit 1
}
trap_clean () {
cleanup
exit
}
_log () {
msg="$*"
logdir="${XDG_STATE_HOME:-$HOME/.state}/books"
logfile=$(basename "$0").log
mkdir -p "$logdir"
echo "$(date -Iseconds): $msg" >> "$logdir/$logfile"
}
log_err () {
_log "E: $*"
}
log_warn () {
_log "W: $*"
}
log_info () {
_log "I: $*"
}
log_debug () {
_log "D: $*"
}
# DATABASE
dbx () {
db="$1"
shift
mysql=$(find_tool "mysql")
if [ $# -gt 0 ]; then
"$mysql" -N -Bsss -h "$dbhost" -P "$dbport" -u "$dbuser" "$db" -e "$*"
else
"$mysql" -N -Bsss -h "$dbhost" -P "$dbport" -u "$dbuser" "$db"
fi
}
# LOCKING
exlock () {
cmd="$1"
lockfile="/var/lock/$(basename "$0")"
lockfd=99
flock=$(find_tool "flock")
case "$cmd" in
prepare)
eval "exec $lockfd<>\"$lockfile\""
trap 'exlock nolock' EXIT
;;
now)
$flock -xn $lockfd
;;
lock)
$flock -x $lockfd
;;
shlock)
$flock -s $lockfd
;;
unlock)
$flock -u $lockfd
;;
nolock)
$flock -u $lockfd
$flock -xn $lockfd && rm -f "$lockfile"
trap_clean
;;
*)
exit_with_error "unknown lock command: $cmd"
;;
esac
}

120
bin/build-libcairo2.sh Executable file
View file

@ -0,0 +1,120 @@
#!/bin/bash
# 2011/03/08 16:28:21
#
# Copyright (C) 2010-2011 Mithat Konar
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
# Build patched libcairo packages for Debian Squeeze that enable Ubuntu-like
# font rendering.
#
# Assumes deb-src http://ftp.us.debian.org/debian/ squeeze main non-free contrib
# or similar is present in /etc/apt/sources.list
#
# Assumes you have already done
# apt-get install build-essential devscripts fakeroot
# apt-get build-dep cairo
set -e
#======================================================================#
# SET THE VERSION INFO BELOW BEFORE RUNNING SCRIPT!!!
#
UBUNTU_VERSION="1.8.10-2ubuntu1" # From http://packages.ubuntu.com/lucid/libcairo2 (e.g., "1.8.10-2ubuntu1");
# should match the version at http://packages.debian.org/squeeze/libcairo2
# You may need to look in http://archive.ubuntu.com/ubuntu/pool/main/c/cairo/
# to resolve inconsistencies.
YOUR_INITIALS="fdl" # from birth or marriage :-) no spaces allowed
#======================================================================#
###
### constanty things
###
UBUNTU_REP=http://archive.ubuntu.com/ubuntu/pool/main/c/cairo
UBUNTU_PATCH=cairo_${UBUNTU_VERSION}.debian.tar.gz
ARCH_REP=http://aur.archlinux.org/packages/cairo-ubuntu/
ARCH_PATCH=cairo-ubuntu.tar.gz
###
### GO!
###
### dir names
root_dir=`pwd`
top_dir="${root_dir}/libcairo2"
deb_sources="${top_dir}/deb-sources"
downloaded_patches="${top_dir}/downloaded-patches"
### make room
mkdir "$top_dir"
mkdir "$deb_sources"
mkdir "$downloaded_patches"
### get patches
cd "$downloaded_patches"
wget ${UBUNTU_REP}/${UBUNTU_PATCH}
wget ${ARCH_REP}/${ARCH_PATCH}
tar xzvf ${UBUNTU_PATCH}
tar xzvf ${ARCH_PATCH}
### get sources
cd "$deb_sources"
apt-get source cairo
cd ./cairo-*
### copy the patches
cp "${downloaded_patches}/cairo-ubuntu/cairo-respect-fontconfig.patch" ./debian/patches/
cp "${downloaded_patches}/debian/patches/04_lcd_filter.patch" ./debian/patches/
cp "${downloaded_patches}/debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch" ./debian/patches/
### apply patches
patch -p1 -i ./debian/patches/cairo-respect-fontconfig.patch
patch -p1 -i ./debian/patches/04_lcd_filter.patch
patch -p1 -i ./debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch
### modify the changelog, add version info
echo ""
echo "********************************"
echo -e "In the editor that appears next, add something like the following\n\
text after the first asterisk (*):\n\
'David Turner's ClearType-like LCD filtering patch and fix.'\n\
Then save and exit the editor."
echo ""
read -p "Press <enter> to continue..."
dch -l $YOUR_INITIALS
### build it
dpkg-buildpackage -rfakeroot -us -uc
### finito
# tell user what to do next
echo ""
echo "********************************"
echo "* DONE with compiling!"
echo "********************************"
echo -e "If all went well, you should have a bunch of new packages inside \n\
$deb_sources\n\
\n\
List of *.deb files in $deb_sources:"
cd $deb_sources
ls *.deb
echo -e "\nInstall all of them by changing into \n\
$deb_sources\n\
and do (as root):\n\
dpkg -i *.deb"

37
bin/camera_import Executable file
View file

@ -0,0 +1,37 @@
#!/bin/sh
destination="/net/media/photos/import/$(date +'%Y-%m-%d')"
mountpoint="/home/frank/cam"
#camera="/dev/disk/by-label/WB2000-F"
camera="/dev/disk/by-uuid/F84E-1690"
store="DCIM"
camera_id=SAMSUNG_WB2000-frank
# volume_id=$(blkid -o value -s UUID ${camera})
seen="/net/media/photos/import/SEEN/${camera_id}"
temp=$(mktemp -d)
current="${temp}/${camera_id}"
#fusermount -u "${mountpoint}"
#fusefat -o ro "${camera}" "${mountpoint}"
sudo umount "${mountpoint}"
sudo mount -o ro,uid=1000 "${camera}" "${mountpoint}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(cd ${mountpoint}/${store} && find . -type f|sed -e 's/^\.\///'|sort) > ${current}
for f in $(diff -u ${seen} ${current}|grep '^+[^+]'|sed -e 's/^+//'); do
cp "${mountpoint}"/"${store}"/"${f}" "${destination}"
echo $f >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
# ls "${mountpoint}"/"${store}"|while read f; do echo -n "."; cp "${mountpoint}"/"${store}"/"${f}" "${destination}"; done; echo " "
#fusermount -u "${mountpoint}"
sudo umount "${mountpoint}"

30
bin/camera_import-canon Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
destination="/net/media/photos/import/$(date +'%Y-%m-%d')"
mountpoint="/home/frank/cam"
camera="/dev/sdb1"
store="store_00010001/DCIM"
camera_id=CANON-G12-frank
# volume_id=$(blkid -o value -s UUID ${camera})
seen="/net/media/photos/import/SEEN/${camera_id}"
temp=$(mktemp -d)
current="${temp}/${camera_id}"
gphotofs "${mountpoint}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(cd ${mountpoint}/${store} && find . -type f|sed -e 's/^\.\///'|sort) > ${current}
for f in $(diff -u ${seen} ${current}|grep '^+[^+]'|sed -e 's/^+//'); do
cp "${mountpoint}"/"${store}"/"${f}" "${destination}"
echo $f >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
fusermount -u "${mountpoint}"

30
bin/camera_import-ellen Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
destination="/net/behemoth/photos/import/$(date +'%Y-%m-%d')"
mountpoint="/home/frank/cam"
camera="/dev/sdb1"
store="store_00010001/DCIM"
camera_id=CANON-A460-ellen
# volume_id=$(blkid -o value -s UUID ${camera})
seen="/net/behemoth/photos/import/SEEN/${camera_id}"
temp=$(mktemp -d)
current="${temp}/${camera_id}"
gphotofs "${mountpoint}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(cd ${mountpoint}/${store} && find . -type f|sed -e 's/^\.\///'|sort) > ${current}
for f in $(diff -u ${seen} ${current}|grep '^+[^+]'|sed -e 's/^+//'); do
cp "${mountpoint}"/"${store}"/"${f}" "${destination}"
echo $f >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
fusermount -u "${mountpoint}"

23
bin/clipplayer Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
clip=$(xclip -o -selection clipboard)
options=
player="-p mplayer"
case "$clip" in
*youtube*|*youtu\.be*)
link="https://youtu.be/${clip:(-11)}"
;;
*svtplay.se*)
// options += " --hls-live-edge 10 --hls-segment-threads 2"
link="$clip"
;;
*disq.us*)
link=$(urldecode "$clip")
;;
esac
if [[ -n "$link" ]]; then
streamlink "$player" --stream-sorting-excludes '>360p,>medium' $options "$link" best
fi

1
bin/clp Symbolic link
View file

@ -0,0 +1 @@
clipplayer

3
bin/compositor_toggle Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
if [ "$(gconftool -g /apps/metacity/general/compositing_manager)" = "true" ]; then gconftool --type bool -s /apps/metacity/general/compositing_manager 0; else gconftool --type bool -s /apps/metacity/general/compositing_manager 1; fi

5
bin/connect Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
sudo iwconfig wlan2 essid wireless.unternet.org
sudo ifconfig wlan2 up
sudo dhclient wlan2

11
bin/countdown Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
#
# a simple countdown timer
if [ $1 -gt 0 ]; then
for n in $(seq $1 -1 1); do
espeak $n
sleep 0.35
done
espeak ${2:-"go"}
fi

17
bin/cpflash Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
if [ x"$1" == "x" ]; then
ls -l /proc/$(ps aux|grep plugin|grep flash|grep -v grep|awk '{print $2}')/fd
else
if [ x"$2" == "x" ]; then
echo "use: $0 file-descriptor destination"
exit
fi
cp /proc/$(ps aux|grep plugin|grep flash|grep -v grep|awk '{print $2}')/fd/$1 $2
fi

2
bin/ddc-brightness Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
ddcutil --model='W240D DVI' setvcp 10 "$1" &

29
bin/ddc-daylight Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
# Usage: ddc-daylight night
case "$1" in
"day" )
BRIGHTNESS=100
TEMPERATURE=0x09
;;
"evening" | "morning" )
BRIGHTNESS=60
TEMPERATURE=0x06
;;
"night" )
BRIGHTNESS=30
TEMPERATURE=0x04
;;
"dark" )
BRIGHTNESS=0
TEMPERATURE=0x04
;;
* )
echo "Unknown time of day '$1'"
exit 1
;;
esac
ddcutil --bus=1 setvcp 10 $BRIGHTNESS &
ddcutil --bus=1 setvcp 14 $TEMPERATURE &
wait

4
bin/disable_pa Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
sudo mv /etc/pulse/default.pa /etc/pulse/default.pa.disabled
pulseaudio --kill

8
bin/drop_caches Normal file
View file

@ -0,0 +1,8 @@
# To free pagecache
echo 1 > /proc/sys/vm/drop_caches
# To free dentries and inodes
echo 2 > /proc/sys/vm/drop_caches
# To free pagecache, dentries and inodes
echo 3 > /proc/sys/vm/drop_caches

7
bin/ds Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
#
# ds - dirsize - show size of current dir only
if test "$1x" = "x";then dir=".";else dir="$1";fi
s=0;c=0;for x in $(ls $dir -al|awk '{print $5}');do s=$[$s + $x];c=$[$c + 1];done;echo $c $s

622
bin/ee.pl Executable file
View file

@ -0,0 +1,622 @@
#!/usr/bin/perl
#
# applicaton/x-external-editor
# reference implementation of the helper application
#
# written by Erik Möller - public domain
#
# User documentation: http://meta.wikimedia.org/wiki/Help:External_editors
# Technical documentation: http://meta.wikimedia.org/wiki/Help:External_editors/Tech
#
# To do: Edit conflicts
#
use Config::IniFiles; # Module for config files in .ini syntax
use LWP::UserAgent; # Web agent module for retrieving and posting HTTP data
use URI::Escape; # Urlencode functions
use Gtk2 '-init'; # Graphical user interface, requires GTK2 libraries
use Encode qw(encode); # UTF-8/iso8859-1 encoding
use HTML::Entities; # Encode or decode strings with HTML entities
# Load interface messages
initmsg();
# By default, config will be searched for in your Unix home directory
# (e.g. ~/.ee-helper/ee.ini). Change path of the configuration file if needed!
#
# Under Windows, set to something like
# $cfgfile='c:\ee\ee.ini';
# (note single quotes!)
$cfgfile=$ENV{HOME}."/.ee-helper/ee.ini";
$cfgfile=getunixpath($cfgfile);
$DEBUG=0;
$NOGUIERRORS=0;
$LANGUAGE="en";
# Read config
my $cfg = new Config::IniFiles( -file => $cfgfile ) or vdie (_("noinifile",$cfgfile));
# Treat spaces as part of input filename
my $args=join(" ",@ARGV);
# Where do we store our files?
my $tempdir=$cfg->val("Settings","Temp Path") or vdie (_("notemppath",$cfgfile));
# Remove slash at the end of the directory name, if existing
$/="/";
chomp($tempdir);
$/="\\";
chomp($tempdir);
my $unixtempdir=getunixpath($tempdir);
if($DEBUG) {
# Make a copy of the control (input) file in the log
open(DEBUGLOG,">$unixtempdir/debug.log");
open(INPUT,"<$args");
$/=undef; # slurp mode
while(<INPUT>) {
$inputfile=$_;
}
print DEBUGLOG $inputfile;
close(INPUT);
}
# Read the control file
if(-e $args) {
$input = new Config::IniFiles( -file => $args );
} else {
vdie (_("nocontrolfile"));
}
# Initialize the browser as Firefox 1.0 with new cookie jar
$browser=LWP::UserAgent->new();
$browser->cookie_jar( {} );
@ns_headers = (
'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20041107 Firefox/1.0',
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, image/png, */*',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Language' => 'en-US',
);
# Obtain parameters from control file
$special=$input->val("Process","Special namespace");
$fileurl=$input->val("File","URL");
$type=$input->val("Process","Type");
$script=$input->val("Process","Script");
$server=$input->val("Process","Server");
$path=$input->val("Process","Path");
$login_url=$script."?title=$special:Userlogin&action=submitlogin";
$ext=$input->val("File","Extension");
if($special eq "") { $special="Special"; };
# Edit file: change an image, sound etc. in an external app
# Edit text: change a regular text file
# In both cases, we need to construct the relevant URLs
# to fetch and post the data.
if($type eq "Edit file") {
$filename=substr($fileurl,rindex($fileurl,"/")+1);
# Image: is canonical namespace name, should always work
$view_url=$script."?title=Image:$filename";
$upload_url=$script."?title=$special:Upload";
} elsif($type eq "Edit text") {
$fileurl=~m|\?title=(.*?)\&action=|i;
$pagetitle=$1;
$filename=uri_unescape($pagetitle);
# substitute illegal or special characters
$filename =~ s/:/__/g; # : - illegal on Windows
$filename =~ s|/|__|g; # / - path character under Unix and others
# potential shell metacharacters:
$filename =~ s/[\[\]\{\}\(\)~!#\$\^\&\*;'"<>\?]/__/g;
$filename=$filename.".wiki";
$edit_url=$script."?title=$pagetitle&action=submit";
$view_url=$script."?title=$pagetitle";
} elsif($type eq "Diff text") {
$secondurl=$input->val("File 2","URL");
if(!$secondurl) {
vdie (_("twofordiff"));
}
$diffcommand=$cfg->val("Settings","Diff");
if(!$diffcommand) {
vdie (_("nodifftool"));
}
} else {
# Nothing we know!
vdie (_("unknownprocess"));
}
# Obtain settings from config file
$previewclient=$cfg->val("Settings","Browser");
$browseaftersave=$cfg->val("Settings","Browse after save");
# The config file can contain definitions for any number
# of site. Each one of them should have an "URL match", which is
# a simple string expression that needs to be part of the
# URL in the control file in order for it to be recognized
# as that site. Using this methodology, we can define usernames
# and passwords for sites relatively easily.
#
# Here we try to match the URL in the control file against the
# URL matches in all sections to determine the username and
# password.
#
@sections=$cfg->Sections();
foreach $section(@sections) {
if($search=$cfg->val($section,"URL match")) {
if(index($fileurl,$search)>=0) {
$username=$cfg->val($section,"Username");
$password=$cfg->val($section,"Password");
$auth_server=$cfg->val("${section}:HTTPAuth","Server");
$auth_realm=$cfg->val("${section}:HTTPAuth","Realm");
$auth_username=$cfg->val("${section}:HTTPAuth","Username");
$auth_password=$cfg->val("${section}:HTTPAuth","Password");
}
}
}
# Log into server
# Note that we also log in for diffs, as the raw text might only be available
# to logged in users (depending on the wiki security settings), and we may want
# to offer GUI-based rollback functionality later
if( $auth_username ne "" ) {
$browser->credentials(
$auth_server,
$auth_realm,
$auth_username => $auth_password
);
}
$response=$browser->post($login_url,@ns_headers,
Content=>[wpName=>$username,wpPassword=>$password,wpRemember=>"1",wpLoginAttempt=>"Log in"]);
# We expect a redirect after successful login
if($response->code!=302 && !$ignore_login_error) {
vdie (_("loginfailed",$login_url,$username,$password));
}
$response=$browser->get($fileurl,@ns_headers);
if($type eq "Edit file") {
open(OUTPUT,">$unixtempdir/".$filename);
binmode(OUTPUT);
select OUTPUT; $|=1; select STDOUT;
print OUTPUT $response->content;
close(OUTPUT);
}elsif($type eq "Edit text") {
# Do we need to convert UTF-8 into ISO 8859-1?
if($cfg->val("Settings","Transcode UTF-8") eq "true") {
$transcode=1;
}
# MediaWiki 1.4+ uses edit tokens, we need to get one
# before we can submit edits. So instead of action=raw, we use
# action=edit, and get the token as well as the text of the page
# we want to edit in one go.
$ct=$response->header('Content-Type');
$editpage=$response->content;
$editpage=~m|<input type='hidden' value="(.*?)" name="wpEditToken" />|i;
$token=$1;
$editpage=~m|<textarea.*?name="wpTextbox1".*?>(.*?)</textarea>|is;
$text=$1;
$editpage=~m|<input type='hidden' value="(.*?)" name="wpEdittime" />|i;
$time=$1;
# Do we need to convert ..?
if($ct=~m/charset=utf-8/i) {
$is_utf8=1;
}
# ..if so, do it.
if($is_utf8 && $transcode) {
Encode::from_to($text,'utf8','iso-8859-1');
}
# decode HTML entities
HTML::Entities::decode($text);
# Flush the raw text of the page to the disk
open(OUTPUT,">$unixtempdir/".$filename);
select OUTPUT; $|=1; select STDOUT;
print OUTPUT $text;
close(OUTPUT);
}
# Search for extension-associated application
@extensionlists=$cfg->Parameters("Editors");
foreach $extensionlist(@extensionlists) {
@exts=split(",",$extensionlist);
foreach $extensionfromlist(@exts) {
if ($extensionfromlist eq $ext) {
$app=$cfg->val("Editors",$extensionlist);
}
}
}
# In most cases, we'll want to run the GUI for managing saves & previews,
# and run the external editor application.
if($type ne "Diff text") {
if($^O eq "MSWin32") {
$appstring="$app $tempdir\\$filename";
} else {
$appstring="$app $tempdir/$filename";
}
$cid=fork();
if(!$cid) {
exec($appstring);
}
makegui();
} else {
# For external diffs, we need to create two temporary files.
$response1=$browser->get($fileurl,@ns_headers);
$response2=$browser->get($secondurl,@ns_headers);
open(DIFF1, ">$unixtempdir/diff-1.txt");
select DIFF1; $|=1; select STDOUT;
open(DIFF2, ">$unixtempdir/diff-2.txt");
select DIFF2; $|=1; select STDOUT;
print DIFF1 $response1->content;
print DIFF2 $response2->content;
close(DIFF1);
close(DIFF2);
if($^O eq "MSWin32") {
$appstring="$diffcommand $tempdir\\diff-1.txt $tempdir\\diff-2.txt";
} else {
$appstring="$diffcommand $tempdir/diff-1.txt $tempdir/diff-2.txt";
}
system($appstring);
}
# Create the GTK2 graphical user interface
# It should look like this:
# _______________________________________________
# | Summary: ____________________________________ |
# | |
# | [Save] [Save & Cont.] [Preview] [Cancel] |
# |_______________________________________________|
#
# Save: Send data to the server and quit ee.pl
# Save & cont.: Send data to the server, keep GUI open for future saves
# Preview: Create local preview file and view it in the browser (for text)
# Cancel: Quit ee.pl
#
sub makegui {
$title_label = Gtk2::Label->new($filename);
$vbox = Gtk2::VBox->new;
$hbox = Gtk2::HBox->new;
$label = Gtk2::Label->new(_("summary"));
$entry = Gtk2::Entry->new;
$hbox->pack_start_defaults($label);
$hbox->pack_start_defaults($entry);
$hbox2 = Gtk2::HBox->new;
$savebutton = Gtk2::Button->new(_("save"));
$savecontbutton = Gtk2::Button->new(_("savecont"));
$previewbutton = Gtk2::Button->new(_("preview"));
$cancelbutton = Gtk2::Button->new(_("cancel"));
$hbox2->pack_start_defaults($savebutton);
$hbox2->pack_start_defaults($savecontbutton);
$hbox2->pack_start_defaults($previewbutton);
$hbox2->pack_start_defaults($cancelbutton);
$vbox->pack_start_defaults($title_label);
$vbox->pack_start_defaults($hbox);
$vbox->pack_start_defaults($hbox2);
if($type ne "Edit file") {
$hbox3 = Gtk2::HBox->new;
$minoreditcheck = Gtk2::CheckButton->new_with_label(_("minoredit"));
$watchcheck = Gtk2::CheckButton->new_with_label(_("watchpage"));
$hbox3->pack_start_defaults($minoreditcheck);
$hbox3->pack_start_defaults($watchcheck);
$vbox->pack_start_defaults($hbox3);
if ($cfg->val("Settings","Minor edit default") =~ m/^(?:true|1)$/i) {
$minoreditcheck->set_active(1);
}
if ($cfg->val("Settings","Watch default") =~ m/^(?:true|1)$/i) {
$watchcheck->set_active(1);
}
}
# Set up window
$window = Gtk2::Window->new;
$window->set_title (_("entersummary"));
$window->signal_connect (delete_event => sub {Gtk2->main_quit});
$savebutton->signal_connect (clicked => \&save);
$savecontbutton->signal_connect ( clicked => \&savecont);
$previewbutton->signal_connect ( clicked => \&preview);
$cancelbutton->signal_connect (clicked => \&cancel);
if($type ne "Edit file") {
$minoreditcheck->get_active();
$watchcheck->get_active();
}
# Add vbox to window
$window->add($vbox);
$window->show_all;
Gtk2->main;
}
# Just let save function know that it shouldn't quit
sub savecont {
save("continue");
}
# Just let save function know that it shouldn't save
sub preview {
$preview=1;
save("continue");
}
sub save {
my $cont=shift;
my $summary=$entry->get_text();
my ($minorvar, $watchvar);
if($type ne "Edit file") {
$minorvar=$minoreditcheck->get_active();
$watchvar=$watchcheck->get_active();
}
# Spam the summary if room is available :-)
if(length($summary)<190) {
my $tosummary=_("usingexternal");
if(length($summary)>0) {
$tosummary=" [".$tosummary."]";
}
$summary.=$tosummary;
}
if($is_utf8) {
$summary=Encode::encode('utf8',$summary);
}
# Upload file back to the server and load URL in browser
if($type eq "Edit file") {
print $upload_url;
$response=$browser->post($upload_url,
@ns_headers,Content_Type=>'form-data',Content=>
[
wpUploadFile=>["$unixtempdir/".$filename],
wpUploadDescription=>$summary,
wpUploadAffirm=>"1",
wpUpload=>"Upload file",
wpIgnoreWarning=>"1"
]);
if($browseaftersave eq "true" && $previewclient && !$preview) {
$previewclient=~s/\$url/$view_url/i;
system(qq|$previewclient|);
$previewclient=$cfg->val("Settings","Browser");
}
# Save text back to the server & load in browser
} elsif($type eq "Edit text") {
open(TEXT,"<$unixtempdir/".$filename);
$/=undef;
while(<TEXT>) {
$text=$_;
}
close(TEXT);
if($is_utf8 && $transcode) {
Encode::from_to( $text, 'iso-8859-1','utf8');
}
@content = (
Content=>[
wpTextbox1=>$text,
wpSummary=>$summary,
wpEdittime=>$time,
wpEditToken=>$token]
);
$watchvar && push @{$content[1]}, (wpWatchthis=>"1");
$minorvar && push @{$content[1]}, (wpMinoredit=>"1");
$preview && push @{$content[1]}, (wpPreview=>"true");
if($preview) {
$response=$browser->post($edit_url,@ns_headers,
@content);
open(PREVIEW,">$unixtempdir/preview.html");
$preview=$response->content;
# Replace relative URLs with absolute ones
$preview=~s|<head>|<head>\n <base href="$server$path">|gi;
print PREVIEW $preview;
close(PREVIEW);
if($previewclient) {
$previewurl="file://$unixtempdir/preview.html";
$previewclient=~s/\$url/$previewurl/i;
system(qq|$previewclient|);
$previewclient=$cfg->val("Settings","Browser");
}
} else {
$response=$browser->post($edit_url,@ns_headers,@content);
}
if($browseaftersave eq "true" && $previewclient && !$preview) {
$previewclient=~s/\$url/$view_url/i;
system(qq|$previewclient|);
$previewclient=$cfg->val("Settings","Browser");
}
$preview=0;
}
if($cont ne "continue") {
Gtk2->main_quit;
exit 0;
}
}
sub cancel {
Gtk2->main_quit;
}
sub _{
my $message=shift;
@subst=@_;
my $suffix;
if($LANGUAGE ne "en") { $suffix = "_".$LANGUAGE; }
$msg=$messages{$message.$suffix};
foreach $substi(@subst) {
$msg=~s/____/$substi/s;
}
return $msg;
}
sub vdie {
my $errortext=shift;
if(!$NOGUIERRORS) {
errorbox($errortext);
}
die($errortext);
}
sub errorbox {
my $errortext=shift;
my $dialog = Gtk2::MessageDialog->new ($window,
[qw/modal destroy-with-parent/],
'error',
'ok',
$errortext);
$dialog->run;
$dialog->destroy;
}
sub getunixpath {
my $getpath=shift;
if($^O eq 'MSWin32') {
$getpath=~s|\\|/|gi;
}
return $getpath;
}
sub initmsg {
%messages=(
noinifile=>
"____ could not be found.
Please move the configuration file (ee.ini) there, or edit ee.pl
and point the variable \$cfgfile to the proper location.",
noinifile_de=>
"____ konnte nicht gefunden werden.
Bitte verschieben Sie die Konfigurations-Datei (ee.ini) dorthin,
oder bearbeiten Sie ee.pl und zeigen Sie die Variable \$cfgfile
auf die korrekte Datei.",
notemppath=>
"No path for temporary files specified. Please edit ____
and add an entry like this:
[Settings]
Temp Path=/tmp\n",
notemppath_de=>
"Kein Pfad für temporäre Dateien festgelegt.
Bitte bearbeiten Sie ____
und fügen Sie einen Eintrag wie folgt ein:
[Settings]
Temp Path=/tmp\n",
nocontrolfile=>
"No control file specified.
Syntax: perl ee.pl <control file>\n",
nocontrolfile_de=>
"Keine Kontrolldatei angegeben.
Syntax: perl ee.pl <Kontrolldatei>\n",
twofordiff=>
"Process is diff, but no second URL contained in control file\n",
twofordiff_de=>
"Dateien sollen verglichen werden, Kontrolldatei enthält aber nur eine URL.",
nodifftool=>
"Process is diff, but ee.ini does not contain a 'Diff=' definition line
in the [Settings] section where the diff tool is defined.\n",
nodifftool_de=>
"Dateien sollen verglichen werden, ee.ini enthält aber keine
'Diff='-Zeile im Abschnitt Settings, in der das Diff-Werkzeug
definiert wird.\n",
unknownprocess=>
"The process type defined in the input file (Type= in the [Process] section)
is not known to this implementation of the External Editor interface. Perhaps
you need to upgrade to a newer version?\n",
unknownprocess_de=>
"Der in der Kontrolldatei definierte Prozesstyp (Type= im Abschnitt [Process])
ist dieser Implementierung des application/x-external-editor-Interface nicht
bekannt. Vielleicht müssen Sie Ihre Version des Skripts aktualisieren.\n",
loginfailed=>
"Could not login to
____
with username '____' and password '____'.
Make sure you have a definition for this website in your ee.ini, and that
the 'URL match=' part of the site definition contains a string that is part
of the URL above.\n",
loginfailed_de=>
"Anmeldung bei
____
gescheitert. Benutzername: ____ Passwort: ____
Stellen Sie sicher, dass Ihre ee.ini eine Definition für diese Website
enthält, und in der 'URL match='-Zeile ein Text steht, der Bestandteil der
obigen URL ist.\n",
summary=>
"Summary",
summary_de=>
"Zusammenfassung",
save=>
"Save",
save_de=>
"Speichern",
savecont=>
"Save and continue",
savecont_de=>
"Speichern und weiter",
preview=>
"Preview",
preview_de=>
"Vorschau",
cancel=>
"Cancel",
cancel_de=>
"Abbruch",
entersummary=>
"Enter edit summary",
entersummary_de=>
"Zusammenfassung eingeben",
minoredit=>
"Check as minor edit",
minoredit_de=>
"Kleine Änderung",
watchpage=>
"Watch this page",
watchpage_de=>
"Seite beobachten",
usingexternal=>
"using [[Help:External editors|an external editor]]",
usingexternal_de=>
"mit [[Hilfe:Externe Editoren|externem Editor]]",
);
}

4
bin/enable_pa Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
sudo mv /etc/pulse/default.pa.disabled /etc/pulse/default.pa
pulseaudio --start

8
bin/escape Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/perl
use URI::Escape;
while (<STDIN>) {
chomp;
print uri_escape($_, "^A-Za-z0-9\-_.!~*()/:") . "\n";
}

71
bin/extract_uImage.sh Executable file
View file

@ -0,0 +1,71 @@
#!/bin/sh
#
# Copyright (C) 2010 Matthias Buecher (http://www.maddes.net/)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/gpl-2.0.txt
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
UIMAGE=$1
# check for uImage magic word
# http://git.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=include/image.h
echo 'Checking for uImage magic word...'
MAGIC=`dd if="${UIMAGE}" ibs=4 count=1 | hexdump -v -e '1/1 "%02X"'`
[ '27051956' != "${MAGIC}" ] && { echo 'Not an uImage.' ; exit 1 ; }
# extract data from uImage
echo 'uImage recognized.'
echo 'Extracting data...'
DATAFILE='uImage.data'
dd if="${UIMAGE}" of="${DATAFILE}" ibs=64 skip=1
# check for ARM mach type ( xx 1C A0 E3 xx 10 81 E3 )
# http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html#d0e600
echo 'Checking for ARM mach-type...'
MAGIC=`dd if="${DATAFILE}" ibs=1 skip=1 count=3 | hexdump -v -e '1/1 "%02X"'`
[ '1CA0E3' = "${MAGIC}" ] && {
MAGIC=`dd if="${DATAFILE}" ibs=1 skip=5 count=3 | hexdump -v -e '1/1 "%02X"'`
[ '1081E3' = "${MAGIC}" ] && {
echo 'ARM mach-type header recognized.'
echo 'Extracting mach-type header...'
dd if="${DATAFILE}" of="uImage.mach-type" ibs=8 count=1
ARCH=$(hexdump -v -e '1/1 "%02X "' uImage.mach-type); echo "The mach-type is: $ARCH"
echo 'Stripping mach-type header...'
TMPFILE='uImage.tmp'
dd if="${DATAFILE}" of="${TMPFILE}" ibs=8 skip=1
rm -f "${DATAFILE}"
mv "${TMPFILE}" "${DATAFILE}"
}
}
# check for zImage, otherwise assume Image
# http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html#d0e309
TMPFILE='Image'
echo 'Checking for zImage...'
MAGIC=`dd if="${DATAFILE}" ibs=4 skip=9 count=1 | hexdump -v -e '1/1 "%02X"'`
[ '18286F01' = "${MAGIC}" ] && {
START=`dd if="${DATAFILE}" ibs=4 skip=10 count=1 | hexdump -v -e '1/4 "%08X"'`
END=`dd if="${DATAFILE}" ibs=4 skip=11 count=1 | hexdump -v -e '1/4 "%08X"'`
#
SIZE=$(( 0x${END} - 0x${START} ))
#
echo "zImage recognized with start 0x${START}, end 0x${END} and size ${SIZE}."
TMPFILE='zImage'
}
mv "${DATAFILE}" "${TMPFILE}"
echo ">>> ${UIMAGE} extracted to ${TMPFILE}"

28
bin/fanspeed Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
fan=/sys/module/fan/drivers/platform\:acpi-fan
range=($(ls $fan|grep PNP|cut -d: -f2))
pnp=$(ls $fan|grep PNP|head -1|cut -d: -f1)
last=$((${#range[@]}-1))
file=thermal_cooling/cur_state
if [ -n "$1" ]; then
if [ "$1" == "off" ]; then
for n in ${range[@]}; do echo 0 > "${fan}/$pnp:$n/$file"; done
elif [ "$1" == "range" ]; then
seq -s ' ' 0 $last
elif [ "$1" == "-h" ]; then
echo "$0 "'[range|off|<speed>]'
elif [ -n ${range[$1]} ]; then
for n in ${range[@]}; do echo 0 > "${fan}/$pnp:$n/$file"; done
echo 1 > "${fan}/$pnp:${range[$1]}/$file"
fi
else
for n in $(seq 0 $last); do
s=$(cat "${fan}/$pnp:${range[$n]}/$file")
if [ $s -gt 0 ]; then
echo -n "$n "
fi
done
echo
fi

1
bin/fiction Symbolic link
View file

@ -0,0 +1 @@
/home/frank/bin/books

7
bin/file_change_monitor Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
[ "$1x" = "x" ] && exit 1
while : ; do mv -f /tmp/fcm-1 /tmp/fcm-2; cp $1 /tmp/fcm-1; diff -U 0 /tmp/fcm-1 /tmp/fcm-2; sleep 1; done

16
bin/floatube Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
# This came from Greg V's dotfiles:
# https://github.com/myfreeweb/dotfiles
# Feel free to steal it, but attribution is nice
if [ "$1" == "start" ]; then
sleep 0.3
#xvkbd -text "\Cl\Cc" # For some reason this doesn't work with xdotool
sleep 0.1
#bspc rule -a mpv -o floating=on sticky=on
mpv $MPV_HWDEC_FLAGS "https://www.youtube.com/embed/`xclip -o | sed -E -e "s/.*v=([^&]+).*/\1/"`" &
sleep 1
xdotool search --class mpv windowsize 1280 720
elif [ "$1" == "toggleopacity" ]; then
transset -t -i "`xdotool search --class mpv`" 0.1
fi

4
bin/ftp_print Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
pdftops -duplex $1 /tmp/out.ps
lftp -c "open -u frank,frank printer; cd PORT1; put /tmp/out.ps"

18
bin/fwdecrypt.pl Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/perl
my $fw;
my $b;
my @fwarray;
(my $n, my $rest) = @ARGV;
while (<STDIN>) {
$fw .= $_;
}
@_=unpack("C*", $fw);
#shift;$_ += 0; print chr(($_ + $n) % 255) for @_;
shift;$_ += 0; print pack('C', $_ + $n % 255) for @_;

9330
bin/get_iplayer Executable file

File diff suppressed because it is too large Load diff

10
bin/git-mkpatches Executable file
View file

@ -0,0 +1,10 @@
#/bin/sh
mkdir patches/
count="1"
for i in $(git-rev-list HEAD ^ORIG_HEAD | tac)
do
git-diff-tree --pretty -p ${i} > patches/$count.diff
count=$(($count + 1))
done

151
bin/gnome-panel-config Executable file
View file

@ -0,0 +1,151 @@
#!/bin/sh
##!/bin/bash
# gnome-panel-config - add/remove panels, applets and objects
# under script control, makes handling gconf slightly less tedious...
#
# Copyright (C) 2008 Frank de Lange <gnome-f@unternet.org>
# licensed under the GNU General Public License v3 or later
# defaults and settings
tool=gconftool-2
root=/apps/panel
applets=/general/applet_id_list
panels=/general/toplevel_id_list
objects=/general/object_id_list
current_applets=$($tool --get $root$applets|sed -e 's#^\[##;s#\]$##')
current_panels=$($tool --get $root$panels|sed -e 's#^\[##;s#\]$##')
current_objects=$($tool --get $root$objects|sed -e 's#^\[##;s#\]$##')
help () {
cat<<-"END"
gnome-panel-config adds/removes panels, applets and objects
-l list panels, applets and objects
-p <name> add panel <name>
-a <name> add applet <name>
-o <name> add object <name>
-P <name> remove panel <name>
-A <name> remove applet <name>
-O <name> remove object <name>
-c <config> configure element using <config>
<config> is a comma-separated string of
gconf types,keys and values. Leave out the
leading '/apps/panel' from the key string:
[list-]type,key,value
examples:
disable animations:
gnome-panel-config -c "boolean,/global/enable_animations,false"
create a vertical panel on the left side:
gnome-panel-config -p left -c "string,/toplevels/left/orientation,left"
delete that panel:
gnome-panel-config -P left
disable some applets globally:
gnome-panel-config -c "list-string,/global/disabled_applets,\
OAFIID:GNOME_SomeApplet,OAFIID:GNOME_SomeOtherApplet"
END
exit
}
list () {
echo "panels: $current_panels"
echo "applets: $current_applets"
echo "objects: $current_objects"
}
add () {
echo $1${1:+,}$2
}
remove () {
echo $1|sed -e "s#,*$2##g"
}
config () {
type=$(echo $1|cut -d ',' -f 1)
key=$(echo $1|cut -d ',' -f 2)
value=$(echo $*|cut -d ',' -f 3-)
IFS= list_type=$(echo $type|cut -d '-' -f 2 -s)
if [ "x$list_type" = "x" ]; then
$tool --set --type=$type $root$key $value
else
$tool --set --type=list --list-type=$list_type $root$key '['$value']'
fi
}
add_panel () {
new_panels=$(add $current_panels $1)
current_panels=$new_panels
config list-string,$panels,$current_panels
}
remove_panel () {
new_panels=$(remove $current_panels $1)
current_panels=$new_panels
config list-string,$panels,$current_panels
}
add_applet () {
new_applets=$(add $current_applets $1)
current_applets=$new_applets
config list-string,$applets,$current_applets
}
remove_applet () {
new_applets=$(remove $current_applets $1)
current_applets=$new_applets
config list-string,$applets,$current_applets
}
add_object () {
new_objects=$(add $current_objects $1)
current_objects=$new_objects
config list-string,$objects,$current_objects
}
remove_object () {
new_objects=$(remove $current_objects $1)
current_objects=$new_objects
config list-string,$objects,$current_objects
}
while getopts "hp:a:P:A:c:l" OPTION
do
case $OPTION in
h)
help
;;
p)
add_panel $OPTARG
;;
a)
add_applet $OPTARG
;;
P)
remove_panel $OPTARG
;;
A)
remove_applet $OPTARG
;;
o)
add_object $OPTARG
;;
O)
remove_object $OPTARG
;;
c)
config $OPTARG
;;
l)
list
;;
esac
done

151
bin/gnome-panel-config.sh Executable file
View file

@ -0,0 +1,151 @@
#!/bin/sh
##!/bin/bash
# gnome-panel-config - add/remove panels, applets and objects
# under script control, makes handling gconf slightly less tedious...
#
# Copyright (C) 2008 Frank de Lange <gnome-f@unternet.org>
# licensed under the GNU General Public License v3 or later
# defaults and settings
tool=gconftool-2
root=/apps/panel
applets=/general/applet_id_list
panels=/general/toplevel_id_list
objects=/general/object_id_list
current_applets=$($tool --get $root$applets|sed -e 's#^\[##;s#\]$##')
current_panels=$($tool --get $root$panels|sed -e 's#^\[##;s#\]$##')
current_objects=$($tool --get $root$objects|sed -e 's#^\[##;s#\]$##')
help () {
cat<<-"END"
gnome-panel-config adds/removes panels, applets and objects
-l list panels, applets and objects
-p <name> add panel <name>
-a <name> add applet <name>
-o <name> add object <name>
-P <name> remove panel <name>
-A <name> remove applet <name>
-O <name> remove object <name>
-c <config> configure element using <config>
<config> is a comma-separated string of
gconf types,keys and values. Leave out the
leading '/apps/panel' from the key string:
[list-]type,key,value
examples:
disable animations:
gnome-panel-config -c "boolean,/global/enable_animations,false"
create a vertical panel on the left side:
gnome-panel-config -p left -c "string,/toplevels/left/orientation,left"
delete that panel:
gnome-panel-config -P left
disable some applets globally:
gnome-panel-config -c "list-string,/global/disabled_applets,\
OAFIID:GNOME_SomeApplet,OAFIID:GNOME_SomeOtherApplet"
END
exit
}
list () {
echo "panels: $current_panels"
echo "applets: $current_applets"
echo "objects: $current_objects"
}
add () {
echo $1${1:+,}$2
}
remove () {
echo $1|sed -e "s#,*$2##g"
}
config () {
type=$(echo $1|cut -d ',' -f 1)
key=$(echo $1|cut -d ',' -f 2)
value=$(echo $*|cut -d ',' -f 3-)
IFS= list_type=$(echo $type|cut -d '-' -f 2 -s)
if [ "x$list_type" = "x" ]; then
$tool --set --type=$type $root$key $value
else
$tool --set --type=list --list-type=$list_type $root$key '['$value']'
fi
}
add_panel () {
new_panels=$(add $current_panels $1)
current_panels=$new_panels
config list-string,$panels,$current_panels
}
remove_panel () {
new_panels=$(remove $current_panels $1)
current_panels=$new_panels
config list-string,$panels,$current_panels
}
add_applet () {
new_applets=$(add $current_applets $1)
current_applets=$new_applets
config list-string,$applets,$current_applets
}
remove_applet () {
new_applets=$(remove $current_applets $1)
current_applets=$new_applets
config list-string,$applets,$current_applets
}
add_object () {
new_objects=$(add $current_objects $1)
current_objects=$new_objects
config list-string,$objects,$current_objects
}
remove_object () {
new_objects=$(remove $current_objects $1)
current_objects=$new_objects
config list-string,$objects,$current_objects
}
while getopts "hp:a:P:A:c:l" OPTION
do
case $OPTION in
h)
help
;;
p)
add_panel $OPTARG
;;
a)
add_applet $OPTARG
;;
P)
remove_panel $OPTARG
;;
A)
remove_applet $OPTARG
;;
o)
add_object $OPTARG
;;
O)
remove_object $OPTARG
;;
c)
config $OPTARG
;;
l)
list
;;
esac
done

14
bin/import_photos Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
destination="/net/behemoth/photos/import/$(date +'%Y-%m-%d')"
mountpoint="/home/frank/cam"
store="store_00010001/DCIM/100CANON"
fusermount -u "${mountpoint}"
gphotofs "${mountpoint}"
mkdir -p "${destination}"
ls "${mountpoint}"/"${store}"|while read f; do echo -n "."; mv "${mountpoint}"/"${store}"/"${f}" "${destination}"; done; echo " "
fusermount -u "${mountpoint}"

13
bin/index.html Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>unterNET...</title>
<link rel="stylesheet" href="css/unternet.css">
</head>
<body>
<DIV align="center" valign="middle">
<IMG SRC="pix/overload.jpg" ALT="unterNET/OVERload">
</DIV>
</body>
</html>

12
bin/info Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
for file in "$@"
do
whichfile=$(which "$file")
if [ -n "$whichfile" ]; then
ls -l "$whichfile"
file "$whichfile"
else
ls -l "$file"
fi
done

BIN
bin/install-check Executable file

Binary file not shown.

15
bin/ivona_download.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# Do not edit this file - it will be overwritten
# by server installer!
export WINEPREFIX=/home/frank/.winesapi
export WINEDEBUG=-all
export DISPLAY=:20
if ! xdpyinfo >/dev/null 2>/dev/null ; then
nohup Xvfb ${DISPLAY} -screen -0 800x600x16 -nolisten tcp &
sleep 2
fi
wine explorer /desktop=ividn,800x600 /usr/lib/sapi4linux/pydir/python.exe /usr/lib/sapi4linux/ivodownload.py $@

27
bin/jalbum_patch Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
JALBUM_ROOT=/opt/APPjalbum
SKIN_ROOT=$JALBUM_ROOT/skins/BluPlusPlus
cd $JALBUM_ROOT
tar zxf /home/frank/Patches/jalbum_flash_movie_patch.tar.gz
cat <<EOF_videos >> $SKIN_ROOT/config/supported-videos.txt
flv
EOF_videos
cat <<EOF_header >> $SKIN_ROOT/includes/common-header.inc
<ja:if exists="originalPath">
<ja:if test="<%= originalPath.endsWith(".flv") %>">
<!-- Flash Movies -->
<script language="javascript" type="text/javascript" src="\$resPath/flv_movie/swfobject.js"></script>
<script language="javascript">
function resPath1() {return "\$resPath";}
</script>
</ja:if>
</ja:if>
EOF_header

31
bin/jhbuild Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env python
import sys
import os
import __builtin__
USE_CHECKOUT_SRC = True
if USE_CHECKOUT_SRC:
sys.path.insert(0, '/home/frank/Source/jhbuild')
pkgdatadir = None
datadir = None
import jhbuild
srcdir = os.path.abspath(os.path.join(os.path.dirname(jhbuild.__file__), '..'))
else:
pkgdatadir = "@pkgdatadir@"
datadir = "@datadir@"
srcdir = "@srcdir@"
if '@pythondir@' not in sys.path:
sys.path.insert(0, '@pythondir@')
try:
import jhbuild
except ImportError:
sys.path.insert(0, srcdir)
__builtin__.__dict__['PKGDATADIR'] = pkgdatadir
__builtin__.__dict__['DATADIR'] = datadir
__builtin__.__dict__['SRCDIR'] = srcdir
import jhbuild.main
jhbuild.main.main(sys.argv[1:])

4
bin/lcd Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
xrandr --fb 1024x768
xrandr -s 0
s3switch lcd

1
bin/libgen_preview Symbolic link
View file

@ -0,0 +1 @@
/home/frank/bin/books

21
bin/lit_to_txt.pl Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/perl
while (<STDIN>) {
$in .= $_;
}
# remove unwanted content
#$in =~ s/ ?file:\/\/\/.*file:\/\/\/.*\.txt ?//g;
# remove successive empty lines
#$in =~ s/\n{2,}/\n\n/g;
# translate funny characters...
$in =~ s/[]/'/g;
$in =~ s/[]/"/g;
$in =~ s//--/g;
$in =~ s//-/g;
$in =~ s/\xA0//g;
# remove successive empty lines
$in =~ s/\n{2,}/\n\n/g;
print $in;

5
bin/load_pcie_modules Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
sudo modprobe acpiphp
sudo modprobe pci_hotplug debug_acpi=1
sudo modprobe pciehp pciehp_force=0 pciehp_debug=1

5
bin/lsflash Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
ls -l /proc/$(ps aux|grep plugin|grep flash|grep -v grep|awk '{print $2}')/fd
echo "/proc/$(ps aux|grep plugin|grep flash|grep -v grep|awk '{print $2}')/fd"

10
bin/make_flv Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# make_flv - make flash movie from any video file
#ffmpeg -i $1 -ar 22050 -ab 32 -f flv -s 320x240 $2
ffmpeg -i $1 -ar 11025 -ab 32k -acodec mp3 -b 200k -s 320x240 $2
# make thumbnail
ffmpeg -y -i $2 -vframes 1 -ss 00:00:05 -an -vcodec png -f rawvideo -s 640x480 $2.thumb
# or
# ffmpeg -i $1 -ar 22050 -ab 32 -f flv -s 320x240 - | flvtool2 -U stdin $2

108
bin/make_flv2 Executable file
View file

@ -0,0 +1,108 @@
#!/bin/bash
# make_flv - make flash movie from any video file
# tools
#MENCODER=/opt/APPmplayer/bin/mencoder
MENCODER=/usr/bin/mencoder
# defaults
extension="flv"
vcodec="flv"
suffix=""
output_dir=""
filter="scale=320:240"
thumbsize="640x480"
vbitrate=200
abitrate=32
# actions
convert () {
# convert to requested format (default: flv)
#ffmpeg -i $inputfile -ar 22050 -ab ${abitrate}k -acodec libmp3lame -b ${vbitrate}k -s 320x240 ${outputfile}
# OR mencoder:
# $MENCODER -vf ${filter} -oac mp3lame -lameopts br=${abitrate} -ovc lavc -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:autoaspect:v4mv:vmax_b_frames=0:vb_strategy=1:mbd=2:mv0:trell:cbp:sc_factor=6:cmp=2:subcmp=2:predia=2:dia=2:preme=2:turbo:acodec=mp3:abitrate=56 ${inputfile} -o ${outputfile}
$MENCODER \
${nosound} -srate 22050 \
-oac lavc -ovc lavc -of lavf \
-lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:acodec=libmp3lame:abitrate=${abitrate} \
-vf ${filter} \
${inputfile} -o ${outputfile}
# add metadata for flash video
[ "$filetype" == ".flv" ] && flvtool2 -U ${outputfile}
# make thumbnail
ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_flv video file converter (defaults to flv - flash video)"
echo " "
echo " -i file Inputfile"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: flv) ]"
echo " -c codec [ video Codec (default: flv) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: 200) ]"
echo " -a [ Audio bitrate (default: 32) ]"
echo " -A [ no sound in output video ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:A" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-flv}"
;;
c)
vcodec="${OPTARG:-flv}"
;;
L)
filter=${filter:-}${filter:+,}rotate=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}rotate=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-200}"
;;
a)
abitrate="${OPTARG:-32}"
;;
A)
nosound="-nosound "
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
echo filename: $filename
echo outputfile: $outputfile
convert
exit

21
bin/make_flv2.org Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# make_flv - make flash movie from any video file
[ $# -lt 2 ] && echo use: $0 inputfile output_dir [ suffix ] [ filetype ] && exit
inputfile=$1
output_dir=${2:-}${2:+/}
filename=$(basename $1|sed -e 's#\..*##')
suffix=${3:+-}${3:-}
filetype=.${4:-flv}
outputfile=${output_dir}${filename}${suffix}${filetype}
# convert to requested format (default: flv)
ffmpeg -i $inputfile -ar 11025 -ab 32k -acodec mp3 -b 200k -s 320x240 ${outputfile}
# OR mencoder:
# mencoder -vf dsize=-1:-1:3/4,rotate=1 -oac mp3lame -lameopts br=32 -ovc lavc -lavcopts vcodec=flv
# add metadata for flash video
[ "$filetype" == ".flv" ] && echo flvtool2 -U ${outputfile}
# make thumbnail
ffmpeg -y -i $inputfile -vframes 1 -ss 00:00:02 -an -vcodec png -f rawvideo -s 640x480 ${outputfile}.thumb

108
bin/make_flv3 Executable file
View file

@ -0,0 +1,108 @@
#!/bin/bash
# make_flv - make flash movie from any video file
# tools
#MENCODER=/opt/APPmplayer/bin/mencoder
MENCODER=/usr/bin/mencoder
# defaults
extension="flv"
vcodec="flv"
suffix=""
output_dir=""
filter="scale=320:180"
thumbsize="640x360"
vbitrate=200
abitrate=32
# actions
convert () {
# convert to requested format (default: flv)
#ffmpeg -i $inputfile -ar 22050 -ab ${abitrate}k -acodec libmp3lame -b ${vbitrate}k -s 320x240 ${outputfile}
# OR mencoder:
# $MENCODER -vf ${filter} -oac mp3lame -lameopts br=${abitrate} -ovc lavc -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:autoaspect:v4mv:vmax_b_frames=0:vb_strategy=1:mbd=2:mv0:trell:cbp:sc_factor=6:cmp=2:subcmp=2:predia=2:dia=2:preme=2:turbo:acodec=mp3:abitrate=56 ${inputfile} -o ${outputfile}
$MENCODER \
${nosound} -srate 22050 \
-oac lavc -ovc lavc -of lavf \
-lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:acodec=libmp3lame:abitrate=${abitrate} \
-vf ${filter} \
${inputfile} -o ${outputfile}
# add metadata for flash video
[ "$filetype" == ".flv" ] && flvtool2 -U ${outputfile}
# make thumbnail
ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_flv video file converter (defaults to flv - flash video)"
echo " "
echo " -i file Inputfile"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: flv) ]"
echo " -c codec [ video Codec (default: flv) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: 200) ]"
echo " -a [ Audio bitrate (default: 32) ]"
echo " -A [ no sound in output video ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:A" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-flv}"
;;
c)
vcodec="${OPTARG:-flv}"
;;
L)
filter=${filter:-}${filter:+,}rotate=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}rotate=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-200}"
;;
a)
abitrate="${OPTARG:-32}"
;;
A)
nosound="-nosound "
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
echo filename: $filename
echo outputfile: $outputfile
convert
exit

3
bin/make_flv_thumbnail Executable file
View file

@ -0,0 +1,3 @@
#!/bin/bash
ffmpeg -y -i $1 -vframes 1 -ss 00:00:05 -an -vcodec png -f rawvideo -s 640x480 $1.thumb

101
bin/make_mp4 Executable file
View file

@ -0,0 +1,101 @@
#!/bin/bash
# make_flv - make flash movie from any video file
# tools
MENCODER=/opt/APPmplayer/bin/mencoder
# defaults
extension="mp4"
vcodec="mpeg4"
suffix=""
output_dir=""
filter="dsize=320:240:0,scale=320:-2"
vbitrate=500
abitrate=32
asrate=22050
# actions
convert () {
# convert to requested format (default: flv)
ffmpeg -i $inputfile -ar ${asrate} -ab ${abitrate}k -acodec libvorbis -b ${vbitrate}k -s 320x240 ${outputfile}
#$MENCODER \
# -oac mp3lame -lameopts br=${abitrate} -srate ${asrate} \
# -ovc lavc -of lavf \
# -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate} \
# -vf ${filter} \
# ${inputfile} -o ${outputfile}
# add metadata for flash video
[ "$filetype" == ".flv" ] && flvtool2 -U ${outputfile}
# make thumbnail
# ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_mp4 video file converter (defaults to ${vcodec})"
echo " "
echo " -i file Inputfile"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: ${extension}) ]"
echo " -c codec [ video Codec (default: ${vcodec}) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: ${vbitrate}) ]"
echo " -a [ Audio bitrate (default: ${abitrate}) ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-flv}"
;;
c)
vcodec="${OPTARG:-flv}"
;;
L)
filter=${filter:-}${filter:+,}rotate=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}rotate=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-200}"
;;
a)
abitrate="${OPTARG:-32}"
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
echo filename: $filename
echo outputfile: $outputfile
convert
exit

99
bin/make_ogg Executable file
View file

@ -0,0 +1,99 @@
#!/bin/bash
# make_ogg - make ogg movie from any video file
# tools
MENCODER=/usr/bin/mencoder
# defaults
extension="ogg"
vcodec="libtheora"
acodec="vorbis"
suffix=""
output_dir=""
vfilter="scale=320:240"
afilter="channels=2"
thumbsize="640x480"
vbitrate=200
abitrate=32
# actions
convert () {
# convert to requested format (default: ogg)
ffmpeg -i ${inputfile} -b ${vbitrate}k -ab ${abitrate}k -s qvga -vcodec libtheora -acodec libvorbis ${outputfile}
# make thumbnail
ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_ogg video file converter (defaults to ogg - theora video)"
echo " "
echo " -i file Inputfile"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: ogg) ]"
echo " -c codec [ video Codec (default: vorbis) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: 200) ]"
echo " -a [ Audio bitrate (default: 32) ]"
echo " -A [ no sound in output video ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:A" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-flv}"
;;
c)
vcodec="${OPTARG:-flv}"
;;
L)
filter=${filter:-}${filter:+,}rotate=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}rotate=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-200}"
;;
a)
abitrate="${OPTARG:-32}"
;;
A)
nosound="-nosound "
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
echo filename: $filename
echo outputfile: $outputfile
convert
exit

131
bin/make_web_video Executable file
View file

@ -0,0 +1,131 @@
#!/bin/bash
# make_flv - make flash movie from any video file
# tools
#MENCODER=/opt/APPmplayer/bin/mencoder
MENCODER=/usr/bin/mencoder
#MENCODER=/usr/bin/avconv
#FFMPEG=$(which ffmpeg)
FFMPEG=$(which avconv)
# defaults
extension="mp4"
vcodec="libx264"
acodec="aac"
suffix=""
output_dir=""
geometry="1280x720"
filter="scale=1280:720"
thumbsize="640x480"
vbitrate=800k
abitrate=64k
# actions
convert () {
# convert to requested format (default: flv)
#ffmpeg -i $inputfile -ar 22050 -ab ${abitrate}k -acodec libmp3lame -b ${vbitrate}k -s 320x240 ${outputfile}
# OR mencoder:
# $MENCODER -vf ${filter} -oac mp3lame -lameopts br=${abitrate} -ovc lavc -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:autoaspect:v4mv:vmax_b_frames=0:vb_strategy=1:mbd=2:mv0:trell:cbp:sc_factor=6:cmp=2:subcmp=2:predia=2:dia=2:preme=2:turbo:acodec=mp3:abitrate=56 ${inputfile} -o ${outputfile}
$FFMPEG \
-i ${inputfile} \
${nosound} -ar 44100 \
-b:v ${vbitrate} \
-b:a ${abitrate} \
-codec:v ${vcodec} \
-codec:a ${acodec} \
${extra_options} ${outputfile}
# -s ${geometry} \
# -r ${framerate} \
# $MENCODER \
# ${nosound} -srate 22050 \
# -oac lavc -ovc lavc -of lavf \
# -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:acodec=libmp3lame:abitrate=${abitrate} \
# -vf ${filter} \
# ${inputfile} -o ${outputfile}
# add metadata for flash video
[ "$filetype" == ".flv" ] && flvtool2 -U ${outputfile}
# make thumbnail
ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_flv video file converter (defaults to flv - flash video)"
echo " "
echo " -i file Inputfile"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: ${extension}) ]"
echo " -c codec [ video Codec (default: ${vcodec}) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: ${vbitrate}) ]"
echo " -a [ Audio bitrate (default: ${abitrate}) ]"
echo " -A [ no sound in output video ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:A" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-mp4}"
;;
c)
vcodec="${OPTARG:-libx264}"
;;
L)
filter=${filter:-}${filter:+,}transpose=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}transpose=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-$vbitrate}"
;;
a)
abitrate="${OPTARG:-$abitrate}"
;;
A)
nosound="-an "
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
if [ "${vcodec}" == "libx264" ]; then
extra_options="-strict -2 "
fi
echo $extra_options
echo filename: $filename
echo outputfile: $outputfile
convert
exit

131
bin/make_web_video2 Executable file
View file

@ -0,0 +1,131 @@
#!/bin/bash
# make_flv - make flash movie from any video file
# tools
#MENCODER=/opt/APPmplayer/bin/mencoder
MENCODER=/usr/bin/mencoder
#MENCODER=/usr/bin/avconv
#FFMPEG=$(which ffmpeg)
FFMPEG=$(which avconv)
# defaults
extension="mp4"
vcodec="libx264"
acodec="aac"
suffix=""
output_dir=""
geometry="1280x720"
filter="scale=1280:720"
thumbsize="640x480"
vbitrate=800k
abitrate=64k
# actions
convert () {
# convert to requested format (default: flv)
#ffmpeg -i $inputfile -ar 22050 -ab ${abitrate}k -acodec libmp3lame -b ${vbitrate}k -s 320x240 ${outputfile}
# OR mencoder:
# $MENCODER -vf ${filter} -oac mp3lame -lameopts br=${abitrate} -ovc lavc -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:autoaspect:v4mv:vmax_b_frames=0:vb_strategy=1:mbd=2:mv0:trell:cbp:sc_factor=6:cmp=2:subcmp=2:predia=2:dia=2:preme=2:turbo:acodec=mp3:abitrate=56 ${inputfile} -o ${outputfile}
$FFMPEG \
-i ${inputfile} \
${nosound} -ar 44100 \
-vf ${filter} \
-b:v ${vbitrate} \
-b:a ${abitrate} \
-codec:v ${vcodec} \
-codec:a ${acodec} \
${extra_options} ${outputfile}
# -r ${framerate} \
# $MENCODER \
# ${nosound} -srate 22050 \
# -oac lavc -ovc lavc -of lavf \
# -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:acodec=libmp3lame:abitrate=${abitrate} \
# -vf ${filter} \
# ${inputfile} -o ${outputfile}
# add metadata for flash video
[ "$filetype" == ".flv" ] && flvtool2 -U ${outputfile}
# make thumbnail
ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_flv video file converter (defaults to flv - flash video)"
echo " "
echo " -i file Inputfile"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: ${extension}) ]"
echo " -c codec [ video Codec (default: ${vcodec}) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: ${vbitrate}) ]"
echo " -a [ Audio bitrate (default: ${abitrate}) ]"
echo " -A [ no sound in output video ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:A" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-mp4}"
;;
c)
vcodec="${OPTARG:-libx264}"
;;
L)
filter=${filter:-}${filter:+,}transpose=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}transpose=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-$vbitrate}"
;;
a)
abitrate="${OPTARG:-$abitrate}"
;;
A)
nosound="-an "
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
if [ "${vcodec}" == "libx264" ]; then
extra_options="-strict -2 "
fi
echo $extra_options
echo filename: $filename
echo outputfile: $outputfile
convert
exit

142
bin/make_web_videos Executable file
View file

@ -0,0 +1,142 @@
#!/bin/bash
# make_web_videos - make mp4/flash movies from any video file
# tools
#MENCODER=/opt/APPmplayer/bin/mencoder
MENCODER=/usr/bin/mencoder
FFMPEG=$(which ffmpeg)
# defaults
extension="mp4"
vcodec="libx264"
acodec="aac"
suffix=""
output_dir=""
geometry="1280x720"
filter="scale=1280:720"
thumbsize="640x480"
vbitrate=1000k
abitrate=64k
# profiles
declare -A profiles
profiles[low][geometry] ="320:240"
profiles[low][vcodec] ="flv"
profiles[low][acodec] ="mp3"
profiles[low][vbitrate] ="200"
profiles[low][abitrate] ="32"
echo ${profiles[low][*]}
exit
# actions
convert () {
# convert to requested format (default: flv)
#ffmpeg -i $inputfile -ar 22050 -ab ${abitrate}k -acodec libmp3lame -b ${vbitrate}k -s 320x240 ${outputfile}
# OR mencoder:
# $MENCODER -vf ${filter} -oac mp3lame -lameopts br=${abitrate} -ovc lavc -of lavf -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:autoaspect:v4mv:vmax_b_frames=0:vb_strategy=1:mbd=2:mv0:trell:cbp:sc_factor=6:cmp=2:subcmp=2:predia=2:dia=2:preme=2:turbo:acodec=mp3:abitrate=56 ${inputfile} -o ${outputfile}
$FFMPEG \
-i ${inputfile} \
${nosound} -ar 44100 \
-b:v ${vbitrate} \
-b:a ${abitrate} \
-codec:v ${vcodec} \
-codec:a ${acodec} \
${extra_options} ${outputfile}
# -s ${geometry} \
# -r ${framerate} \
# $MENCODER \
# ${nosound} -srate 22050 \
# -oac lavc -ovc lavc -of lavf \
# -lavcopts vcodec=${vcodec}:vbitrate=${vbitrate}:acodec=libmp3lame:abitrate=${abitrate} \
# -vf ${filter} \
# ${inputfile} -o ${outputfile}
# add metadata for flash video
[ "$filetype" == ".flv" ] && flvtool2 -U ${outputfile}
# make thumbnail
ffmpeg -y -i $outputfile -vframes 1 -ss 00:00:02 -an -vcodec mjpeg -f rawvideo -s ${thumbsize} ${outputfile}.thumb
}
help () {
echo " "
echo "make_flv video file converter (defaults to flv - flash video)"
echo " "
echo " -i file Inputfile"
echo " -l/m/h [ create Low (${lowres-geometry}, Medium (${medres-geometry} and/or High (${highres-geometry}) versions ]"
echo " -d dir [ outputDirectory (default: current directory) ]"
echo " -s suffix [ Suffix (default: none) ]"
echo " -x ext [ eXtension (default: ${extension}) ]"
echo " -c codec [ video Codec (default: ${vcodec}) ]"
echo " -L [ rotate video Left/counterclockwise ]"
echo " -R [ rotate video Right/clockwise ]"
echo " -v [ Video bitrate (default: ${vbitrate}) ]"
echo " -a [ Audio bitrate (default: ${abitrate}) ]"
echo " -A [ no sound in output video ]"
echo " -h this Help message"
echo " "
echo "final destination file is (outputdirectory/) (basename inputfile)(-suffix).(extension)"
}
# parameters
while getopts "hi:d:s:t:LRv:a:A" OPTION
do
case $OPTION in
h)
help
exit
;;
i)
inputfile="$OPTARG"
filename=$(basename $inputfile|sed -e 's#\..*##')
;;
d)
output_dir="${OPTARG}/"
;;
s)
suffix="-${OPTARG:-}"
;;
t)
extension="${OPTARG:-mp4}"
;;
c)
vcodec="${OPTARG:-libx264}"
;;
L)
filter=${filter:-}${filter:+,}transpose=2
thumbsize="480x640"
;;
R)
filter=${filter:-}${filter:+,}transpose=1
thumbsize="480x640"
;;
v)
vbitrate="${OPTARG:-$vbitrate}"
;;
a)
abitrate="${OPTARG:-$abitrate}"
;;
A)
nosound="-an "
;;
esac
done
# show help if called without options
[ $OPTIND = 1 ] && help && exit
outputfile=${output_dir}${filename}${suffix}.${extension}
if [ "${vcodec}" == "libx264" ]; then
extra_options="-strict -2 "
fi
echo $extra_options
echo filename: $filename
echo outputfile: $outputfile
convert
exit

180
bin/mate-term-save-colors Executable file
View file

@ -0,0 +1,180 @@
#!/bin/sh
# Copyright (C) 2013, Giorgos Keramidas <gkeramidas@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# Dump an executable form of all the mate-terminal keys associated with
# colors. Running the resulting script should restore all color-related
# state of the terminal to whatever it was at the time the script was
# created.
#
# Inspired by:
# The setup scripts of solarized theme for gnome-terminal from:
# https://github.com/sigurdga/gnome-terminal-colors-solarized
# ----- startup code ---------------------------------------------------
# Save the original program invocation name, and the real path of the
# startup directory, for later use.
progdir=$( cd $(dirname "$0") ; /bin/pwd -P )
progname=$( basename "$0" )
# ----- misc functions -------------------------------------------------
#
# err exitval message
# Display message to stderr and to the logfile, if any, and then
# exit with exitval as the return code of the script.
#
err()
{
exitval=$1
shift
log "$0: ERROR: $*"
exit $exitval
}
#
# warn message
# Display message to stderr and the log file.
#
warn()
{
log "$0: WARNING: $*"
}
#
# info message
# Display informational message to stderr and to the logfile.
#
info()
{
log "$0: INFO: $*"
}
#
# debug message
# Output message to stderr if debug_output_enabled is set to
# 'yes', 'true' or '1'. Please AVOID calling any shell subroutine
# that may recursively call debug().
#
debug()
{
case ${debug_enabled} in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
log "$0: DEBUG: $*"
;;
esac
}
#
# log message
# Print a log message to standard error. If ${LOGFILE} is set
# Output message to "${LOGFILE}" if it is set and is writable.
#
log()
{
__timestamp="`date -u '+%Y-%m-%d %H:%M:%S'`"
__msg="${__timestamp} [${progname}] -- $*"
echo >&2 "${__msg}" 2>&1
if [ -n "${LOGFILE}" ]; then
echo "${__msg}" >> "${LOGFILE}"
fi
}
# ----- main script body ------------------------------------------------
# The gconf-compatible tool to use for reading and writing gconf keys
# for the MATE desktop, and the application name under /apps/ to
# configure. These are provisionaly set to work for the MATE desktop,
# but they can also be tweaked to work for GNOME 2.X by setting:
#
# conftool='gconftool-2'
# appname='gnome-terminal'
conftool='gconftool-2'
appname='mate-terminal'
# Basic command-line sanity checking.
if test $# -ne 0 && test $# -ne 1 ; then
echo >&2 "usage: ${progname} [ PROFILE ]"
exit 1
fi
# The name of the profile we are dumping can be passed as a command line
# argument, or auto-detected by peeking at:
# '/apps/${appname}/global/default_profile'
if test $# -eq 1 ; then
profile="$1"
else
key="/apps/${appname}/global/default_profile"
profile=$( ${conftool} --get "${key}" 2>/dev/null )
if test $? -ne 0 ; then
debug "Cannot read configuration key: ${key}"
err 1 "Cannot detect default profile name."
fi
unset key
fi
# Verify that the profile we are looking for really exists, by trying to
# read at least one key from it:
# '/apps/${appname}/profiles/${profile}/foreground_color'
key="/apps/${appname}/profiles/${profile}/foreground_color"
${conftool} --get "${key}" > /dev/null 2>&1
if test $? -ne 0 ; then
debug "Cannot read configuration key: ${key}"
err 1 "Profile ${profile} cannot be found."
fi
unset key
# dumpkey TYPE KEY
# Dump a configuration key to standard output, as a shell command that
# will _set_ it to its current value, using the associated type.
dumpkey()
{
if test $# -ne 2 || test -z "$1" || test -z "$2" ; then
debug "dumpkey() requires exactly 2 non-empty arguments,"
debug "but it was invoked with:"
debug " \"$1\""
debug " \"$2\""
return 1
fi
__type="$1"
__key="$2"
__value=$( ${conftool} --get "${__key}" )
if test $? -ne 0 ; then
err 1 "Cannot read key \"${__key}\""
fi
echo "${conftool} --set --type \"${__type}\"" \
"\"${__key}\" \"${__value}\""
}
dumpkey "string" "/apps/${appname}/profiles/${profile}/background_color"
dumpkey "string" "/apps/${appname}/profiles/${profile}/bold_color"
dumpkey "bool" "/apps/${appname}/profiles/${profile}/bold_color_same_as_fg"
dumpkey "string" "/apps/${appname}/profiles/${profile}/foreground_color"
dumpkey "string" "/apps/${appname}/profiles/${profile}/palette"

30
bin/mdb-sqlite.py Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env python
#
# AccessDump.py
# A simple script to dump the contents of a Microsoft Access Database.
# It depends upon the mdbtools suite:
# http://sourceforge.net/projects/mdbtools/
import sys, subprocess, os
DATABASE = sys.argv[1]
# Dump the schema for the DB
subprocess.call(["mdb-schema", DATABASE, "mysql"])
# Get the list of table names with "mdb-tables"
table_names = subprocess.Popen(["mdb-tables", "-1", DATABASE],
stdout=subprocess.PIPE).communicate()[0]
tables = table_names.splitlines()
print "BEGIN;" # start a transaction, speeds things up when importing
sys.stdout.flush()
# Dump each table as a CSV file using "mdb-export",
# converting " " in table names to "_" for the CSV filenames.
for table in tables:
if table != '':
subprocess.call(["mdb-export", "-I", "mysql", DATABASE, table])
print "COMMIT;" # end the transaction
sys.stdout.flush()

10
bin/memuse Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
total=0
ps aux|egrep -v 'RSS|0 0'|sort -k6 -n|while read line;do
rss=$(echo "$line"|awk '{print $6}')
cmd=$(echo "$line"|awk '{print $11}')
total=$(($total+$rss));echo $total - $rss - $cmd
done

245
bin/menumaker Executable file
View file

@ -0,0 +1,245 @@
#!/usr/bin/perl -w
#
# sitemaker - create html files and nested menu based on templates and content
#
# Copyright (C) 2008 Frank de Lange
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# This program assumes that filenames are formatted as follows:
#
# category _ subcategory _ subsubcategory _ ... _ filename
#
# It then creates html in the 'site' directory based on the content
# of those files. It also creates a 'menu.html' file in this directory
# which contains a nested unordered list reflecting the hierarchy of
# the site.
#
# Currently the script handles these special tags in the input files:
#
# <title>menu title</title>
# set menu title to 'menu title'
#
# <content>.....</content>
# set page content to whatever is between these tags
#
# <extra>.....</extra>
# set extra page content to whatever is between these tags
# extra content is generally rendered in the left column but that
# can be changed by editing the site CSS.
#
# Output files get the name of the input file with the .shtml extension.
#
# Templates are stored in the 'template' directory
#
# The program orders the menu lexicografically depth-first so menus
# can be put in any order by prepending the part name with a sequence
# numbner. Like so:
#
# 1-a
# 1-a_a
# 1-a_c
# 2-c
# 3-b
# 3-b_1-f
# 3-b_2-a
# 3-b_3-g
# 3-b_4-j_a_c
# 3-b_4-j_a_f
# ...etc.
my $DEBUG=0;
use strict;
use warnings;
use HTML::Template;
use Getopt::Long;
use Data::Dumper;
my %hash;
my %OPT = ( build_menu => 0,
append_menu => 0,
build_html => 0,
target_dir => "site",
source_dir => "",
extension => ".shtml",
menu_template => "menu.tmpl",
html_template => "page.tmpl",
debug => 0
);
# subs ------------------------------------------------------------------------
# walk_tree - recursively walk over the input, creating parsed output in $aref
#
sub walk_tree {
my ($parent, $aref, $file, $name, @kids) = @_;
unless( @$aref and $aref->[-1]{name} eq $name ) {
push @{$aref}, { name => $name, title => $name, parent => $parent };
}
if( @kids ) {
if( not exists $aref->[ -1 ]{ children } ) {
$aref->[-1]{children} = [];
# copy href and title to current for orphaned parent link, then remove orphan
if (exists $aref->[-2] and exists $aref->[-2]{href} and $aref->[-2]{href} =~ /$name$OPT{extension}/) {
$aref->[-1]{href} = $aref->[-2]{href};
$aref->[-1]{title} = $aref->[-2]{title};
splice(@$aref,-2,1);
}
}
walk_tree($aref->[-1], $aref->[-1]{children}, $file, @kids );
} elsif (-f $file) {
# leaf node with accessible file: set href...
$aref->[-1]{href}="$file" . $OPT{extension};
$aref->[-1]{file}="$file";
parse_content($aref->[-1]) if ($OPT{build_html} or $OPT{build_menu});
build_html($aref->[-1]) if $OPT{build_html};
} elsif (-d $file) {
print "[warning] invalid input: $file (is a directory)\n";
} else {
print "[error] invalid input: name: $name ($file): leaf node without file?\n";
}
}
# parse_content - insert tagged content into $href, create clicktrail
#
sub parse_content {
my $href = shift;
my $input;
open(INFILE, "<$$href{file}") or die "can not open $$href{file}: $!\n";
while(<INFILE>) {
$input .= $_;
}
close INFILE;
# create clicktrail
my $ancestor = $$href{parent};
while (exists ${$ancestor}{parent}) {
if (exists ${$ancestor}{href}) {
$$href{clicktrail} = [] if not exists $$href{clicktrail};
unshift(@{$$href{clicktrail}}, { href => ${$ancestor}{href}, title => ${$ancestor}{title} });
}
$ancestor = ${$ancestor}{parent};
}
# parse input
if ($input =~ /<title>\s*(.*?)\s*<\/title>/is) {
# ... found title, replace placeholder (filename) with it
$$href{title} = $1;
}
if ($input =~ /<content>(.*)<\/content>/is) {
# ... found content...
$$href{content} = $1;
}
if ($input =~ /<extra>(.*)<\/extra>/is) {
# ... found extra content
$$href{extra} = $1;
}
}
# build_html - create the (s)html files for the content
#
sub build_html {
my $href = shift;
system("mkdir $OPT{target_dir}") if not -d $OPT{target_dir};
open(OUTFILE, ">$OPT{target_dir}$$href{href}") or die "can not open $OPT{target_dir}$$href{href}: $!\n";
my $t = HTML::Template->new (filename => "template/$OPT{html_template}", die_on_bad_params => 0);
$t->param (content => $$href{content});
$t->param (title => $$href{title});
$t->param (extra => $$href{extra}) if (exists $$href{extra});
$t->param (clicktrail => $$href{clicktrail}) if (exists $$href{clicktrail});
print OUTFILE $t->output ();
close OUTFILE;
}
# build_menu - create the menu.html file for the content
#
sub build_menu {
my ($aref, $menu_file, $menu_template) = @_;
system("mkdir -p $OPT{target_dir}include") if not -d "$OPT{target_dir}include";
open(OUTFILE, ($OPT{append_menu}) ? ">>" : ">", "$OPT{target_dir}include/$menu_file") or die "can not open $OPT{target_dir}include/$menu_file: $!\n";
my $t = HTML::Template->new (filename => "template/$menu_template", die_on_bad_params => 0);
$t->param (Parents => $aref);
# the template produces a lot of empty lines, remove these from the output...
my $clean_output = $t->output ();
$clean_output =~ s/\n\s*\n/\n/g;
print OUTFILE $clean_output;
close OUTFILE;
}
# main ---------------------------------------------------------------------
#
my @input;
my @sorted_input;
my @tree;
GetOptions("menu!" => \$OPT{build_menu},
"append_menu!" => \$OPT{append_menu},
"html!" => \$OPT{build_html},
"debug!" => \$OPT{debug},
"extension=s" => \$OPT{extension},
"target_dir=s" => \$OPT{target_dir},
"source_dir=s" => \$OPT{source_dir},
"menu_template=s" => \$OPT{menu_template},
"html_template=s" => \$OPT{html_template});
# append slash to end of source/target if needed
$OPT{target_dir} =~ s/(\S+[^\/])/$1\//;
$OPT{source_dir} =~ s/(\S+[^\/])/$1\//;
# prepend dot to extension if needed
$OPT{extension} =~ s/(^[^.]\S+)/.$1/;
# allow DEBUG to be set at runtime
$DEBUG=1 if $OPT{debug};
# append_menu sets build_menu
$OPT{build_menu}=1 if $OPT{append_menu};
if ($DEBUG) {
print "build_menu: $OPT{build_menu}\n";
print "append_menu: $OPT{append_menu}\n";
print "build_html: $OPT{build_html}\n";
print "target_dir: $OPT{target_dir}\n";
print "source_dir: $OPT{source_dir}\n";
print "menu_template: $OPT{menu_template}\n";
print "html_template: $OPT{html_template}\n";
print "extension: $OPT{extension}\n";
}
while(<STDIN>) {
chomp;
push @input,$_;
}
# depth-first sort, uses underscore as divider
#
@sorted_input = sort {
my $aa=$a;
my $bb=$b;
(($aa =~ tr/_/_/) <= ($bb =~ tr/_/_/) && lc($a) cmp lc($b)) ||
lc($a) cmp lc($b);
} @input;
foreach (@sorted_input) {
walk_tree( {}, \@tree, $_, split '_', $_ );
}
$DEBUG && print Dumper @tree;
build_menu(\@tree, "menu.html", $OPT{menu_template}) if $OPT{build_menu};

183
bin/menumaker.OK Executable file
View file

@ -0,0 +1,183 @@
#!/usr/bin/perl -w
#
# menumaker - create nested menu file from list of filenames
# This program assumes that filenames are formatted as follows:
#
# category _ subcategory _ subsubcategory _ ... _ filename.extension
#
# It then writes a nested menu structure for these files to stdout
# The program tries to get the menu title from the files by searching
# for <!-- menu_title this is the menu title -->
# If there is no such comment in the file it uses the last part
# of the filename (after the last _, full filename if no _) as title.
#
# The program orders the menu lexicografically depth-first so menus
# can be put in any order by prepending the part name with a sequence
# numbner. Like so:
#
# 1-a.shtml
# 1-a_a.shtml
# 1-a_c.shtml
# 2-c.shtml
# 3-b.shtml
# 3-b_1-f.shtml
# 3-b_2-a.shtml
# 3-b_3-g.shtml
# 3-b_4-j_a_c.shtml
# 3-b_4-j_a_f.shtml
# ...etc.
my $DEBUG=0;
use strict;
use warnings;
use HTML::Template;
if ($DEBUG) {
use Data::Dumper;
}
my %hash;
sub x {
my $parent = shift;
my $aref = shift;
my( $name, @kids ) = @_;
my $clicktrail = "";
unless( @$aref and $aref->[-1]{ name } eq $name ) {
push @{ $aref }, { name => $name, title => $name, parent => $parent };
}
if( @kids ) {
if( not exists $aref->[ -1 ]{ children } ) {
$aref->[ -1 ]{ children } = [];
# copy href and title to current for orphaned parent link, then remove orphan
if (exists $aref->[-2] and $aref->[-2]{ href } =~ /$name\.\S+/) {
$aref->[-1]{href} = $aref->[-2]{href};
$aref->[-1]{title} = $aref->[-2]{title};
splice(@$aref,-2,1);
}
}
x( $aref->[ -1 ], $aref->[ -1 ]{ children }, @kids );
} elsif (-f $_) {
# leaf node with accessible file: set href...
$aref->[-1]{href}=$_;
# create clicktrail...
my $ancestor = $parent;
while (exists ${$ancestor}{parent}) {
if (exists ${$ancestor}{href}) {
$clicktrail = " > <a href=\"${$ancestor}{href}\">${$ancestor}{title}</a>" . $clicktrail;
}
$ancestor = ${$ancestor}{parent};
}
if ($clicktrail ne "") {
open(FILE,">$_.clicktrail") or die "can not open $_.clicktrail:$!\n";
print FILE $clicktrail;
close FILE;
}
# ... and try to find menu title in file ...
open(FILE, "<$_") or die "can not open $_:$!\n";
while(<FILE>) {
chomp;
if (/\s*?<!--\s*menu_title\s*(.*?)\s*-->/i) {
# ... found title, replace placeholder (filename) with it
$aref->[-1]{title} = $1;
last;
}
}
close FILE;
} else {
print "leaf node without file?\n";
}
}
my @input;
my @sorted_input;
my @tree;
chomp() and push @input,$_ while <STDIN>;
@sorted_input = sort {
my $aa=$a;
my $bb=$b;
(($aa =~ tr/_/_/) <= ($bb =~ tr/_/_/) && lc($a) cmp lc($b)) ||
lc($a) cmp lc($b);
} @input;
foreach (@sorted_input) {
x( {}, \@tree, split '_', $_ );
}
$DEBUG && print Dumper @tree;
my $template = <<'HTML';
<TMPL_LOOP NAME="Parents">
<TMPL_UNLESS children>
<li><a<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a></li>
<TMPL_ELSE>
<li><a class="qmparent"<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a>
<ul>
<TMPL_LOOP children>
<TMPL_UNLESS children>
<li><a<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a></li>
<TMPL_ELSE>
<li><span class="qmdivider qmdividery" ></span></li>
<li><a class="qmparent"<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a>
<ul>
<TMPL_LOOP children>
<TMPL_UNLESS children>
<li><a<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a></li>
<TMPL_ELSE>
<li><span class="qmdivider qmdividery" ></span></li>
<li><a class="qmparent"<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a>
<ul>
<TMPL_LOOP children>
<TMPL_UNLESS children>
<li><a<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a></li>
<TMPL_ELSE>
<li><span class="qmdivider qmdividery" ></span></li>
<li><a class="qmparent"<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a>
<ul>
<TMPL_LOOP children>
<TMPL_UNLESS children>
<li><a<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a></li>
<TMPL_ELSE>
<li><span class="qmdivider qmdividery" ></span></li>
<li><a class="qmparent"<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a>
<ul>
<TMPL_LOOP children>
<li><a<TMPL_IF href> href="<TMPL_VAR href>"</TMPL_IF>><TMPL_VAR title></a></li>
</TMPL_LOOP>
</ul></li>
</TMPL_UNLESS>
</TMPL_LOOP>
</ul></li>
</TMPL_UNLESS>
</TMPL_LOOP>
</ul></li>
</TMPL_UNLESS>
</TMPL_LOOP>
</ul></li>
</TMPL_UNLESS>
</TMPL_LOOP>
</ul></li>
</TMPL_UNLESS>
</TMPL_LOOP>
HTML
my $t = HTML::Template->new (scalarref => \$template, die_on_bad_params => 0);
$t->param (Parents => \@tree);
# the template produces a lot of empty lines, remove these from the output...
my $clean_output = $t->output ();
$clean_output =~ s/\n\s*\n/\n/g;
print $clean_output;

183
bin/menumaker_works_but_messy Executable file
View file

@ -0,0 +1,183 @@
#!/usr/bin/perl -w
#
# sitemaker - create html files and nested menu based on templates and content
#
# Copyright (C) 2008 Frank de Lange
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# This program assumes that filenames are formatted as follows:
#
# category _ subcategory _ subsubcategory _ ... _ filename
#
# It then creates html in the 'site' directory based on the content
# of those files. It also creates a 'menu.html' file in this directory
# which contains a nested unordered list reflecting the hierarchy of
# the site.
#
# Currently the script handles these special tags in the input files:
#
# <title>menu title</title>
# set menu title to 'menu title'
#
# <content>.....</content>
# set page content to whatever is between these tags
#
# <extra>.....</extra>
# set extra page content to whatever is between these tags
# extra content is generally rendered in the left column but that
# can be changed by editing the site CSS.
#
# Output files get the name of the input file with the .shtml extension.
#
# Templates are stored in the 'template' directory
#
# The program orders the menu lexicografically depth-first so menus
# can be put in any order by prepending the part name with a sequence
# numbner. Like so:
#
# 1-a
# 1-a_a
# 1-a_c
# 2-c
# 3-b
# 3-b_1-f
# 3-b_2-a
# 3-b_3-g
# 3-b_4-j_a_c
# 3-b_4-j_a_f
# ...etc.
my $DEBUG=0;
use strict;
use warnings;
use HTML::Template;
use Getopt::Long;
if ($DEBUG) {
use Data::Dumper;
}
my %hash;
my %OPT = ( make_menu => 0,
make_html => 0,
debug => 0 );
sub x {
my $parent = shift;
my $aref = shift;
my( $name, @kids ) = @_;
unless( @$aref and $aref->[-1]{ name } eq $name ) {
push @{ $aref }, { name => $name, title => $name, parent => $parent };
}
if( @kids ) {
if( not exists $aref->[ -1 ]{ children } ) {
$aref->[ -1 ]{ children } = [];
# copy href and title to current for orphaned parent link, then remove orphan
if (exists $aref->[-2] and $aref->[-2]{ href } =~ /$name\.\S+/) {
$aref->[-1]{href} = $aref->[-2]{href};
$aref->[-1]{title} = $aref->[-2]{title};
splice(@$aref,-2,1);
}
}
x( $aref->[ -1 ], $aref->[ -1 ]{ children }, @kids );
} elsif (-f $_) {
# leaf node with accessible file: set href...
$aref->[-1]{href}="$_.shtml";
# create clicktrail...
my $ancestor = $parent;
while (exists ${$ancestor}{parent}) {
if (exists ${$ancestor}{href}) {
$aref->[-1]{clicktrail} = [] if not exists $aref->[-1]{clicktrail};
unshift(@{$aref->[-1]{clicktrail}}, { href => ${$ancestor}{href}, title => ${$ancestor}{title} });
}
$ancestor = ${$ancestor}{parent};
}
# ... and try to find menu title in file ...
system("mkdir site") if not -d "site";
open(INFILE, "<$_") or die "can not open $_:$!\n";
open(OUTFILE, ">site/$_.shtml") or die "can not open site/$_.shtml: $!\n";
my $input;
while(<INFILE>) {
$input .= $_;
}
close INFILE;
# parse input file
if ($input =~ /<title>\s*(.*?)\s*<\/title>/is) {
# ... found title, replace placeholder (filename) with it
$aref->[-1]{title} = $1;
}
if ($input =~ /<content>(.*)<\/content>/is) {
# ... found content...
$aref->[-1]{content} = $1;
}
if ($input =~ /<extra>(.*)<\/extra>/is) {
# ... found extra content
$aref->[-1]{extra} = $1;
}
# create output file
my $t = HTML::Template->new (filename => "template/adk.tmpl", die_on_bad_params => 0);
$t->param (content => $aref->[-1]{content});
$t->param (title => $aref->[-1]{title});
$t->param (extra => $aref->[-1]{extra}) if (exists $aref->[-1]{extra});
$t->param (clicktrail => $aref->[-1]{clicktrail}) if (exists $aref->[-1]{clicktrail});
print OUTFILE $t->output ();
close OUTFILE;
} else {
print "leaf node without file?\n";
}
}
my @input;
my @sorted_input;
my @tree;
GetOptions("m!"=>\$OPT{make_menu},
"h!"=>\$OPT{make_html},
"d!"=>\$OPT{debug});
print "make_menu: $OPT{make_menu}\n";
print "make_html: $OPT{make_html}\n";
print "debug: $OPT{debug}\n";
foreach (@ARGV) {
print "$_\n";
}
chomp() and push @input,$_ while <STDIN>;
@sorted_input = sort {
my $aa=$a;
my $bb=$b;
(($aa =~ tr/_/_/) <= ($bb =~ tr/_/_/) && lc($a) cmp lc($b)) ||
lc($a) cmp lc($b);
} @input;
foreach (@sorted_input) {
x( {}, \@tree, split '_', $_ );
}
$DEBUG && print Dumper @tree;
system("mkdir -p site/include") if not -d "site/include";
open(OUTFILE, ">site/include/menu.html") or die "can not open site/include/menu.html: $!\n";
my $t = HTML::Template->new (filename => "template/menu.tmpl", die_on_bad_params => 0);
$t->param (Parents => \@tree);
# the template produces a lot of empty lines, remove these from the output...
my $clean_output = $t->output ();
$clean_output =~ s/\n\s*\n/\n/g;
print OUTFILE $clean_output;
close OUTFILE;

9
bin/mirrortowindows Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/perl
#
while (<STDIN>) {
chomp;
my $input = $_;
my $output = sprintf("%s",`iconv -f UTF-8 -t WINDOWS-1251 $_`);
print "in: $input\nout:$output\n";
}

15
bin/mmsdl Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
prefix=mms://publicims.groovygecko.net/publicims/council/beva/
status=130
until [ $status == 0 ]; do
mimms -r ${prefix}${1}
status=$?
echo download terminated with status $status...
sleep 5
done
echo download should be complete...

16
bin/mmsdl-part Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
prefix=mms://publicims.groovygecko.net/publicims/council/beva/
status=130
limit=1
until [ $status == 0 ]; do
mimms -t ${limit} -r ${prefix}${1}
status=$?
echo download terminated with status $status...
sleep 5
done
echo download should be complete...

16
bin/mmsdl-part2 Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
prefix=mms://publicims.groovygecko.net/publicims/council/beva/
status=130
limit=2
until [ $status == 0 ]; do
mimms -t ${limit} -r ${prefix}${1}
status=$?
echo download terminated with status $status...
sleep 5
done
echo download should be complete...

21
bin/monitor Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
monitor=DVI-0
bright=1
dim=0.5
case $0 in
monitor-bright)
xrandr --output $monitor --brightness $bright
exit
;;
monitor-dim)
xrandr --output $monitor --brightness $dim
exit
;;
*)
xrandr --output $monitor --brightness $1
exit
;;
esac

83
bin/mp3l Executable file
View file

@ -0,0 +1,83 @@
#!/bin/sh
# mp3l - lookup songs in music database
host=behemoth.unternet.org
database=george
dba="mysql -h $host $database"
query () {
[ -n "$artist" ] && what=artist.artist
[ -n "$album" ] && what=${what:-}${what:+,}album.title
[ -n "$song" ] && what=${what:-}${what:+,}song.title
[ -n "$carrier" ] && what=${what:-}${what:+,}carrier.carriername
[ -n "$artist" ] && from=artist
[ -n "$album" ] && from=${from:-}${from:+,}album
[ -n "$song" ] && from=${from:-}${from:+,}song
[ -n "$carrier" ] && from=${from:-}${from:+,}carrier
[ -n "$artist" ] && where=${artist:+artist.artist like \"%}${artist}${artist:+%\"}${album:+ and artist.id=album.artistid}${song:+ and artist.id=song.artistid}
[ -n "$album" ] && where=${where:-}${where:+ and }${album:+album.title like \"%}${album}${album:+%\"}${carrier:+ and album.carrierid=carrier.id}
[ -n "$song" ] && where=${where:-}${where:+ and }${song:+song.title like \"%}${song}${song:+%\"}${album:+ and song.albumid=album.id}
[ -n "$carrier" ] && where=${where:-}${where:+ and }${carrier:+carrier.carriername like \"%}${carrier}${carrier:+%\"}
querystring="select $what from $from where $where"
echo $querystring|$dba $format
}
help () {
cat<<-"END"
mp3l (mp3locate) queries the music database for artists/albums/songs/carriers
-a <name> artist <name>
-b <name> album <name>
-s <name> song <name>
-c <name> carrier (CD/DVD/etc) name
-h this help message
END
exit
}
# parameters
while getopts "ABSCa:b:s:c:ith" OPTION
do
case $OPTION in
h)
help
;;
A)
artist=%
;;
B)
album=%
;;
S)
song=%
;;
C)
carrier=%
;;
a)
artist=$OPTARG
;;
b)
album=$OPTARG
;;
s)
song=$OPTARG
;;
c)
carrier=$OPTARG
;;
t)
format="--table"
;;
[?]:)
help
;;
esac
done
query

4
bin/mskill Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
kill $(ps aux|grep -i exe|grep -v gvfs|grep -v grep|awk '{print $2}')

1
bin/nbook Symbolic link
View file

@ -0,0 +1 @@
/home/frank/bin/books

1
bin/nfiction Symbolic link
View file

@ -0,0 +1 @@
/home/frank/bin/books

2
bin/nm-applet-loop Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
while :;do nm-applet;done

220
bin/nxsession Executable file
View file

@ -0,0 +1,220 @@
#!/bin/bash
#
# Simple script to create/resume a remote NX session and connect to it.
#
# NX can be used without specific client software. All that is needed is nxagent and nxproxy.
# The reason that this is more than 5 lines is the suspend/resume logic built in nxagent.
#
# This is replacement for freeNX and any NX client software.
#
# In order to use this you need:
# 1. NX base installed (nxagent, nxproxy, nxcomp) on the (remote) client, and (nxproxy, nxcomp) on the (local) server
# 2. bash, fuser, awk, xauth, hexdump on the (remote) client, bash on the (local) server
#
# freeNX or any NX client is NOT needed.
#
# In the simplest case just run (on the local server):
# nxsession :<x port> -h <host>
# (if -h is omitted a local session is created/resumed, you later connect to that session through another server)
#
# If -h is present, you'll be requested to log in the remote (client) machine via SSH.
# An NX session is automatically created/resumed on the client. When the session is created .nxstartup is execute
# to start default X applications. When the last X application has ended the remote NX session ends automatically.
# All traffic is tunelled through the SSH connection.
#
# If the requested session is currently used from another machine add -f to force suspension of that other server connection.
#
# An MIT-MAGIC-COOKIE is generated when the session is created and used to secure the remote session.
# In addition that cookie is passed to the (local) server to also secure the nxproxy connection.
#
# To suspend a session from the (local) server use:
# nxsession :<x port> -s
#
# nxsession can also be used standalone on the remote client to terminate the session (-t)
#
# Author: Lars Hofhansl
#
# settings
bandwidth="adsl"
timeout="86400"
dpi="72"
function usage() {
echo "$0 port [-h host] [-ssh ssh-options] [-s] [-f] | $0 port -C [-f] [-t]"
exit 1
}
umask 0077 # make sure created files are not world/group read/writeable
SCRIPT=${HOME}/bin/$(basename $0)
while [ "${1+defined}" ]; do
case $1 in
-h)
HOST=$2
shift
;;
-ssh)
SSH_OPTS=$2
shift
;;
-s)
SUSPEND="1"
;;
-C)
CLIENT="1"
;;
-o)
NX_OPTS=$2
shift
;;
-f)
FORCE=$1
;;
-t)
TERMINATE=$1
;;
*)
if [ -n "$X_DISPLAY" ]; then
usage
fi
X_DISPLAY=$1
NX_PORT=$(($X_DISPLAY+4000))
X_PORT=$(($X_DISPLAY+6000))
;;
esac
shift
done
if [ -z $X_DISPLAY ]; then
usage
fi
## CLIENT(REMOTE) ##
if [ -n "$CLIENT" ]; then
if [ -n "$SUSPEND" -o -n "$SSH" -o -n "$HOST" ]; then
usage
fi
NX_BASE=$HOME/.nx/C-$X_DISPLAY
unset DISPLAY
pid=`cat $NX_BASE/pid 2>/dev/null`
if grep -q '^nxagent' /proc/$pid/cmdline 2>/dev/null; then
# Agent is running
if /bin/fuser -s $NX_PORT/tcp; then
# and is active
if [ -z $FORCE ]; then
echo "Another session is active, use -f to force suspension of that session"
exit 1
fi
# kill existing session if necessary
kill -HUP $pid # suspend agent
sleep 1
# kill the watchdog - if necessary
kill -HUP `ps --ppid $pid -o pid h` 2>/dev/null
sleep 1
fi
if [ -z $TERMINATE ]; then
# Agent is inactive... Resume
COOKIE=`xauth nextract - :$X_DISPLAY | awk '{print $9}'`
echo "nodelay=1,cleanup=0,accept=127.0.0.1,taint=1,cookie=$COOKIE,$NX_OPTS" > $NX_BASE/options
kill -HUP $pid
else
# we guaranteed that the session is suspended, it is save to kill it
# TERM should do it.. use -9 just in case
kill -TERM $pid || kill -9 $pid
xauth remove ":$X_DISPLAY"
echo "Terminated :$X_DISPLAY"
exit 0
fi
else
# Start Agent
if [ -n "$TERMINATE" ]; then
echo "No Agent running?"
exit 1
fi
if /bin/fuser -s $NX_PORT/tcp; then
echo "Port $NX_PORT is in use"
exit 1
fi
if /bin/fuser -s $X_PORT/tcp; then
echo "Display :$X_DISPLAY is in use"
exit 1
fi
# clear out existing Dir
rm -rf $NX_BASE
mkdir $NX_BASE
# secure the remote X session (generate MIT-MAGIC-COOKIE)
COOKIE=`head -c 16 /dev/urandom | hexdump -e '1/1 "%02x"'`
xauth add :$X_DISPLAY . $COOKIE
# run agent
echo "nodelay=1,cleanup=0,accept=127.0.0.1,taint=1,cookie=$COOKIE,$NX_OPTS" > $NX_BASE/options
nxagent -display nx/nx,options=$NX_BASE/options:$X_DISPLAY :$X_DISPLAY -R -timeout ${timeout} -nolisten tcp -persistent -noreset -dpi ${dpi} -forcenx -class TrueColor -auth $HOME/.Xauthority &> $NX_BASE/session &
echo $! > $NX_BASE/pid
# wait until nxagent is ready
while ! /bin/fuser -s $NX_PORT/tcp; do
sleep 1
done
# run startup script
env DISPLAY=:$X_DISPLAY $HOME/.nxstartup &> $NX_BASE/x_session &
fi
# send $COOKIE
echo "Cookie:$COOKIE" # write a line (the client will wait for this)
sleep 1
else
## LOCAL ##
if [ -n "$TERMINATE" ]; then
usage
fi
NX_BASE=$HOME/.nx/S-$X_DISPLAY
pid=`cat $NX_BASE/pid 2>/dev/null`
if [ -n "$SUSPEND" ]; then
if kill -HUP $pid 2>/dev/null; then
echo "Suspending Session"
else
echo "Already Suspended?"
fi
exit 0
fi
if [ -z "$HOST" ]; then
echo "Starting/Resuming LOCAL session"
RESULT=$($SCRIPT $X_DISPLAY -o link=100k -C $FORCE | head -n1)
else
echo "Starting/Resuming session on $HOST"
# | head -n1 waits for the first line from the remote machine
RESULT=$(ssh -T -f -o ExitOnForwardFailure=yes -L$NX_PORT:localhost:$NX_PORT $HOST $SSH_OPTS $SCRIPT $X_DISPLAY -o link=$bandwidth -C $FORCE | head -n1)
fi
if [ "${RESULT:0:6}" != "Cookie" ]; then
echo "Client: $RESULT"
exit 1;
fi
COOKIE=${RESULT:7}
# clear existing dir
rm -rf $NX_BASE
mkdir $NX_BASE
echo "Running nxproxy... Establishing connection may take a few seconds"
echo "cookie=$COOKIE" > $NX_BASE/options
nxproxy options=$NX_BASE/options -S localhost:$X_DISPLAY &> $NX_BASE/session &
echo $! > $NX_BASE/pid
fi

174
bin/open_with_linux.py Executable file
View file

@ -0,0 +1,174 @@
#!/usr/bin/env python3
from __future__ import print_function
import os
import sys
import json
import struct
import subprocess
VERSION = '7.2.6'
try:
sys.stdin.buffer
# Python 3.x version
# Read a message from stdin and decode it.
def getMessage():
rawLength = sys.stdin.buffer.read(4)
if len(rawLength) == 0:
sys.exit(0)
messageLength = struct.unpack('@I', rawLength)[0]
message = sys.stdin.buffer.read(messageLength).decode('utf-8')
return json.loads(message)
# Send an encoded message to stdout
def sendMessage(messageContent):
encodedContent = json.dumps(messageContent).encode('utf-8')
encodedLength = struct.pack('@I', len(encodedContent))
sys.stdout.buffer.write(encodedLength)
sys.stdout.buffer.write(encodedContent)
sys.stdout.buffer.flush()
except AttributeError:
# Python 2.x version (if sys.stdin.buffer is not defined)
print('Python 3.2 or newer is required.')
sys.exit(-1)
def install():
home_path = os.getenv('HOME')
manifest = {
'name': 'open_with',
'description': 'Open With native host',
'path': os.path.realpath(__file__),
'type': 'stdio',
}
locations = {
'chrome': os.path.join(home_path, '.config', 'google-chrome', 'NativeMessagingHosts'),
'chrome-beta': os.path.join(home_path, '.config', 'google-chrome-beta', 'NativeMessagingHosts'),
'chrome-unstable': os.path.join(home_path, '.config', 'google-chrome-unstable', 'NativeMessagingHosts'),
'chromium': os.path.join(home_path, '.config', 'chromium', 'NativeMessagingHosts'),
'firefox': os.path.join(home_path, '.mozilla', 'native-messaging-hosts'),
'thunderbird': os.path.join(home_path, '.thunderbird', 'native-messaging-hosts'),
}
filename = 'open_with.json'
for browser, location in locations.items():
if os.path.exists(os.path.dirname(location)):
if not os.path.exists(location):
os.mkdir(location)
browser_manifest = manifest.copy()
if browser in ['firefox', 'thunderbird']:
browser_manifest['allowed_extensions'] = ['openwith@darktrojan.net']
else:
browser_manifest['allowed_origins'] = [
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/', # Chrome
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/', # Opera
]
with open(os.path.join(location, filename), 'w') as file:
file.write(
json.dumps(browser_manifest, indent=2, separators=(',', ': '), sort_keys=True).replace(' ', '\t') + '\n'
)
def _read_desktop_file(path):
with open(path, 'r') as desktop_file:
current_section = None
name = None
command = None
for line in desktop_file:
if line[0] == '[':
current_section = line[1:-2]
if current_section != 'Desktop Entry':
continue
if line.startswith('Name='):
name = line[5:].strip()
elif line.startswith('Exec='):
command = line[5:].strip()
return {
'name': name,
'command': command
}
def find_browsers():
apps = [
'Chrome',
'Chromium',
'chromium',
'chromium-browser',
'firefox',
'Firefox',
'Google Chrome',
'google-chrome',
'opera',
'Opera',
'SeaMonkey',
'seamonkey',
]
paths = [
os.path.join(os.getenv('HOME'), '.local/share/applications'),
'/usr/local/share/applications',
'/usr/share/applications'
]
suffix = '.desktop'
results = []
for p in paths:
for a in apps:
fp = os.path.join(p, a) + suffix
if os.path.exists(fp):
results.append(_read_desktop_file(fp))
return results
def listen():
receivedMessage = getMessage()
if receivedMessage == 'ping':
sendMessage({
'version': VERSION,
'file': os.path.realpath(__file__)
})
elif receivedMessage == 'find':
sendMessage(find_browsers())
else:
for k, v in os.environ.items():
if k.startswith('MOZ_'):
try:
os.unsetenv(k)
except:
os.environ[k] = ''
devnull = open(os.devnull, 'w')
subprocess.Popen(receivedMessage, stdout=devnull, stderr=devnull)
sendMessage(None)
if __name__ == '__main__':
if len(sys.argv) == 2:
if sys.argv[1] == 'install':
install()
sys.exit(0)
elif sys.argv[1] == 'find_browsers':
print(find_browsers())
sys.exit(0)
allowed_extensions = [
'openwith@darktrojan.net',
'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/',
'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/',
]
for ae in allowed_extensions:
if ae in sys.argv:
listen()
sys.exit(0)
print('This is the Open With native helper, version %s.' % VERSION)
print('Run this script again with the word "install" after the file name to install.')

115
bin/osdmixer Executable file
View file

@ -0,0 +1,115 @@
#!/bin/bash
# Name and description
name="mixer-osd"
description="Provides an OSD (On Screen Display) for basic mixer operations."
# Some variables
default_color="green"
acolor=$default_color
# This program depends on aosd_cat and amixer (alsa-utils in Debian)
deps="aosd_cat amixer"
function usage()
{
show_name=$1
error=$2
# Show name and description only if explicitly stated
if [[ $show_name == 1 ]] ; then
echo -e " $name - $description\n"
fi
# Show an error message, if present
if [[ $error != '' ]] ; then
echo -e "\033[1m$error\033[0m\n"
fi
cat << EOF
Usage:
$name -u|-d|-m
$name -h
Options:
-u Volume up
-d Volume down
-m Mute/Unmute
-h Shows this help.
EOF
}
# Check for dependencies
for dep in $deps ; do
if [[ `which $dep` == '' ]] ; then
echo "Please, install $dep for $name to work!"
exit 1
fi
done
# Managing options
while getopts "hudm" option ; do
case $option in
h )
usage 1
exit 0
;;
u )
aarg="Volume ↑ $(amixer -c 0 sset Master 2+ unmute | tail -1 | awk '{print $4}' | tr -d '[]')"
acolor="royalblue"
;;
d )
aarg="Volume ↓ $(amixer -c 0 sset Master 2- unmute | tail -1 | awk '{print $4}' | tr -d '[]')"
acolor="gray50"
;;
m )
case $(amixer -c 0 sset Master toggle | tail -1 | awk '{print $6}' | tr -d '[]') in
on )
aarg="UNMUTED"
acolor="green"
;;
off )
aarg="MUTED"
acolor="red"
;;
esac
;;
\? )
echo -e "Please type ${name} -h for help on usage."
exit 1
;;
esac
done
shift $(($OPTIND - 1))
# This program doesn't accept any other argument than flag-options
if [[ $# -gt 0 ]] ; then
usage 0 "Invalid argument (\`$1')."
exit 1
fi
# One have to either mute/unmute or change the volume,
# otherwise program will exit with error code 1
if [[ -z $aarg ]] ; then
usage 0 "Please, mute/unmute or change the volume!"
exit 1
fi
# Kills any instance of aosd_cat
pkill aosd_cat >/dev/null 2>&1
# Performs osd-ized volume changes
echo "$aarg" | aosd_cat \
--fore-color=$acolor \
--position 4 \
--font="Droid Sans Bold 32" \
--y-offset=300 \
--transparency=2 \
--back-color="gray10" \
--back-opacity=50 \
--padding=20 \
--fade-full=1500 >/dev/null 2>&1 &
exit $?

11
bin/pdfreduce Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
if [ "$2"x = "x" ]; then
echo use: $0 input.pdf output.pdf
exit 1
fi
#gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$2 $1
#gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$2 $1
#gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dUseCIEColor -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$2 $1
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dUseCIEColor -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$2" "$1"

8
bin/pharo Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
export PHARO_DIR=/opt/pharo5.0
export PHARO_IMAGE=${PHARO_DIR}/shared/Pharo5.0.image
export PATH=${PHARO_DIR}/bin:${PATH}
pharo

34
bin/phone_import Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
destination="/net/media/photos/import/$(date +'%Y-%m-%d')"
devices=$(adb devices|grep -v 'List of devices attached'|grep device|cut -f 1)
for device in $devices; do
storages=$(adb -s "$device" shell ls /storage|grep '....-....')
for storage in $storages "self/primary"; do
label=${storage/\//-}
dcim=$(adb shell "ls /storage/$storage"|grep -i dcim)
if [ -n $dcim ]; then
store="/storage/$storage/$dcim"
seen="/net/media/photos/import/SEEN/${device}-${label}"
[ -f ${seen} ] || touch ${seen}
temp=$(mktemp -d)
current="${temp}/${device}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(adb -s ${device} shell "cd ${store} && find . -type f \! -path '*/.*'"|sed -e 's/^\.\///'|sort) > ${current}
for f in $(comm -13 <(sort ${seen}) ${current}); do
adb -s ${device} pull ${store}/${f} ${destination} >& /dev/null
echo "${f}" >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
fi
done
done

34
bin/phone_import-emma Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
destination="/net/media/photos/import/$(date +'%Y-%m-%d')"
devices=$(adb devices|grep -v 'List of devices attached'|grep device|cut -f 1)
for device in $devices; do
storages=$(adb -s "$device" shell ls /storage|grep '....-....')
for storage in $storages "self/primary"; do
label=${storage/\//-}
dcim=$(adb shell "ls /storage/$storage"|grep -i dcim)
if [ -n $dcim ]; then
store="/storage/$storage/$dcim"
seen="/net/media/photos/import/SEEN/${device}-${label}"
[ -f ${seen} ] || touch ${seen}
temp=$(mktemp -d)
current="${temp}/${device}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(adb -s ${device} shell "cd ${store} && find . -type f \! -path '*/.*'"|sed -e 's/^\.\///'|sort) > ${current}
for f in $(comm -13 <(sort ${seen}) ${current}); do
adb -s ${device} pull ${store}/${f} ${destination} >& /dev/null
echo "${f}" >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
fi
done
done

37
bin/phone_import-emma.old Executable file
View file

@ -0,0 +1,37 @@
#!/bin/sh
destination="/net/behemoth/photos/import/$(date +'%Y-%m-%d')"
mountpoint="/home/frank/cam"
camera="/dev/disk/by-label/MB526-E"
store="dcim/Camera"
camera_id=MOTOROLA_DEFY-emma
# volume_id=$(blkid -o value -s UUID ${camera})
seen="/net/behemoth/photos/import/SEEN/${camera_id}"
temp=$(mktemp -d)
current="${temp}/${camera_id}"
#fusermount -u "${mountpoint}"
#fusefat -o ro "${camera}" "${mountpoint}"
sudo umount "${mountpoint}"
sudo mount -o ro,uid=1000,check=r,shortname=lower "${camera}" "${mountpoint}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(cd ${mountpoint}/${store} && find . -type f|sed -e 's/^\.\///'|sort) > ${current}
for f in $(diff -u ${seen} ${current}|grep '^+[^+]'|sed -e 's/^+//'); do
cp "${mountpoint}"/"${store}"/"${f}" "${destination}"
echo $f >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
# ls "${mountpoint}"/"${store}"|while read f; do echo -n "."; cp "${mountpoint}"/"${store}"/"${f}" "${destination}"; done; echo " "
#fusermount -u "${mountpoint}"
sudo umount "${mountpoint}"

30
bin/phone_import-emma2 Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
destination="/net/behemoth/photos/import/$(date +'%Y-%m-%d')"
devices=$(adb devices|grep -v 'List of devices attached'|grep device|cut -f 1)
for device in $devices; do
dcim=$(adb shell "ls /storage/3731-3236"|grep -i dcim)
if [ -n $dcim ]; then
store="/storage/3731-3236/DCIM"
seen="/net/behemoth/photos/import/SEEN/${device}"
[ -f ${seen} ] || touch ${seen}
temp=$(mktemp -d)
current="${temp}/${device}"
mkdir -p "${destination}"
mkdir -p "${temp}"
(adb -s ${device} shell "cd ${store} && find . -type f \! -path '*/.*'"|sed -e 's/^\.\///'|sort) > ${current}
for f in $(comm -13 <(sort ${seen}) ${current}); do
adb -s ${device} pull ${store}/${f} ${destination} >& /dev/null
echo "${f}" >> ${seen}
echo -n "."
done
echo " "
rm -rf ${temp}
fi
done

4
bin/pirateplayer Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
#ssh behemoth xpra start :100 --start-child=pirateplayer --exit-with-children
#xpra attach ssh:behemoth:100
ssh -X behemoth pirateplayer

22
bin/plsparse.pl Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/perl -w
while (<STDIN>) {
chomp;
s/\&nbsp;//g;
if (/(\d{1,2} - ).*mp3=(.*\.mp3).*<b>(.*)<\/b>.*/i) {
my $url='http://hoorspelweb.com/stream/index.php?cmd=stream&mp3=' . $2 . '&dir_id=0';
my $name=$1 . $3;
$name =~ s/\s/_/g;
system("wget -O '" . $name . ".mp3' '" . $url . "'");
} elsif (/.*mp3=(.*\.mp3).*<b>(.*)<\/b>.*/i) {
my $url='http://hoorspelweb.com/stream/index.php?cmd=stream&mp3=' . $1 . '&dir_id=0';
my $name=$2;
$name =~ s/\s/_/g;
system("wget -O '" . $name . ".mp3' '" . $url . "'");
} elsif (/a href=".*mp3=(.*\.mp3).*">(.*)<\/a>.*/i) {
my $url='http://hoorspelweb.com/stream/index.php?cmd=stream&mp3=' . $1 . '&dir_id=0';
my $name=$2;
$name =~ s/\s/_/g;
system("wget -O '" . $name . ".mp3' '" . $url . "'");
}
}

8
bin/plsparse2.pl Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/perl -w
#use Mojo::DOM;
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
print $ua->max_redirects(5)->get($ARGV[0])->res->dom('p.title > a.title')->pluck('text')->shuffle;

16
bin/pop_clean_all Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
username=$1
password=$2
MAX_MESS=$3
[ $# -eq 0 ] && exit 1 || :
sleep 2
echo USER $username
sleep 1
echo PASS $password
sleep 2
for (( j = 1 ; j <= $MAX_MESS; j++ ))
do
echo DELE $j
sleep 1
done
echo QUIT

38
bin/psduplex Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/perl -s
# psduplex - filter to insert PostScript code to set/unset duplex mode
# Steve Kinzler, kinzler@cs.indiana.edu, Oct 91
# http://www.cs.indiana.edu/~kinzler/home.html#unix
# Note: This was found not to be effective with the "Generic postscript
# printer" PPD (vs "Generic PostScript Printer") from the foomatic
# printer database on RHEL5 2008-07-08.
$usage = "usage: $0 [ -e | -t ] [ file ... ]
-e use edge orientation (default)
-t use tumble orientation\n";
die $usage if $h;
$_ = <>;
print;
unless (/^%!/) { # not PostScript, pass through as is
while (<>) { print }
exit;
}
while (<>) {
last unless /^\s*%/;
print;
}
print "statusdict begin\n\ttrue setduplexmode\n";
print "\ttrue settumble\n" if $t;
print "end\n";
print;
while (<>) { print }
print "statusdict begin\n\tfalse setduplexmode\n";
print "\tfalse settumble\n" if $t;
print "end\n";

5
bin/qjackctl_poststartup Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
# create Headphone channel on internal hardware
alsa_out -j Headphone -d hw:0 -q 0 & 2>1 > .jack_log

5
bin/qjackctl_prestartup Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
# kill pulseaudio if it happens to be running
killall pulseaudio

Some files were not shown because too many files have changed in this diff Show more