add some scripts
This commit is contained in:
parent
cec737e0f8
commit
5dd0007c04
12
Makefile
12
Makefile
|
@ -1,4 +1,7 @@
|
|||
install: man sh c
|
||||
all: mkc
|
||||
install: man sh mkc c
|
||||
.PHONY: man sh mkc c
|
||||
|
||||
man:
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/man1
|
||||
cp -f *.1 $(DESTDIR)$(PREFIX)/man1
|
||||
|
@ -6,6 +9,11 @@ sh:
|
|||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f scripts/paste $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f scripts/bat $(DESTDIR)$(PREFIX)/bin
|
||||
c:
|
||||
cp -f scripts/disp $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f scripts/shime $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f scripts/wall $(DESTDIR)$(PREFIX)/bin
|
||||
cp -f scripts/yt $(DESTDIR)$(PREFIX)/bin
|
||||
mkc:
|
||||
cc progs/scream.c -o progs/scream
|
||||
c:
|
||||
cp -f progs/scream $(DESTDIR)$(PREFIX)/bin
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
|
||||
exists() {
|
||||
xrandr | grep ' connected' | grep "${1}" | wc -l
|
||||
}
|
||||
|
||||
# usual setup: thinkpad x220 on dock connected to external
|
||||
# monitor
|
||||
|
||||
[ $(exists "HDMI2") -gt 0 ] && \
|
||||
[ $(exists "LVDS1") -gt 0 ] && \
|
||||
xrandr --output LVDS1 --below HDMI2 --auto && \
|
||||
exit 0 || exit 1
|
||||
|
||||
# thinkpad x220 connected to display on local port
|
||||
|
||||
[ $(exists "HDMI1") -gt 0 ] && \
|
||||
[ $(exists "LVDS1") -gt 0 ] && \
|
||||
xrandr --output LVDS1 --below HDMI1 --auto && \
|
||||
exit 0 || exit 1
|
||||
|
||||
# only the thinkpad
|
||||
|
||||
[ $(exists "HDMI2") -eq 0 ] && \
|
||||
[ $(exists "LVDS1") -gt 0 ] && \
|
||||
xrandr --output LVDS1 --auto && \
|
||||
exit 0 || exit 1
|
||||
|
||||
exit 1
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
WALLDIR="${HOME}/.share/wallpapers"
|
||||
BASECMD="feh --bg-fill"
|
||||
|
||||
generate_wall () {
|
||||
GENWALL=$( \
|
||||
ls $WALLDIR | \
|
||||
shuf -n 1
|
||||
)
|
||||
GENWALL="${WALLDIR}/${GENWALL}"
|
||||
}
|
||||
wall () {
|
||||
generate_wall
|
||||
while [ "${GENWALL}" = "${1}" ]; do
|
||||
generate_wall
|
||||
done
|
||||
}
|
||||
displays () {
|
||||
displays=$(xrandr | grep ' connected' | wc -l)
|
||||
}
|
||||
check () {
|
||||
which $1 &>/dev/null
|
||||
}
|
||||
|
||||
cmd=""
|
||||
check "feh" || exit 1
|
||||
if check "xrandr"; then
|
||||
displays
|
||||
for i in $(seq 1 $displays); do
|
||||
wall ${tmp}
|
||||
tmp=${GENWALL}
|
||||
echo ${GENWALL} ${i}
|
||||
cmd="${cmd} ${GENWALL}"
|
||||
done
|
||||
eval ${BASECMD} ${cmd}
|
||||
else
|
||||
generate_wall
|
||||
eval ${BASECMD} ${GENWALL}
|
||||
fi
|
||||
unset GENWALL BASECMD tmp cmd displays i
|
||||
exit 0
|
43
scripts/yt
43
scripts/yt
|
@ -1,25 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
DATFILE="${HOME}/.config/youtube/dat"
|
||||
CACHEDIR="${HOME}/.config/youtube/cache"
|
||||
tmp1=$(mktemp)
|
||||
tmp2=$(mktemp)
|
||||
[ -z "${YT_DATFILE}" ] && YT_DATFILE="${HOME}/.local/share/ytdat"
|
||||
[ -z "${YT_CACHEDIR}" ] && YT_CACHEDIR="${HOME}/.local/share/ytcache"
|
||||
ver=0.1
|
||||
|
||||
touch $DATFILE
|
||||
mkdir -p $CACHEDIR
|
||||
|
||||
info () {
|
||||
printf %s "\
|
||||
yt - youtube tool
|
||||
|
||||
=> [s]ync - Sync RSS feeds
|
||||
=> [a]dd [id] - Add a channel to the list
|
||||
=> [d]el [id] - Remove a channel from the list
|
||||
=> [h]elp - Show this help
|
||||
|
||||
List file: export DATFILE=<your file here>
|
||||
Cache directory: export CACHEDIR=<your dir here>
|
||||
|
||||
see yt(1) for more information on usage
|
||||
"
|
||||
}
|
||||
sync () {
|
||||
for i in $(cat $DATFILE | tr '\n' ' '); do
|
||||
for i in $(cat $YT_DATFILE | tr '\n' ' '); do
|
||||
torify curl -s \
|
||||
https://www.youtube.com/feeds/videos.xml?channel_id=$i\
|
||||
> ${CACHEDIR}/$i
|
||||
> ${YT_CACHEDIR}/$i
|
||||
done
|
||||
}
|
||||
display () {
|
||||
for i in $(ls $CACHEDIR | tr '\n' ' '); do
|
||||
grep \<media:title\> ${CACHEDIR}/$i | cut -c 17- | \
|
||||
tmp1=$(mktemp)
|
||||
tmp2=$(mktemp)
|
||||
for i in $(ls $YT_CACHEDIR | tr '\n' ' '); do
|
||||
grep \<media:title\> ${YT_CACHEDIR}/$i | cut -c 17- | \
|
||||
rev | cut -c 15- | rev >> $tmp1
|
||||
grep 'link rel' ${CACHEDIR}/$i | grep 'watch' | \
|
||||
grep 'link rel' ${YT_CACHEDIR}/$i | grep 'watch' | \
|
||||
cut -c31- | rev | cut -c4- | rev >> $tmp2
|
||||
done
|
||||
cat $tmp1 $tmp2 | pr -2t -s" | "
|
||||
|
@ -31,15 +47,18 @@ del () { # $1: line number of channel id
|
|||
sed -i "${1}d" $DATFILE
|
||||
}
|
||||
case $1 in
|
||||
*"sync"*)
|
||||
*"s"*)
|
||||
sync
|
||||
;;
|
||||
*"add"*)
|
||||
*"a"*)
|
||||
[ $# -eq 2 ] && add $2
|
||||
;;
|
||||
*"del"*)
|
||||
*"d"*)
|
||||
[ $# -eq 2 ] && del $2
|
||||
;;
|
||||
*"h"*)
|
||||
info
|
||||
;;
|
||||
*)
|
||||
display
|
||||
;;
|
||||
|
|
Loading…
Reference in New Issue