removing breaking section from disp and retab shime, yt

This commit is contained in:
randomuser 2021-02-16 10:31:48 -06:00
parent 1abf6914e9
commit a2055f3deb
3 changed files with 78 additions and 88 deletions

View File

@ -4,16 +4,6 @@ exists() {
xrandr | grep ' connected' | grep "${1}" | wc -l xrandr | grep ' connected' | grep "${1}" | wc -l
} }
# commands
[ "$1" = "big" ] && \
xrandr --output LVDS1 --off && \
exit 0 || exit 1
[ "$1" = "small" ] && \
xrandr --output HDMI2 --off && \
exit 0 || exit 1
# usual setup: thinkpad x220 on dock connected to external # usual setup: thinkpad x220 on dock connected to external
# monitor # monitor

View File

@ -1,52 +1,52 @@
#!/bin/sh #!/bin/sh
case $0 in case $0 in
*"timer"*) *"timer"*)
[ $# -ne 2 ] && printf "specify minutes and \ [ $# -ne 2 ] && printf "specify minutes and \
seconds\n" && exit 1 seconds\n" && exit 1
sleep $(($1 * 60 + $2)) sleep $(($1 * 60 + $2))
printf "your timer is done\a\n" printf "your timer is done\a\n"
exit 0 exit 0
;; ;;
*"alarm"*) *"alarm"*)
[ $# -ne 1 ] && printf "specify time\n" && exit 1 [ $# -ne 1 ] && printf "specify time\n" && exit 1
ttw=$(($(date +%s --date="$1 tomorrow") - $(date +%s))) ttw=$(($(date +%s --date="$1 tomorrow") - $(date +%s)))
sleep $ttw sleep $ttw
printf "your alarm is done\a\n" printf "your alarm is done\a\n"
exit 0 exit 0
;; ;;
*"tomato"*) *"tomato"*)
[ $# -ne 2 ] && \ [ $# -ne 2 ] && \
printf "specify work and rest time\n" && exit 1 printf "specify work and rest time\n" && exit 1
counter=0 counter=0
while true; do while true; do
printf "start work cycle %s\a\n" $(($counter + 1)) printf "start work cycle %s\a\n" $(($counter + 1))
sleep $(($1 * 60)) sleep $(($1 * 60))
printf "start rest cycle %s\a\n" $(($counter + 1)) printf "start rest cycle %s\a\n" $(($counter + 1))
sleep $(($2 * 60)) sleep $(($2 * 60))
counter=$(($counter + 1)) counter=$(($counter + 1))
done done
exit 0 exit 0
;; ;;
*"stopwatch"*) *"stopwatch"*)
now=$(date +%s) now=$(date +%s)
read var read var
printf "%s\n" $(($(date +%s) - $now)) printf "%s\n" $(($(date +%s) - $now))
exit 0 exit 0
;; ;;
*"verbosewatch"*) *"verbosewatch"*)
min=0 min=0
sec=0 sec=0
while true; do while true; do
printf "%02d:%02d\r" $min $sec printf "%02d:%02d\r" $min $sec
sleep 1 sleep 1
sec=$(($sec + 1)) sec=$(($sec + 1))
[ $sec -eq 60 ] && min=$(($min + 1)) && sec=0 [ $sec -eq 60 ] && min=$(($min + 1)) && sec=0
done done
exit 0 exit 0
;; ;;
*) *)
printf "unknown invocation\n" printf "unknown invocation\n"
exit 2 exit 2
;; ;;
esac esac

View File

@ -23,44 +23,44 @@ see yt(1) for more information on usage
" "
} }
sync () { sync () {
for i in $(cat $YT_DATFILE | tr '\n' ' '); do for i in $(cat $YT_DATFILE | tr '\n' ' '); do
torify curl -s \ torify curl -s \
https://www.youtube.com/feeds/videos.xml?channel_id=$i\ https://www.youtube.com/feeds/videos.xml?channel_id=$i\
> ${YT_CACHEDIR}/$i > ${YT_CACHEDIR}/$i
done done
} }
display () { display () {
tmp1=$(mktemp) tmp1=$(mktemp)
tmp2=$(mktemp) tmp2=$(mktemp)
for i in $(ls $YT_CACHEDIR | tr '\n' ' '); do for i in $(ls $YT_CACHEDIR | tr '\n' ' '); do
grep \<media:title\> ${YT_CACHEDIR}/$i | cut -c 17- | \ grep \<media:title\> ${YT_CACHEDIR}/$i | cut -c 17- | \
rev | cut -c 15- | rev >> $tmp1 rev | cut -c 15- | rev >> $tmp1
grep 'link rel' ${YT_CACHEDIR}/$i | grep 'watch' | \ grep 'link rel' ${YT_CACHEDIR}/$i | grep 'watch' | \
cut -c31- | rev | cut -c4- | rev >> $tmp2 cut -c31- | rev | cut -c4- | rev >> $tmp2
done done
cat $tmp1 $tmp2 | pr -2t -s" | " cat $tmp1 $tmp2 | pr -2t -s" | "
} }
add () { # $1: name of channel id add () { # $1: name of channel id
printf "%s\n" $1 >> $DATFILE printf "%s\n" $1 >> $DATFILE
} }
del () { # $1: line number of channel id del () { # $1: line number of channel id
sed -i "${1}d" $DATFILE sed -i "${1}d" $DATFILE
} }
case $1 in case $1 in
*"s"*) *"s"*)
sync sync
;; ;;
*"a"*) *"a"*)
[ $# -eq 2 ] && add $2 [ $# -eq 2 ] && add $2
;; ;;
*"d"*) *"d"*)
[ $# -eq 2 ] && del $2 [ $# -eq 2 ] && del $2
;; ;;
*"h"*) *"h"*)
info info
;; ;;
*) *)
display display
;; ;;
esac esac
exit 0 exit 0