summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dot/bashrc8
-rwxr-xr-xdot/local/bin/google6
-rwxr-xr-xdot/local/bin/hard-restart-wifi14
-rwxr-xr-xdot/local/bin/lptext7
-rwxr-xr-xdot/local/bin/musopen34
-rwxr-xr-xdot/local/bin/selfie44
6 files changed, 100 insertions, 13 deletions
diff --git a/dot/bashrc b/dot/bashrc
index 19bf544..1c2a83c 100644
--- a/dot/bashrc
+++ b/dot/bashrc
@@ -390,3 +390,11 @@ subvolify()
390 mv "$path" "$path".subvol~ 390 mv "$path" "$path".subvol~
391 mv "$path".subvol "$path" 391 mv "$path".subvol "$path"
392} 392}
393
394fkill()
395{
396 killall "$@" firefox-bin 'Web Content' WebExtensions
397}
398
399alias fstop='fkill -STOP'
400alias fcont='fkill -CONT'
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;
4s/([^a-zA-Z0-9])/sprintf "%%%x", ord $1/ge; 5s/([^a-zA-Z0-9])/sprintf "%%%x", ord $1/ge;
5exec qw(w3m), "http://www.google.com/search?q=$_" 6$url = "https://www.google.com/search?q=$_";
7
8if ($ENV{NO_FAKE_UA}) { exec qw(w3m), "$url" }
9else { 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
15restart=$(with_pwd_path which restart-linux-device) || die "command 'restart-linux-device' is not available." 13restart=$(with_pwd_path which restart-linux-device) || die "command 'restart-linux-device' is not available."
16 14
15if [ $(id -u) = 0 ]; then
16 sudo=
17else
18 sudo=sudo
19fi
20
17dev=${1:-$default_dev} 21dev=${1:-$default_dev}
18rawdev=${dev%=*} 22rawdev=${dev%=*}
19 23
20[ "$VERBOSE" ] && set -x 24[ "$VERBOSE" ] && set -x
21$restart $rawdev 25$sudo $restart $rawdev
22ifdown --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.
23ifup $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
2case "$1" in
3 -*|'') ;;
4 *) echo "Warning: $0: ignoring stdin and using first argument as input ($1)" >&2
5 exec < "$1"
6 shift
7 ;;
8esac
2text2png | lp "$@" 9text2png | 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
3usage()
4{
5 cat <<EOF
6Usage: $0 [-h|--help] [-n|--no-save] [-s|--save]
7EOF
8}
9
10DO_SAVE=y
11
12eval set -- "$(getopt -o 'hsn' --long '-help,-save,-no-save' -n 'musopen' -- "$@")" || exit 1
13while 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
22done
23
3URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0 24URL=https://radio.musopen.org/v1/pieces/get_current/streamvbr0
4JSON=$(curl -s "$URL") 25JSON=$(curl -s "$URL")
5URL_FMT='https://live.musopen.org/music/vbr0/%s' 26URL_FMT='https://live.musopen.org/music/vbr0/%s'
@@ -14,7 +35,14 @@ title=$(j .title)
14 35
15STREAM_URL=$(printf "$URL_FMT" "$filename") 36STREAM_URL=$(printf "$URL_FMT" "$filename")
16 37
17CAPTURE_NAME= 38CAPTURE_NAME="$composer - $title.${filename##*.}"
18[ "$CAPTURE" ] && CAPTURE_NAME="$composer - $title.${filename##*.}" 39
40if [ "$DO_SAVE" -a -e "$CAPTURE_NAME" ]; then
41 echo "Warning: not saving: file exists: $CAPTURE_NAME" >&2
42 DO_SAVE=
43else
44 printf '%s: %s - %s\n' "${DO_SAVE+Saving}${DO_SAVE-Playing}" "$composer" "$title" >&2
45fi
46
19 47
20exec mpv "$STREAM_URL" ${CAPTURE_NAME+ --stream-capture="$CAPTURE_NAME"} 48exec 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
3video_devices()
4{
5 v4l2-ctl --list-devices | sed -ne 's/^\t//p'
6}
7
3AUDIO_DEVICE=pulse 8AUDIO_DEVICE=pulse
4VIDEO_DEVICE=/dev/video0 9VIDEO_DEVICE=$(video_devices | head -n1)
10
11[ "$VIDEO_DEVICE" ] || exit 1
5 12
6MAX_RECORDING_TIME=00:05:00 13MAX_RECORDING_TIME=00:05:00
14[ "$RECORD_FOREVER" ] && unset MAX_RECORDING_TIME
7 15
8NOW=$(date -Iseconds) 16NOW=$(date -Iseconds)
9 17
10OUTPUT=recording.${NOW//[:T]/.}.avi 18OUTPUT=recording.${NOW//[:T]/.}.avi
11OUTPUT_LINK=recording.latest.avi 19OUTPUT_LINK=recording.latest.avi
12 20
21XVID_QUALITY=10
22
23info()
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
38V4L2_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
42drawtext='text=%{pts\\:hms}:x=5:y=h-lh-5:fontsize=18:fontcolor=white:box=1:boxcolor=0x00000099'
13record() 43record()
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