scripts: make all POSIX compliant
This commit is contained in:
parent
15deaadc5f
commit
05f3c5aa0f
@ -1,12 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
lock=/tmp/.beep-lock
|
lock=/tmp/.beep-lock
|
||||||
test -f $lock && exit 1 || touch $lock
|
test -f $lock && exit 1
|
||||||
head -c 8 /dev/urandom | \
|
touch $lock
|
||||||
hexdump -v -e '/1 "%u\n"' | \
|
|
||||||
awk '{ split("0,3,5,6,7,10,12",a,","); \
|
head -c 8 /dev/urandom |
|
||||||
for (i = 0; i < 1; i+= 0.00012) \
|
hexdump -v -e '/1 "%u\n"' |
|
||||||
printf("%08X\n", 60*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' | \
|
awk '{ split("0,3,5,6,7,10,12",a,",");
|
||||||
xxd -r -p | \
|
for (i = 0; i < 1; i+= 0.00012)
|
||||||
|
printf("%08X\n", 60*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' |
|
||||||
|
xxd -r -p |
|
||||||
aplay -c 1 -f S32_LE -r 48000 -D plug:default
|
aplay -c 1 -f S32_LE -r 48000 -D plug:default
|
||||||
|
|
||||||
rm -f $lock
|
rm -f $lock
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
lock=/tmp/.beep-lock
|
lock=/tmp/.beep-lock
|
||||||
test -f $lock && exit 1 || touch $lock
|
test -f $lock && exit 1
|
||||||
|
touch $lock
|
||||||
|
|
||||||
head -c 4 /dev/urandom | \
|
head -c 4 /dev/urandom | \
|
||||||
hexdump -v -e '/1 "%u\n"' | \
|
hexdump -v -e '/1 "%u\n"' |
|
||||||
awk '{ split("0,3,5,6,7,10,12",a,","); \
|
awk '{ split("0,3,5,6,7,10,12",a,",");
|
||||||
for (i = 0; i < 1; i+= 0.00011) \
|
for (i = 0; i < 1; i+= 0.00011)
|
||||||
printf("%08X\n", 40*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' | \
|
printf("%08X\n", 40*sin(450*exp((a[$1 % 8]/12)*log(2))*i)) }' |
|
||||||
xxd -r -p | \
|
xxd -r -p |
|
||||||
aplay -c 2 -f S16_LE -r 48000 -Dplug:hdmi1
|
aplay -c 2 -f S16_LE -r 48000 -Dplug:hdmi1
|
||||||
|
|
||||||
rm -f $lock
|
rm -f $lock
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
current=$(cat /sys/class/backlight/intel_backlight/brightness)
|
current=$(cat /sys/class/backlight/intel_backlight/brightness)
|
||||||
|
|
||||||
if test -z "$1"; then
|
if test -z "$1"; then
|
||||||
echo $current
|
echo "$current"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ case "$1" in
|
|||||||
echo "missing increment"
|
echo "missing increment"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
new=$(("$current" "$1" "$2"))
|
new="$((current $1 $2))"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "invalid argument '$1'"
|
echo "invalid argument '$1'"
|
||||||
@ -24,4 +24,4 @@ case "$1" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
echo "current: $new"
|
echo "current: $new"
|
||||||
echo $new > /sys/class/backlight/intel_backlight/brightness
|
echo "$new" > /sys/class/backlight/intel_backlight/brightness
|
||||||
|
@ -2,19 +2,20 @@
|
|||||||
|
|
||||||
xcolor() { xrdb -query | grep -Po "color$1:\s+\K#\w+"; }
|
xcolor() { xrdb -query | grep -Po "color$1:\s+\K#\w+"; }
|
||||||
|
|
||||||
xrdb -override $XDG_CONFIG_HOME/x/$1
|
xrdb -override "$XDG_CONFIG_HOME/x/$1"
|
||||||
|
|
||||||
pkill -USR1 'qutebrowser|urxvt'
|
pkill -USR1 'qutebrowser|urxvt'
|
||||||
$XDG_CONFIG_HOME/bspwm/bspwmrc
|
"$XDG_CONFIG_HOME/bspwm/bspwmrc"
|
||||||
|
|
||||||
if test "$1" == light; then
|
if test "$1" = light; then
|
||||||
xsetroot -fg $(xcolor 14) -bg $(xcolor 11) -bitmap ~/img/tiles/tile.xbm
|
xsetroot -fg "$(xcolor 14)" -bg "$(xcolor 11)" \
|
||||||
bspc config focused_border_color $(xcolor 3)
|
-bitmap ~/img/tiles/tile.xbm
|
||||||
bspc config normal_border_color $(xcolor 8)
|
bspc config focused_border_color "$(xcolor 3)"
|
||||||
bspc config presel_feedback_color $(xcolor 3)
|
bspc config normal_border_color "$(xcolor 8)"
|
||||||
|
bspc config presel_feedback_color "$(xcolor 3)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$1" == dark; then
|
if test "$1" = dark; then
|
||||||
xsetroot -fg \#4F5B66 -bg \#343D46 -bitmap ~/img/tiles/tile.xbm
|
xsetroot -fg \#4F5B66 -bg \#343D46 -bitmap ~/img/tiles/tile.xbm
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ deref() {
|
|||||||
|
|
||||||
fade_to() {
|
fade_to() {
|
||||||
current=$(brightness)
|
current=$(brightness)
|
||||||
echo $current $1
|
echo "$current $1"
|
||||||
step=10
|
step=10
|
||||||
[ "$current" -gt "$1" ] && sign=- || sign=+
|
[ "$current" -gt "$1" ] && sign=- || sign=+
|
||||||
for i in $(seq "$current" "${sign}$step" "$1"); do
|
for i in $(seq "$current" "${sign}$step" "$1"); do
|
||||||
|
@ -18,22 +18,22 @@ deref() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_brightness() {
|
set_brightness() {
|
||||||
sudo ddccontrol $device -r 0x10 -w > /dev/null $1 2>&1
|
sudo ddccontrol $device -r 0x10 -w > /dev/null "$1" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
fade_to() {
|
fade_to() {
|
||||||
current=$(sudo ddccontrol $device -r 0x10 2> /dev/null | grep -oP '\+/\K[0-9]+')
|
current=$(sudo ddccontrol $device -r 0x10 2> /dev/null | grep -oP '\+/\K[0-9]+')
|
||||||
[ $current -gt $1 ] && step=-1 || step=1
|
[ "$current" -gt "$1" ] && step=-1 || step=1
|
||||||
for i in $(seq $current $step $1); do
|
for i in $(seq "$current" "$step" "$1"); do
|
||||||
set_brightness $i
|
set_brightness "$i"
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if [ $1 = "period-changed" ]; then
|
if [ "$1" = "period-changed" ]; then
|
||||||
if ! (lsmod | grep -q "^i2c_dev"); then
|
if ! (lsmod | grep -q "^i2c_dev"); then
|
||||||
sudo modprobe i2c-dev
|
sudo modprobe i2c-dev
|
||||||
fi
|
fi
|
||||||
fade_to $(deref $3)
|
fade_to "$(deref "$3")"
|
||||||
fi
|
fi
|
||||||
|
57
scripts/wa
57
scripts/wa
@ -1,44 +1,41 @@
|
|||||||
#!/usr/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
## WolframAlpha CLI
|
## WolframAlpha CLI
|
||||||
|
|
||||||
# load api key
|
# load api key
|
||||||
token="${XDG_CONFIG_HOME:-$HOME}/wolfram"
|
token="$XDG_CONFIG_HOME/wolfram"
|
||||||
source $token
|
. "$token"
|
||||||
|
|
||||||
# properly encode query
|
# properly encode query
|
||||||
q=$(echo ${*} | sed 's/+/%2B/g' | tr '\ ' '\+')
|
q=$(echo "$*" | sed 's/+/%2B/g' | tr '\ ' '\+')
|
||||||
|
|
||||||
# fetch and parse result
|
# fetch and parse result
|
||||||
result=$(curl -s "http://api.wolframalpha.com/v2/query?input=${q}&appid=${API_KEY}&format=plaintext")
|
result="$(curl -s "http://api.wolframalpha.com/v2/query?input=$q&appid=$API_KEY&format=plaintext")"
|
||||||
|
|
||||||
if [ -n "$(echo ${result} | grep 'Invalid appid')" ] ; then
|
if echo "$result" | grep -q 'Invalid appid'; then
|
||||||
echo "Invalid API key!"
|
echo "Invalid API key!"
|
||||||
echo "Get one at https://developer.wolframalpha.com/portal/apisignup.html"
|
echo "Get one at https://developer.wolframalpha.com/portal/apisignup.html"
|
||||||
echo -n 'Enter your WolframAlpha API key:'
|
printf 'Enter your WolframAlpha API key:'
|
||||||
read api_key
|
read -r api_key
|
||||||
echo "API_KEY=${api_key}" >> $token
|
echo "API_KEY=${api_key}" >> "$token"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
result=`echo "${result}" \
|
echo "$result" |
|
||||||
| tr '\n' '\t' \
|
tr '\n' '\t' |
|
||||||
| sed -e 's/<plaintext>/\'$'\n<plaintext>/g' \
|
sed -e 's/<plaintext>/\n<plaintext>/g' |
|
||||||
| grep -oE "<plaintext>.*</plaintext>|<pod title=.[^\']*" \
|
grep -oE "<plaintext>.*</plaintext>|<pod title=.[^\']*" |
|
||||||
| sed -e 's!<plaintext>!!g; \
|
sed -e 's!<plaintext>!!g' \
|
||||||
s!</plaintext>!!g; \
|
-e 's!</plaintext>!!g' \
|
||||||
s!<pod title=.*!\\\x1b[1;36m&\\\x1b[0m!g; \
|
-e 's!<pod title=.*!\x1b[1;36m&\x1b[0m!g' \
|
||||||
s!^! !g; \
|
-e 's!^! !g' \
|
||||||
s!<pod title=.!\n!g; \
|
-e 's!<pod title=.!\n!g' \
|
||||||
s!\&!\&!g; \
|
-e 's!\&!\&!g' \
|
||||||
s!\<!<!g; \
|
-e 's!\<!<!g' \
|
||||||
s!\>!>!g; \
|
-e 's!\>!>!g' \
|
||||||
s!\"!"!g' \
|
-e 's!\"!"!g' \
|
||||||
-e "s/\'/'/g" \
|
-e "s/\'/'/g" |
|
||||||
| tr '\t' '\n' \
|
tr '\t' '\n' |
|
||||||
| sed '/^$/d; \
|
sed -e '/^$/d;' \
|
||||||
s/\ \ */\ /g; \
|
-e 's/\ \ */\ /g;' \
|
||||||
s/\\\:/\\\u/g'`
|
-e 's/\\\:/\\\u/g'
|
||||||
|
|
||||||
# print result
|
|
||||||
echo -e "${result}"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user