summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2018-12-09 03:58:58 -0500
committerAndrew Cady <d@jerkface.net>2018-12-09 03:58:58 -0500
commitf4bd641e36418bc2a43bc31d8ac0bf57b1c51953 (patch)
treef565e29f956152fdb53c2a5042714de5bbb202ab
parent7aa3cd0a0e2961388df2cc11665dabef2250d6d7 (diff)
new commands
-rwxr-xr-xdot/local/bin/datel3
-rwxr-xr-xdot/local/bin/linlaunch58
-rwxr-xr-xdot/local/bin/safeunrar90
-rwxr-xr-xdot/local/bin/screeny31
-rwxr-xr-xdot/local/bin/selfstream49
-rwxr-xr-xdot/local/bin/soundy32
-rwxr-xr-xdot/local/bin/webbie47
-rwxr-xr-xdot/local/bin/xtermessage4
-rwxr-xr-xdot/local/bin/zukertort2
-rw-r--r--dot/local/share/applications/mimeapps.list3
10 files changed, 319 insertions, 0 deletions
diff --git a/dot/local/bin/datel b/dot/local/bin/datel
new file mode 100755
index 0000000..4375b4f
--- /dev/null
+++ b/dot/local/bin/datel
@@ -0,0 +1,3 @@
1#!/bin/bash
2date=$(date "$@")
3printf '%s\n' "$date" "${date//?/-}"
diff --git a/dot/local/bin/linlaunch b/dot/local/bin/linlaunch
new file mode 100755
index 0000000..20ebc7a
--- /dev/null
+++ b/dot/local/bin/linlaunch
@@ -0,0 +1,58 @@
1#!/bin/sh
2
3linphone_socket=/tmp/linphonec-$(id -u)
4
5warn() { printf '%s\n' "$0" "${*:-something is wrong.}" >&2; }
6die() { warn "$@"; exit 1; }
7
8init()
9{
10 out=$(linphonecsh init -CD 2>&1)
11 [ -z "$out" ] && return
12 case "$out" in
13 *'running linphonec has been found'*)
14 printf '%s\n' "$out" >&2
15 return 1 ;;
16 '')
17 return 0 ;;
18 *)
19 die "Error: unexpected output from linphonecsh: $out" ;;
20 esac
21}
22
23wait_for_linphone_socket()
24{
25 for n in $(seq 1 50); do
26 test -e ${linphone_socket} && break
27 sleep 0.1
28 done
29}
30
31getip()
32{
33 upnpc -s|sed -ne 's/^ExternalIPAddress = //p'
34}
35
36generic()
37{
38 linphonecsh generic "$*"
39}
40
41atexit()
42{
43 if [ "$kill_linphonec" ]; then
44 linphonecsh exit
45 fi
46}
47
48init
49trap atexit EXIT
50
51wait_for_linphone_socket
52
53if ip=$(getip); then
54 generic nat $ip
55 generic firewall nat
56fi
57
58generic friend list
diff --git a/dot/local/bin/safeunrar b/dot/local/bin/safeunrar
new file mode 100755
index 0000000..506145b
--- /dev/null
+++ b/dot/local/bin/safeunrar
@@ -0,0 +1,90 @@
1#!/usr/bin/perl -w
2########################################################################
3# safeunrar, safeunzip, safeuntar -- Extract archives, ensuring that #
4# all files in each archive remain in a single subdirectory, without #
5# overwriting anything. #
6########################################################################
7# The decompression program is called once for each argument. The #
8# program to use is guessed, first by extension, and failing that #
9# by the name of this program (which, in that case, must be one of #
10# safeunrar, safeunzip, safeuntar). #
11########################################################################
12use File::Temp qw(tempdir);
13use File::Basename;
14use Cwd;
15
16my %extension_map = (
17 '(tar\.gz|tgz|taz)' => 'tar -zxf',
18 '(tar\.Z|taZ)' => 'tar -Zxf',
19 '(tar\.bz2|tz2|tbz2|tbz)' => 'tar -jxf',
20 '(tar\.lzma|tlz)' => 'tar --use-compress-program=lzma -xf',
21 '(zip|xpi|jar)' => 'unzip',
22 'rar' => 'unrar x',
23 'tar' => 'tar -xf',
24);
25
26$cwd = getcwd or die "getcwd error: $!";
27for $archive (@ARGV) {
28 chdir $cwd or die "chdir error: $!";
29
30 my ($base, @cmd);
31 keys %extension_map; # resets "each"
32 while (($rx, $cmd) = each %extension_map) {
33 $_ = basename $archive;
34 if (m/^(.*)\.$rx$/) {
35 @cmd = split / /, $cmd;
36 $base = $1;
37 last;
38 }
39 }
40 unless (@cmd) {
41 for (basename $0) {
42 $_ eq 'safeunzip' && (@cmd = qw'unzip')
43 || $_ eq 'safeunrar' && (@cmd = qw'unrar x')
44# don't use this because the current gnu tar's --auto-compress is
45# guaranteed to fail if the current %extension_map failed.
46# || $_ eq 'safeuntar' && (@cmd = qw'tar --auto-compress -xf')
47 || $_ eq 'safeuntar' && (@cmd = qw'tar -zxf')
48 || die;
49 }
50 ($base = basename $archive) =~ s/\..{2,4}$//;
51 }
52
53 $tempdir = tempdir("$base.XXXXXX", DIR => ".")
54 or warn("tempdir error: $!; skipping $archive"), next;
55 chmod 0777 & ~ umask, $tempdir;
56
57 $ltd = "leaving temporary directory '$tempdir'";
58
59 # extract the files
60 chdir $tempdir
61 or warn("chdir error: $!; $ltd"), next;
62 $archive =~ s#^(?!/)#../#;
63 system(@cmd, $archive) == 0
64 or warn("$cmd[0] error: $?/$!; $ltd"), next;
65
66 # count the files
67 opendir(DIR, '.')
68 or warn("opendir error: $!; $ltd"), next;
69 @f = readdir(DIR)
70 or warn("readdir error: $!; $ltd"), next;
71 closedir(DIR)
72 or warn("closedir error: $!; ignoring");
73
74 # if only one file, delete the dir
75 @f = grep { ! m/^\.\.?$/ } @f;
76 if (1 == @f) {
77 ! -e "$cwd/$f[0]"
78 or warn("not overwriting $f[0]; $ltd"), next;
79 rename $f[0], "$cwd/$f[0]"
80 or warn("rename error: $!; $ltd"), next;
81 chdir $cwd
82 or warn("chdir error: $!; $ltd"), next;
83 rmdir $tempdir
84 or warn("rmdir error: $!; $ltd"), next;
85 # if multiple files, rename the dir
86 } else {
87 rename "$cwd/$tempdir", "$cwd/$base"
88 or warn("rename error: $!; $ltd"), next;
89 }
90}
diff --git a/dot/local/bin/screeny b/dot/local/bin/screeny
new file mode 100755
index 0000000..8ecf2d0
--- /dev/null
+++ b/dot/local/bin/screeny
@@ -0,0 +1,31 @@
1#!/bin/bash
2die() { printf '%s: Error: %s\n' "$0" "$*" >&2; exit 1; }
3[ "$DISPLAY" ] || die 'no $DISPLAY set. Try launching from a new xterm.'
4
5AUDIO_DEVICE=pulse
6
7NOW=$(date -Iseconds)
8
9OUTPUT=screen-capture.${NOW//[:T]/.}.avi
10OUTPUT_LINK=screen-capture.latest.avi
11
12# ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0 out.mpg
13
14record()
15{
16 local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
17 ffmpeg -hide_banner -loglevel error -stats \
18 $timeout -f x11grab -framerate 25 -video_size 1280x800 -i "$DISPLAY" \
19 $timeout -f "$AUDIO_DEVICE" -i default \
20 -c:a mp3 \
21 -c:v libxvid -qscale:v 3 \
22 "$1"
23}
24
25silently() { "$@" >/dev/null 2>&1; }
26
27silently amixer-enable-mic
28banish
29record "$OUTPUT"
30
31[ -h "$OUTPUT_LINK" -o ! -e "$OUTPUT_LINK" ] && ln -sf "$OUTPUT" "$OUTPUT_LINK"
diff --git a/dot/local/bin/selfstream b/dot/local/bin/selfstream
new file mode 100755
index 0000000..85b8a8f
--- /dev/null
+++ b/dot/local/bin/selfstream
@@ -0,0 +1,49 @@
1#!/bin/bash
2
3AUDIO_DEVICE=pulse
4VIDEO_DEVICE=/dev/video0
5
6case $(hostname) in
7 fifty) outhost=blackbird ;;
8 blackbird) outhost=fifty; AUDIO_DEVICE=alsa ;;
9 *) outhost=$1
10esac
11
12MAX_RECORDING_TIME=00:05:00
13
14# https://trac.ffmpeg.org/wiki/StreamingGuide#Pointtopointstreaming
15
16VIDEO_OPTS='-framerate 30 -video_size 640x480'
17VIDEO_OPTS='-framerate 30 -video_size 320x240'
18# VIDEO_OPTS='-input_format mjpeg -framerate 30 -video_size 800x600'
19
20record()
21{
22 local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
23 ffmpeg -hide_banner -loglevel error -stats \
24 $timeout -f video4linux2 ${VIDEO_OPTS} -i "$VIDEO_DEVICE" \
25 $timeout -f "$AUDIO_DEVICE" -i default \
26 -c:v rawvideo -pix_fmt yuv420p -f xv win \
27 -c:a mp3 \
28 -c:v libxvid \
29 -f mpegts \
30 "$1"
31}
32
33# ffmpeg -i input -f rtsp -rtsp_transport tcp rtsp://localhost:8888/live.sdp
34# ffplay -rtsp_flags listen rtsp://localhost:8888/live.sdp?tcp
35
36#OUTPUT=${1:-udp://blackbird:55555}
37#INPUT=${2:-ffmpeg://udp://localhost:55555?listen}
38
39
40OUTPUT=udp://blackbird:55555
41
42silently() { "$@" >/dev/null 2>&1; }
43
44silently amixer-enable-mic
45banish
46
47record "$OUTPUT"
48# mpv "$INPUT"
49
diff --git a/dot/local/bin/soundy b/dot/local/bin/soundy
new file mode 100755
index 0000000..5ec812b
--- /dev/null
+++ b/dot/local/bin/soundy
@@ -0,0 +1,32 @@
1#!/bin/bash
2die() { printf '%s: Error: %s\n' "$0" "$*" >&2; exit 1; }
3[ "$DISPLAY" ] || die 'no $DISPLAY set. Try launching from a new xterm.'
4
5AUDIO_DEVICE=pulse
6AUDIO_INPUT=jack_out.monitor
7
8NOW=$(date -Iseconds)
9
10OUTPUT=screen-capture.${NOW//[:T]/.}.avi
11OUTPUT_LINK=screen-capture.latest.avi
12
13# ffmpeg -f x11grab -framerate 25 -video_size cif -i :0.0 out.mpg
14
15record()
16{
17 local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
18 ffmpeg -hide_banner -loglevel error -stats \
19 $timeout -f x11grab -framerate 25 -video_size 1280x800 -i "$DISPLAY" \
20 $timeout -f "$AUDIO_DEVICE" -i "$AUDIO_INPUT" \
21 -c:a mp3 \
22 -c:v libxvid -qscale:v 3 \
23 "$1"
24}
25
26silently() { "$@" >/dev/null 2>&1; }
27
28silently amixer-enable-mic
29banish
30record "$OUTPUT"
31
32[ -h "$OUTPUT_LINK" -o ! -e "$OUTPUT_LINK" ] && ln -sf "$OUTPUT" "$OUTPUT_LINK"
diff --git a/dot/local/bin/webbie b/dot/local/bin/webbie
new file mode 100755
index 0000000..02fa3dd
--- /dev/null
+++ b/dot/local/bin/webbie
@@ -0,0 +1,47 @@
1#!/bin/bash
2
3AUDIO_DEVICE=pulse
4VIDEO_DEVICE=/dev/video0
5
6# Why does OUTPUT_CODECS have to specify -pix_fmt ? Answered:
7# https://stackoverflow.com/questions/37967120/ffmpeg-convert-from-h-264-high-444-profile-to-h-264-main-profile
8
9# Why aac and libx264? Browser support:
10# https://gist.github.com/Vestride/278e13915894821e1d6f
11
12# Explanation of -profile and -level:
13# https://trac.ffmpeg.org/wiki/Encode/H.264
14
15OUTPUT_CODECS='-c:a aac -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.1 -movflags +faststart'
16# OUTPUT_CODECS='-c:a aac -c:v libx264'
17OUTPUT_EXTENSION=mp4
18
19MAX_RECORDING_TIME=00:05:00
20
21NOW=$(date -Iseconds)
22
23OUTPUT=recording.${NOW//[:T]/.}.${OUTPUT_EXTENSION}
24OUTPUT_LINK=recording.latest.${OUTPUT_EXTENSION}
25
26VIDEO_OPTS='-framerate 30 -video_size 640x480'
27VIDEO_OPTS='-input_format mjpeg -framerate 30 -video_size 800x600'
28# VIDEO_OPTS='-input_format mjpeg -framerate 15 -video_size 1600x1200'
29
30record()
31{
32 local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}"
33 ffmpeg -hide_banner -loglevel error -stats \
34 $timeout -f video4linux2 ${VIDEO_OPTS} -i "$VIDEO_DEVICE" \
35 $timeout -f "$AUDIO_DEVICE" -i default \
36 -c:v rawvideo -pix_fmt yuv420p -f xv win \
37 ${OUTPUT_CODECS} \
38 "$1"
39}
40
41silently() { "$@" >/dev/null 2>&1; }
42
43silently amixer-enable-mic
44banish
45record "$OUTPUT"
46
47[ -h "$OUTPUT_LINK" -o ! -e "$OUTPUT_LINK" ] && ln -sf "$OUTPUT" "$OUTPUT_LINK"
diff --git a/dot/local/bin/xtermessage b/dot/local/bin/xtermessage
new file mode 100755
index 0000000..8e64b3a
--- /dev/null
+++ b/dot/local/bin/xtermessage
@@ -0,0 +1,4 @@
1#!/bin/sh
2literal=$(printf "%s\n" "$@")
3export literal
4xterm -cr white -fs 90 -e 'tput civis; printf %s "$literal"; read -n1'
diff --git a/dot/local/bin/zukertort b/dot/local/bin/zukertort
new file mode 100755
index 0000000..5bbaf8b
--- /dev/null
+++ b/dot/local/bin/zukertort
@@ -0,0 +1,2 @@
1#!/bin/sh
2exec x11-ssh-host zukertort.childrenofmay.org
diff --git a/dot/local/share/applications/mimeapps.list b/dot/local/share/applications/mimeapps.list
new file mode 100644
index 0000000..3a146e3
--- /dev/null
+++ b/dot/local/share/applications/mimeapps.list
@@ -0,0 +1,3 @@
1[Default Applications]
2application/pdf=evince.desktop
3image/png=geeqie.desktop