diff options
Diffstat (limited to 'dot/local')
-rwxr-xr-x | dot/local/bin/google | 6 | ||||
-rwxr-xr-x | dot/local/bin/hard-restart-wifi | 14 | ||||
-rwxr-xr-x | dot/local/bin/lptext | 7 | ||||
-rwxr-xr-x | dot/local/bin/musopen | 34 | ||||
-rwxr-xr-x | dot/local/bin/selfie | 44 |
5 files changed, 92 insertions, 13 deletions
diff --git a/dot/local/bin/google b/dot/local/bin/google index 25604fb..94ebf0f 100755 --- a/dot/local/bin/google +++ b/dot/local/bin/google | |||
@@ -1,5 +1,9 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!/usr/bin/perl -w |
2 | $useragent = 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0'; | ||
2 | 3 | ||
3 | $_ = join ' ', map { m/ / ? qq<"$_"> : $_ } @ARGV; | 4 | $_ = join ' ', map { m/ / ? qq<"$_"> : $_ } @ARGV; |
4 | s/([^a-zA-Z0-9])/sprintf "%%%x", ord $1/ge; | 5 | s/([^a-zA-Z0-9])/sprintf "%%%x", ord $1/ge; |
5 | exec qw(w3m), "http://www.google.com/search?q=$_" | 6 | $url = "https://www.google.com/search?q=$_"; |
7 | |||
8 | if ($ENV{NO_FAKE_UA}) { exec qw(w3m), "$url" } | ||
9 | else { exec qw(w3m -o), "user_agent=$useragent", "$url" } | ||
diff --git a/dot/local/bin/hard-restart-wifi b/dot/local/bin/hard-restart-wifi index 78f7144..52f21d3 100755 --- a/dot/local/bin/hard-restart-wifi +++ b/dot/local/bin/hard-restart-wifi | |||
@@ -10,14 +10,18 @@ with_pwd_path() | |||
10 | "$@" | 10 | "$@" |
11 | } | 11 | } |
12 | 12 | ||
13 | [ $(id -u) = 0 ] || die "you are not root." | ||
14 | |||
15 | restart=$(with_pwd_path which restart-linux-device) || die "command 'restart-linux-device' is not available." | 13 | restart=$(with_pwd_path which restart-linux-device) || die "command 'restart-linux-device' is not available." |
16 | 14 | ||
15 | if [ $(id -u) = 0 ]; then | ||
16 | sudo= | ||
17 | else | ||
18 | sudo=sudo | ||
19 | fi | ||
20 | |||
17 | dev=${1:-$default_dev} | 21 | dev=${1:-$default_dev} |
18 | rawdev=${dev%=*} | 22 | rawdev=${dev%=*} |
19 | 23 | ||
20 | [ "$VERBOSE" ] && set -x | 24 | [ "$VERBOSE" ] && set -x |
21 | $restart $rawdev | 25 | $sudo $restart $rawdev |
22 | ifdown --force $rawdev # It's not clear to me why this is necessary, but it is. | 26 | $sudo ifdown --force $rawdev # It's not clear to me why this is necessary, but it is. |
23 | ifup $dev | 27 | $sudo ifup $dev |
diff --git a/dot/local/bin/lptext b/dot/local/bin/lptext index 064e98e..645e4a4 100755 --- a/dot/local/bin/lptext +++ b/dot/local/bin/lptext | |||
@@ -1,2 +1,9 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | case "$1" in | ||
3 | -*|'') ;; | ||
4 | *) echo "Warning: $0: ignoring stdin and using first argument as input ($1)" >&2 | ||
5 | exec < "$1" | ||
6 | shift | ||
7 | ;; | ||
8 | esac | ||
2 | text2png | lp "$@" | 9 | text2png | lp "$@" |
diff --git a/dot/local/bin/musopen b/dot/local/bin/musopen index 3ed9962..7d007fb 100755 --- a/dot/local/bin/musopen +++ b/dot/local/bin/musopen | |||
@@ -1,5 +1,26 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | usage() | ||
4 | { | ||
5 | cat <<EOF | ||
6 | Usage: $0 [-h|--help] [-n|--no-save] [-s|--save] | ||
7 | EOF | ||
8 | } | ||
9 | |||
10 | DO_SAVE=y | ||
11 | |||
12 | eval set -- "$(getopt -o 'hsn' --long '-help,-save,-no-save' -n 'musopen' -- "$@")" || exit 1 | ||
13 | while true; do | ||
14 | case "$1" in | ||
15 | -h|--help) usage; exit ;; | ||
16 | -s|--save) DO_SAVE=y ;; | ||
17 | -n|--no-save) DO_SAVE= ;; | ||
18 | --) shift; break ;; | ||
19 | *) usage; exit 1 ;; | ||
20 | esac | ||
21 | shift | ||
22 | done | ||
23 | |||
3 | URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0 | 24 | URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0 |
4 | JSON=$(curl -s "$URL") | 25 | JSON=$(curl -s "$URL") |
5 | URL_FMT='https://live.musopen.org/music/vbr0/%s' | 26 | URL_FMT='https://live.musopen.org/music/vbr0/%s' |
@@ -14,7 +35,14 @@ title=$(j .title) | |||
14 | 35 | ||
15 | STREAM_URL=$(printf "$URL_FMT" "$filename") | 36 | STREAM_URL=$(printf "$URL_FMT" "$filename") |
16 | 37 | ||
17 | CAPTURE_NAME= | 38 | CAPTURE_NAME="$composer - $title.${filename##*.}" |
18 | [ "$CAPTURE" ] && CAPTURE_NAME="$composer - $title.${filename##*.}" | 39 | |
40 | if [ "$DO_SAVE" -a -e "$CAPTURE_NAME" ]; then | ||
41 | echo "Warning: not saving: file exists: $CAPTURE_NAME" >&2 | ||
42 | DO_SAVE= | ||
43 | else | ||
44 | printf '%s: %s - %s\n' "${DO_SAVE+Saving}${DO_SAVE-Playing}" "$composer" "$title" >&2 | ||
45 | fi | ||
46 | |||
19 | 47 | ||
20 | exec mpv "$STREAM_URL" ${CAPTURE_NAME+ --stream-capture="$CAPTURE_NAME"} | 48 | exec mpv "$STREAM_URL" ${DO_SAVE+ --stream-capture="$CAPTURE_NAME"} |
diff --git a/dot/local/bin/selfie b/dot/local/bin/selfie index 9fa2a45..ef0adb2 100755 --- a/dot/local/bin/selfie +++ b/dot/local/bin/selfie | |||
@@ -1,24 +1,60 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | video_devices() | ||
4 | { | ||
5 | v4l2-ctl --list-devices | sed -ne 's/^\t//p' | ||
6 | } | ||
7 | |||
3 | AUDIO_DEVICE=pulse | 8 | AUDIO_DEVICE=pulse |
4 | VIDEO_DEVICE=/dev/video0 | 9 | VIDEO_DEVICE=$(video_devices | head -n1) |
10 | |||
11 | [ "$VIDEO_DEVICE" ] || exit 1 | ||
5 | 12 | ||
6 | MAX_RECORDING_TIME=00:05:00 | 13 | MAX_RECORDING_TIME=00:05:00 |
14 | [ "$RECORD_FOREVER" ] && unset MAX_RECORDING_TIME | ||
7 | 15 | ||
8 | NOW=$(date -Iseconds) | 16 | NOW=$(date -Iseconds) |
9 | 17 | ||
10 | OUTPUT=recording.${NOW//[:T]/.}.avi | 18 | OUTPUT=recording.${NOW//[:T]/.}.avi |
11 | OUTPUT_LINK=recording.latest.avi | 19 | OUTPUT_LINK=recording.latest.avi |
12 | 20 | ||
21 | XVID_QUALITY=10 | ||
22 | |||
23 | info() | ||
24 | { | ||
25 | ffmpeg -hide_banner -f v4l2 -list_formats all -i "$VIDEO_DEVICE" | ||
26 | v4l2-ctl --list-formats-ext | ||
27 | |||
28 | # Such commands as these do nothing. ffmpeg overrides them. | ||
29 | #v4l2-ctl --set-fmt-video=width=800,height=600,pixelformat=MJPG | ||
30 | #v4l2-ctl --set-fmt-video=width=1600,height=1200,pixelformat=MJPG | ||
31 | } | ||
32 | |||
33 | # The higher resolution matches the display, and so fills the screen while | ||
34 | # recording, but the field of view is larger in the 800x600 resolution, which | ||
35 | # also supports a higher framerate. Thus 800x600 seems like the "natural" | ||
36 | # resolution of the camera. Though, it is still quite low. :( | ||
37 | |||
38 | V4L2_OPTIONS='-input_format mjpeg -framerate 30 -video_size 800x600' | ||
39 | # V4L2_OPTIONS='-input_format mjpeg -framerate 15 -video_size 1280x800' | ||
40 | # V4L2_OPTIONS='-input_format mjpeg -framerate 15 -video_size 1600x1200' | ||
41 | |||
42 | drawtext='text=%{pts\\:hms}:x=5:y=h-lh-5:fontsize=18:fontcolor=white:box=1:boxcolor=0x00000099' | ||
13 | record() | 43 | record() |
14 | { | 44 | { |
15 | local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}" | 45 | local timeout="${MAX_RECORDING_TIME+-t $MAX_RECORDING_TIME}" |
16 | ffmpeg -hide_banner -loglevel error -stats \ | 46 | ffmpeg -hide_banner -loglevel error -stats \ |
17 | $timeout -f video4linux2 -i "$VIDEO_DEVICE" \ | 47 | $timeout -f video4linux2 ${V4L2_OPTIONS} -i "$VIDEO_DEVICE" \ |
18 | $timeout -f "$AUDIO_DEVICE" -i default \ | 48 | $timeout -f "$AUDIO_DEVICE" -i default \ |
19 | -c:v rawvideo -pix_fmt yuv420p -f xv win \ | 49 | \ |
20 | -c:a mp3 \ | 50 | -c:v rawvideo \ |
51 | -vf scale=iw/2:ih/2,drawtext="${drawtext}" \ | ||
52 | -pix_fmt yuv420p \ | ||
53 | -f xv selfie \ | ||
54 | \ | ||
21 | -c:v libxvid \ | 55 | -c:v libxvid \ |
56 | -c:a libmp3lame \ | ||
57 | -q:v $XVID_QUALITY \ | ||
22 | "$1" | 58 | "$1" |
23 | } | 59 | } |
24 | 60 | ||