inital commit
This commit is contained in:
8
.local/bin/tools/bright
Executable file
8
.local/bin/tools/bright
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
case $1 in
|
||||
"set") printf %0.f $( echo "scale=0; $2 * 9.37" | bc -l ) > /sys/class/backlight/intel_backlight/brightness;;
|
||||
"add") current=$( </sys/class/backlight/intel_backlight/brightness )
|
||||
new=$( printf %.0f $(echo "$current + $2 * 9.37" | bc -l ) )
|
||||
[ $new -gt 936 ] && bright set 937 || ( [ $new -lt 0 ] && bright set 0 || bright set "$(( new + 1 ))" ) ;;
|
||||
"del") bright add "-$2";;
|
||||
esac
|
1
.local/bin/tools/bt_blacklist
Normal file
1
.local/bin/tools/bt_blacklist
Normal file
@ -0,0 +1 @@
|
||||
MX Master
|
77
.local/bin/tools/bthandler_
Executable file
77
.local/bin/tools/bthandler_
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
#wait time to discover new devices in seconds
|
||||
SCAN_PERIOD=5
|
||||
BLACKLIST=$HOME/.local/bin/tools/bt_blacklist
|
||||
actions="turn off\nturn on\npair\nunpair"
|
||||
|
||||
#Checks for necessary programs to be present. Very unlikely not to be present but let's just err on the safer side.
|
||||
for prog in dmenu bluetoothctl awk cat; do
|
||||
if ! hash "$prog" 2>/dev/null; then
|
||||
printf 'bthandler: %s: command not found\n' "$prog" >&2
|
||||
exit 127
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
bluetoothctl paired-devices | awk '{print $2}' > /tmp/bt_IDS
|
||||
bluetoothctl paired-devices | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' > /tmp/paired_devices
|
||||
grep -vf "$BLACKLIST" /tmp/paired_devices > /tmp/disp_devices
|
||||
|
||||
#Don't print empty device list, removes unnecessary empty choice in dmenu
|
||||
len=$(cat /tmp/disp_devices | wc -l)
|
||||
[ $len -gt 0 ] && choice=$( printf "$(< /tmp/disp_devices)\n$actions" | dmenu -i -p 'What BT action would you like to perform:' )
|
||||
[ $len -eq 0 ] && choice=$( printf "$actions" | dmenu -i -p 'What BT action would you like to perform:' )
|
||||
|
||||
cleanup(){
|
||||
rm -f /tmp/bt_devices
|
||||
rm -f /tmp/bt_IDS
|
||||
rm -f /tmp/paired_devices
|
||||
rm -f /tmp/new_devices
|
||||
rm -f /tmp/disp_devices
|
||||
bluetoothctl scan off > /dev/null
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
case $choice in
|
||||
"turn on") bluetoothctl power on
|
||||
cleanup;;
|
||||
"turn off") bluetoothctl power off
|
||||
cleanup;;
|
||||
"scan on") bluetoothctl power on && echo power on && sleep 2
|
||||
[ -n $TERMINAL ] && ($TERMINAL -e bluetoothctl scan on ) || st bluetoothctl scan on
|
||||
cleanup;;
|
||||
"pair") bluetoothctl power on
|
||||
bluetoothctl scan on & disown
|
||||
notify-send "Bluetooth" "Searching for devices, please wait a bit"
|
||||
sleep $SCAN_PERIOD
|
||||
bluetoothctl devices | awk '{for (i=3; i<NF; i++) printf $i " "; print $NF}' > /tmp/bt_devices
|
||||
grep -vf /tmp/paired_devices /tmp/bt_devices > /tmp/new_devices
|
||||
choice=$( cat /tmp/new_devices | dmenu -l 10 -i -p 'pair with which device?' )
|
||||
if [ -n "$choice" ]; then
|
||||
bluetoothctl devices | awk '{print $2}' > /tmp/bt_IDS
|
||||
dev_no=$(cat -n /tmp/bt_devices | grep "$choice" | awk '{print $1}')
|
||||
dev_id=$(cat -n /tmp/bt_IDS | grep -E $dev_no"[[:space:]]" | awk '{print $2}' )
|
||||
|
||||
bluetoothctl pair $dev_id && sleep 2
|
||||
bluetoothctl connect $dev_id
|
||||
fi
|
||||
cleanup;;
|
||||
"unpair") choice=$( cat /tmp/paired_devices | dmenu -l 10 -i -p 'remove which paired device?')
|
||||
if [ -n "choice" ]; then
|
||||
dev_no=$(cat -n /tmp/paired_devices | grep "$choice" | awk '{print $1}')
|
||||
dev_id=$(cat -n /tmp/bt_IDS | grep -E $dev_no"[[:space:]]" | awk '{print $2}' )
|
||||
bluetoo
|
||||
bluetoothctl remove $dev_id
|
||||
fi
|
||||
cleanup;;
|
||||
esac
|
||||
|
||||
if [ -n "$choice" ]; then
|
||||
dev_no=$(cat -n /tmp/paired_devices | grep "$choice" | awk '{print $1}')
|
||||
dev_id=$(cat -n /tmp/bt_IDS | grep $dev_no | awk '{print $2}')
|
||||
bluetoothctl power on
|
||||
bluetoothctl connect $dev_id
|
||||
fi
|
||||
|
||||
cleanup
|
12
.local/bin/tools/casttest
Executable file
12
.local/bin/tools/casttest
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
video=$1
|
||||
speed=${2:-1}
|
||||
echo "speed: $speed"
|
||||
slowness="$( echo $speed | bc -l )"
|
||||
echo "slowness: $slowness"
|
||||
rate=$( ffmpeg -i $video | sed -n "s/.*, \(.*\) tbr.*/\1/p" )
|
||||
echo "oldrate: $rate"
|
||||
newrate=$( echo "scale=0; $speed * $rate" | bc -l )
|
||||
echo "newrate: $newrate"
|
||||
command=ffmpeg -re -i "$video" -r $newrate filter:v "setpts=$slowness*PTS" pipe:1
|
||||
mkchromecast --video --control --command "$command"
|
2
.local/bin/tools/castyt
Executable file
2
.local/bin/tools/castyt
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
mkchromecast --notifications --video --control -y $1 2>/dev/null || true
|
4
.local/bin/tools/ce
Executable file
4
.local/bin/tools/ce
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
currentdir="$(pwd)"
|
||||
file="$( du -a ~/.config/* ~/.local/src/* ~/.local/bin/* | awk '{print $2}' | fzf -e --query="$*")"
|
||||
[ "$file" = "" ] || ( cd "$( dirname "$file" )" && $EDITOR "$file" && cd "$currentdir" )
|
2
.local/bin/tools/clip
Executable file
2
.local/bin/tools/clip
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
xclip -o -selection "clipboard"
|
58
.local/bin/tools/dmenu_run_history
Executable file
58
.local/bin/tools/dmenu_run_history
Executable file
@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
aliases=$HOME/.config/aliasrc
|
||||
|
||||
source $aliases
|
||||
termcmd="st -e"
|
||||
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
|
||||
if [ -d "$cachedir" ]; then
|
||||
cache=$cachedir/dmenu_run
|
||||
historyfile=$cachedir/dmenu_history
|
||||
else # if no xdg dir, fall back to dotfiles in ~
|
||||
cache=$HOME/.dmenu_cache
|
||||
historyfile=$HOME/.dmenu_history
|
||||
fi
|
||||
|
||||
IFS=:
|
||||
if stest -dqr -n "$cache" $PATH; then
|
||||
stest -flx $PATH | sort -u > "$cache"
|
||||
fi
|
||||
unset IFS
|
||||
|
||||
cmd=$(awk -v histfile=$historyfile '
|
||||
BEGIN {
|
||||
while( (getline < histfile) > 0 ) {
|
||||
sub("^[0-9]+\t","")
|
||||
print
|
||||
x[$0]=1
|
||||
}
|
||||
} !x[$0]++ ' "$cache" \
|
||||
| dmenu "$@" \
|
||||
| awk -v histfile=$historyfile '
|
||||
BEGIN {
|
||||
FS=OFS="\t"
|
||||
while ( (getline < histfile) > 0 ) {
|
||||
count=$1
|
||||
sub("^[0-9]+\t","")
|
||||
fname=$0
|
||||
history[fname]=count
|
||||
}
|
||||
close(histfile)
|
||||
}
|
||||
|
||||
{
|
||||
history[$0]++
|
||||
print
|
||||
}
|
||||
|
||||
END {
|
||||
if(!NR) exit
|
||||
for (f in history)
|
||||
print history[f],f | "sort -t '\t' -k1rn >" histfile
|
||||
}
|
||||
' )
|
||||
|
||||
case $cmd in
|
||||
*\! ) ${termcmd} "$(printf "%s" "${cmd}" | cut -d'!' -f1)";;
|
||||
* ) ${cmd} ;;
|
||||
esac
|
||||
exit
|
20
.local/bin/tools/dmenuhandler
Executable file
20
.local/bin/tools/dmenuhandler
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Feed this script a link and it will give dmenu
|
||||
# some choice programs to use to open it.
|
||||
|
||||
case "$(printf "mpv\\ncopy url\\nqueue download\\n\\nqueue youtube-dl\\nbrowser\\nrip media\\ncast" | dmenu -i -p "Open link with what program?")" in
|
||||
"copy url") echo "$1" | xclip -selection clipboard ;;
|
||||
mpv) setsid mpv --quiet --ytdl-format='bestvideo[height<=1080]+bestaudio/best[height<=1080]' "$1" & ;;
|
||||
"mpv (loop)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet --loop "$1" >/dev/null 2>&1 & ;;
|
||||
"queue download") name="$( dmenuinput 'Name for file:' )"
|
||||
tsp curl -L -o $name "$1" >/dev/null 2>&1 ;;
|
||||
"queue youtube-dl") youtube-dl --write-metadata -i -o '/home/alex/%(upload_date)s-%(title)s.%(ext)s' "$1" >/dev/null 2>&1 ;;
|
||||
cast) setsid $TERMINAL -e mkchromecast -y $1 --video --control
|
||||
;;
|
||||
browser) setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;;
|
||||
#feh) setsid feh "$1" >/dev/null 2>&1 & ;;
|
||||
#w3m) w3m "$1" >/dev/null 2>&1 ;;
|
||||
#"mpv (float)") setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) --geometry=+0-0 --autofit=30% --title="mpvfloat" "$1" >/dev/null 2>&1 & ;;
|
||||
"rip media") dest="$(dmenuinput 'name of folder:')"
|
||||
[ "$dest" != "" ] && ( lynx --dump --nonumbers --listonly $1 | grep -E "(*\.webm|*\.mp4|\.gif|\.jpg|\.jpeg|\.png)" | sort -u | xargs wget -P /home/alex/$dest ) || ( lynx --dump --nonumbers --listonly $1 | grep -E "(*\.webm|*\.mp4|\.gif|\.jpg|\.jpeg|\.png)" | sort -u | xargs wget -P /home/alex/ );;
|
||||
esac
|
3
.local/bin/tools/dmenuinput
Executable file
3
.local/bin/tools/dmenuinput
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
dmenu -fn Monospace-13 -p "$1" <&- && echo
|
||||
|
2
.local/bin/tools/dmenupass
Executable file
2
.local/bin/tools/dmenupass
Executable file
@ -0,0 +1,2 @@
|
||||
!/bin/sh
|
||||
dmenu -fn Monospace-13 -sb "#d79921" -sf "#1d2021" -nf "#000000" -nb "#000000" -p "$1" <&- && echo
|
6
.local/bin/tools/email_handler
Executable file
6
.local/bin/tools/email_handler
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
input=$1
|
||||
while read -r str
|
||||
do
|
||||
[[ $(grep -c "$str" "$input") == 1 ]] && echo $str
|
||||
done < "$input"
|
3
.local/bin/tools/epdf
Executable file
3
.local/bin/tools/epdf
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
pdf="$(du -a --time ETH/ | awk '!($1="")' | sort -r | grep '\.pdf' | awk '!($1="")' | awk '!($1="")' | sed 's/^ //' | dmenu -l 20 )"
|
||||
[ -z $pdf ] || $READER "$pdf"
|
2
.local/bin/tools/ethvpn
Executable file
2
.local/bin/tools/ethvpn
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
[ $( pgrep -c openconnect ) -eq 0 ] &&( dmenupass "Password for ETH-VPN:" | sudo openconnect -g student-net -u abocken@student-net.ethz.ch --passwd-on-stdin sslvpn.ethz.ch ) || ( sudo pkill openconnect; notify-send "ETH VPN" "ETH VPN disconnected")
|
3
.local/bin/tools/ewv
Executable file
3
.local/bin/tools/ewv
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
video=$(du -a ~/eth/videos/* --time | awk '!($1="")' | sort -bg | awk '!($1="")' | awk '!($1="")' | sed 's/^ \/home\/alex\/eth\/videos\///' | grep -E "\....$"| tac | dmenu -l 10 -p "What lecture would you like to watch?");
|
||||
[ -z $video ] || ( mpv "/home/alex/eth/videos/$video" & disown )
|
1
.local/bin/tools/ext
Symbolic link
1
.local/bin/tools/ext
Symbolic link
@ -0,0 +1 @@
|
||||
extract
|
41
.local/bin/tools/extract
Executable file
41
.local/bin/tools/extract
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# A general, all-purpose extraction script.
|
||||
#
|
||||
# Default behavior: Extract archive into new directory
|
||||
# Behavior with `-c` option: Extract contents into current directory
|
||||
|
||||
while getopts "hc" o; do case "${o}" in
|
||||
c) extracthere="True" ;;
|
||||
*) printf "Options:\\n -c: Extract archive into current directory rather than a new one.\\n" && exit ;;
|
||||
esac done
|
||||
|
||||
if [ -z "$extracthere" ]; then
|
||||
archive="$(readlink -f "$*")" &&
|
||||
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
|
||||
mkdir -p "$directory" &&
|
||||
cd "$directory" || exit
|
||||
else
|
||||
archive="$(readlink -f "$(echo "$*" | cut -d' ' -f2)")"
|
||||
fi
|
||||
|
||||
[ "$archive" = "" ] && printf "Give archive to extract as argument.\\n" && exit
|
||||
|
||||
if [ -f "$archive" ] ; then
|
||||
case "$archive" in
|
||||
*.tar.bz2|*.tar.xz|*.tbz2) tar xvjf "$archive" ;;
|
||||
*.tar.gz|*.tgz) tar xvzf "$archive" ;;
|
||||
*.lzma) unlzma "$archive" ;;
|
||||
*.bz2) bunzip2 "$archive" ;;
|
||||
*.rar) unrar x -ad "$archive" ;;
|
||||
*.gz) gunzip "$archive" ;;
|
||||
*.tar) tar xvf "$archive" ;;
|
||||
*.zip) unzip "$archive" ;;
|
||||
*.Z) uncompress "$archive" ;;
|
||||
*.7z) 7z x "$archive" ;;
|
||||
*.xz) unxz "$archive" ;;
|
||||
*.exe) cabextract "$archive" ;;
|
||||
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
|
||||
esac
|
||||
else
|
||||
printf "File \"%s\" not found.\\n" "$archive"
|
||||
fi
|
3
.local/bin/tools/fix_devices
Normal file
3
.local/bin/tools/fix_devices
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
Device 00:00:00:00:3F:F3 TOZO-T10-R
|
||||
Device 00:00:00:00:3F:F3 TOZO-T10-R
|
14
.local/bin/tools/getbib
Executable file
14
.local/bin/tools/getbib
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit
|
||||
|
||||
if [ -f "$1" ]; then
|
||||
# Try to get DOI from pdfinfo or pdftotext output.
|
||||
doi=$(pdfinfo "$1" | grep -io "doi:.*") ||
|
||||
doi=$(pdftotext "$1" 2>/dev/null - | grep -io "doi:.*" -m 1) ||
|
||||
exit 1
|
||||
else
|
||||
doi="$1"
|
||||
fi
|
||||
|
||||
# Check crossref.org for the bib citation.
|
||||
curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex" -w "\\n"
|
4
.local/bin/tools/getkeys
Executable file
4
.local/bin/tools/getkeys
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
cat ~/.config/getkeys/"$1" 2>/dev/null && exit
|
||||
echo "Run command with one of the following arguments for info about that program:"
|
||||
ls ~/.config/getkeys
|
3
.local/bin/tools/ifinstalled
Executable file
3
.local/bin/tools/ifinstalled
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# If $1 command is not available, error code and notify.
|
||||
command -v "$1" >/dev/null || { notify-send "📦 $1" "must be installed for this function." && exit 1 ;}
|
13
.local/bin/tools/importvocabs
Executable file
13
.local/bin/tools/importvocabs
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
#arg 1: xlsx file
|
||||
current_dir="$pwd"
|
||||
cd $HOME/src/GRE/
|
||||
find *.xlsx | xargs git rm
|
||||
find *.csv | xargs git rm
|
||||
cd "$current_dir"
|
||||
xlsx2csv -d 'tab' $1 | tail -n +3 > "$HOME/src/GRE/${1%xlsx}csv"
|
||||
mv $1 $HOME/src/GRE
|
||||
cd $HOME/src/GRE/
|
||||
git add "$1"
|
||||
git add "${1%xlsx}csv"
|
||||
cd "$current_dir"
|
22
.local/bin/tools/linkhandler
Executable file
22
.local/bin/tools/linkhandler
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Feed script a url or file location.
|
||||
# If an image, it will view in sxiv,
|
||||
# if a video or gif, it will view in mpv
|
||||
# if a music file or pdf, it will download,
|
||||
# otherwise it opens link in browser.
|
||||
|
||||
# If no url given. Opens browser. For using script as $BROWSER.
|
||||
[ -z "$1" ] && { "$BROWSER"; exit; }
|
||||
|
||||
case "$1" in
|
||||
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*)
|
||||
setsid mpv --input-ipc-server=/tmp/mpvsoc$(date +%s) -quiet "$1" >/dev/null 2>&1 & ;;
|
||||
*png|*jpg|*jpe|*jpeg|*gif)
|
||||
curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;;
|
||||
*mp3|*flac|*opus|*mp3?source*)
|
||||
setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
|
||||
*)
|
||||
if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
|
||||
else setsid "$BROWSER" "$1" >/dev/null 2>&1 & fi ;;
|
||||
esac
|
42
.local/bin/tools/lmc
Executable file
42
.local/bin/tools/lmc
Executable file
@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# A general audio interface for LARBS.
|
||||
|
||||
[ -z "$2" ] && num="2" || num="$2"
|
||||
|
||||
case "$1" in
|
||||
u*) pulsemixer --change-volume +"$num" ;;
|
||||
d*) pulsemixer --change-volume -"$num" ;;
|
||||
m*) pulsemixer --toggle-mute ;;
|
||||
truemute) pulsemixer --mute ;;
|
||||
play) mpc play ;;
|
||||
n*) mpc next ;;
|
||||
prev) mpc prev ;;
|
||||
t*) mpc toggle ;;
|
||||
p*) mpc pause ; pauseallmpv ;;
|
||||
f*) mpc seek +"$num" ;;
|
||||
b*) mpc seek -"$num" ;;
|
||||
r*) mpc seek 0% ;;
|
||||
*) cat << EOF
|
||||
lmc: cli music interface for mpd and pulse for those with divine intellect too
|
||||
grand to remember the mpc/pamixer commands.
|
||||
|
||||
Allowed options:
|
||||
up NUM Increase volume (2 secs default)
|
||||
down NUM Decrease volume (2 secs default)
|
||||
mute Toggle mute
|
||||
truemute Mute
|
||||
next Next track
|
||||
prev Previous track
|
||||
toggle Toggle pause
|
||||
truepause Pause
|
||||
foward NUM Seek foward in song (2 secs default)
|
||||
back NUM Seek back in song (2 secs default)
|
||||
restart Restart current song
|
||||
all else Print this message
|
||||
|
||||
All of these commands, except for \`truemute\`, \`prev\` and \`play\` can be truncated,
|
||||
i.e. \`lmc r\` for \`lmc restart\`.
|
||||
EOF
|
||||
esac
|
||||
|
||||
pkill -RTMIN+10 i3blocks
|
11
.local/bin/tools/opout
Executable file
11
.local/bin/tools/opout
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# opout: "open output": A general handler for opening a file's intended output.
|
||||
# I find this useful especially running from vim.
|
||||
|
||||
basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
|
||||
|
||||
case "$1" in
|
||||
*.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;;
|
||||
*.html) setsid "$BROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;;
|
||||
*.sent) setsid sent "$1" >/dev/null 2>&1 & ;;
|
||||
esac
|
64
.local/bin/tools/passmenu2
Executable file
64
.local/bin/tools/passmenu2
Executable file
@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
shopt -s nullglob globstar
|
||||
|
||||
typeit=0
|
||||
if [[ $1 == "--type" ]]; then
|
||||
typeit=1
|
||||
shift
|
||||
fi
|
||||
|
||||
|
||||
STARTDIR=${PASSWORD_STORE_DIR-~/.password-store}
|
||||
BASEDIR=$STARTDIR
|
||||
DONE=0
|
||||
LEVEL=0
|
||||
PREVSELECTION=""
|
||||
SELECTION=""
|
||||
|
||||
while [ "$DONE" -eq 0 ] ; do
|
||||
password_files=( "$STARTDIR"/* )
|
||||
password_files=( "${password_files[@]#"$STARTDIR"/}" )
|
||||
password_files=( "${password_files[@]%.gpg}" )
|
||||
|
||||
if [ "$LEVEL" -ne 0 ] ; then
|
||||
password_files=(".." "${password_files[@]}")
|
||||
fi
|
||||
entry=$(printf '%s\n' "${password_files[@]}" | grep -v 'mutt'| dmenu -i -p "Select a password:" "$@" -l 15)
|
||||
|
||||
echo "entry: $entry"
|
||||
if [ -z "$entry" ] ; then
|
||||
DONE=1
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$entry" != ".." ] ; then
|
||||
PREVSELECTION=$SELECTION
|
||||
SELECTION="$SELECTION/$entry"
|
||||
|
||||
# check if another dir
|
||||
if [ -d "$STARTDIR/$entry" ] ; then
|
||||
STARTDIR="$STARTDIR/$entry"
|
||||
LEVEL=$((LEVEL+1))
|
||||
else
|
||||
# not a directory so it must be a real password entry
|
||||
|
||||
if [[ $typeit -eq 0 ]]; then
|
||||
pass show -c "$SELECTION" > $HOME/.cache/passstring
|
||||
sed -e "s/^/\"/" -e "s/$/\"/" $HOME/.cache/passstring | xargs -r notify-send "Password" -t 4000
|
||||
sleep 45
|
||||
[ -f $HOME/.cache/passstring ] && notify-send "Password" "password cleared from clipboard" -t 4000
|
||||
rm $HOME/.cache/passstring
|
||||
|
||||
else
|
||||
xdotool - <<<"type --clearmodifiers -- $(pass show "$SELECTION" | head -n 1)"
|
||||
fi
|
||||
DONE=1
|
||||
fi
|
||||
|
||||
else
|
||||
LEVEL=$((LEVEL-1))
|
||||
SELECTION=$PREVSELECTION
|
||||
STARTDIR="$BASEDIR/$SELECTION"
|
||||
fi
|
||||
done
|
4
.local/bin/tools/pauseallmpv
Executable file
4
.local/bin/tools/pauseallmpv
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
for i in $(ls /tmp/mpvsoc*); do
|
||||
echo '{ "command": ["set_property", "pause", true] }' | socat - $i;
|
||||
done
|
34
.local/bin/tools/plot
Executable file
34
.local/bin/tools/plot
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
echo $1
|
||||
sed "9s/.*/func = lambda x: $1/" "/home/alex/.local/bin/tools/plotter.py" > /tmp/plotter_temp.py
|
||||
if [ ! -z $(echo $2 | grep "a=") ]; then
|
||||
echo $2
|
||||
echo "Has found attribute a="
|
||||
sed "13s/.*/$2/" "/tmp/plotter_temp.py" > /tmp/plotter_temp2.py
|
||||
cat "/tmp/plotter_temp2.py" > /tmp/plotter_temp.py
|
||||
a=0
|
||||
fi
|
||||
|
||||
if [ ! -z $(echo $3 | grep "b=") ]; then
|
||||
echo $3
|
||||
echo "has found attribute b="
|
||||
sed "14s/.*/$3/" "/tmp/plotter_temp.py" > /tmp/plotter_temp2.py
|
||||
cat "/tmp/plotter_temp2.py" > /tmp/plotter_temp.py
|
||||
b=0
|
||||
fi
|
||||
|
||||
if [ -z $(echo $2 | grep "a=") ]; then
|
||||
echo $2
|
||||
a=$2
|
||||
fi
|
||||
|
||||
if [ -z $(echo $3 | grep "b=") ]; then
|
||||
echo $3
|
||||
b=$3
|
||||
fi
|
||||
|
||||
rm -f /tmp/plotter_temp2.py
|
||||
python /tmp/plotter_temp.py "$1" $2 $3
|
||||
sxiv -b /tmp/plot.png
|
||||
rm -f /tmp/plot.png
|
||||
#rm /tmp/plotter_temp.py
|
197
.local/bin/tools/plotter.py
Normal file
197
.local/bin/tools/plotter.py
Normal file
@ -0,0 +1,197 @@
|
||||
import matplotlib.pyplot as plt
|
||||
from numpy import *
|
||||
import sys
|
||||
import re
|
||||
|
||||
#limits of function:
|
||||
#put function here
|
||||
func=lambda x: 1
|
||||
|
||||
|
||||
if(len(sys.argv) == 4):
|
||||
a_s = sys.argv[2]
|
||||
b_s = sys.argv[3]
|
||||
func_string = sys.argv[1]
|
||||
|
||||
print("a_s: {}".format(a_s))
|
||||
print("b_s: {}".format(b_s))
|
||||
a = float(re.sub("a=", "", a_s))
|
||||
b = float(re.sub("b=", "", b_s))
|
||||
N= 1000
|
||||
|
||||
def plotter():
|
||||
x = linspace(a,b, N)
|
||||
plt.figure(figsize=(10,10))
|
||||
plt.plot(x,func(x), label=func_string)
|
||||
#plt.plot(x,g(x), label='g(x)')
|
||||
plt.legend(loc='best')
|
||||
plt.grid()
|
||||
plt.show()
|
||||
plt.savefig("/tmp/plot.png", dpi=150)
|
||||
|
||||
# License: Creative Commons Zero (almost public domain) http://scpyce.org/cc0
|
||||
|
||||
import numpy as np
|
||||
|
||||
def sample_function(func, points, tol=0.05, min_points=16, max_level=16,
|
||||
sample_transform=None):
|
||||
"""
|
||||
Sample a 1D function to given tolerance by adaptive subdivision.
|
||||
|
||||
The result of sampling is a set of points that, if plotted,
|
||||
produces a smooth curve with also sharp features of the function
|
||||
resolved.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
func : callable
|
||||
Function func(x) of a single argument. It is assumed to be vectorized.
|
||||
points : array-like, 1D
|
||||
Initial points to sample, sorted in ascending order.
|
||||
These will determine also the bounds of sampling.
|
||||
tol : float, optional
|
||||
Tolerance to sample to. The condition is roughly that the total
|
||||
length of the curve on the (x, y) plane is computed up to this
|
||||
tolerance.
|
||||
min_point : int, optional
|
||||
Minimum number of points to sample.
|
||||
max_level : int, optional
|
||||
Maximum subdivision depth.
|
||||
sample_transform : callable, optional
|
||||
Function w = g(x, y). The x-samples are generated so that w
|
||||
is sampled.
|
||||
|
||||
Returns
|
||||
-------
|
||||
x : ndarray
|
||||
X-coordinates
|
||||
y : ndarray
|
||||
Corresponding values of func(x)
|
||||
|
||||
Notes
|
||||
-----
|
||||
This routine is useful in computing functions that are expensive
|
||||
to compute, and have sharp features --- it makes more sense to
|
||||
adaptively dedicate more sampling points for the sharp features
|
||||
than the smooth parts.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> def func(x):
|
||||
... '''Function with a sharp peak on a smooth background'''
|
||||
... a = 0.001
|
||||
... return x + a**2/(a**2 + x**2)
|
||||
...
|
||||
>>> x, y = sample_function(func, [-1, 1], tol=1e-3)
|
||||
|
||||
>>> import matplotlib.pyplot as plt
|
||||
>>> xx = np.linspace(-1, 1, 12000)
|
||||
>>> plt.plot(xx, func(xx), '-', x, y[0], '.')
|
||||
>>> plt.show()
|
||||
|
||||
"""
|
||||
return _sample_function(func, points, values=None, mask=None, depth=0,
|
||||
tol=tol, min_points=min_points, max_level=max_level,
|
||||
sample_transform=sample_transform)
|
||||
|
||||
def _sample_function(func, points, values=None, mask=None, tol=0.05,
|
||||
depth=0, min_points=16, max_level=16,
|
||||
sample_transform=None):
|
||||
points = np.asarray(points)
|
||||
|
||||
if values is None:
|
||||
values = np.atleast_2d(func(points))
|
||||
|
||||
if mask is None:
|
||||
mask = Ellipsis
|
||||
|
||||
if depth > max_level:
|
||||
# recursion limit
|
||||
return points, values
|
||||
|
||||
x_a = points[...,:-1][mask]
|
||||
x_b = points[...,1:][mask]
|
||||
|
||||
x_c = .5*(x_a + x_b)
|
||||
y_c = np.atleast_2d(func(x_c))
|
||||
|
||||
x_2 = np.r_[points, x_c]
|
||||
y_2 = np.r_['-1', values, y_c]
|
||||
j = np.argsort(x_2)
|
||||
|
||||
x_2 = x_2[...,j]
|
||||
y_2 = y_2[...,j]
|
||||
|
||||
# -- Determine the intervals at which refinement is necessary
|
||||
|
||||
if len(x_2) < min_points:
|
||||
mask = np.ones([len(x_2)-1], dtype=bool)
|
||||
else:
|
||||
# represent the data as a path in N dimensions (scaled to unit box)
|
||||
if sample_transform is not None:
|
||||
y_2_val = sample_transform(x_2, y_2)
|
||||
else:
|
||||
y_2_val = y_2
|
||||
|
||||
p = np.r_['0',
|
||||
x_2[None,:],
|
||||
y_2_val.real.reshape(-1, y_2_val.shape[-1]),
|
||||
y_2_val.imag.reshape(-1, y_2_val.shape[-1])
|
||||
]
|
||||
|
||||
sz = (p.shape[0]-1)//2
|
||||
|
||||
xscale = x_2.ptp(axis=-1)
|
||||
yscale = abs(y_2_val.ptp(axis=-1)).ravel()
|
||||
|
||||
p[0] /= xscale
|
||||
p[1:sz+1] /= yscale[:,None]
|
||||
p[sz+1:] /= yscale[:,None]
|
||||
|
||||
# compute the length of each line segment in the path
|
||||
dp = np.diff(p, axis=-1)
|
||||
s = np.sqrt((dp**2).sum(axis=0))
|
||||
s_tot = s.sum()
|
||||
|
||||
# compute the angle between consecutive line segments
|
||||
dp /= s
|
||||
dcos = np.arccos(np.clip((dp[:,1:] * dp[:,:-1]).sum(axis=0), -1, 1))
|
||||
|
||||
# determine where to subdivide: the condition is roughly that
|
||||
# the total length of the path (in the scaled data) is computed
|
||||
# to accuracy `tol`
|
||||
dp_piece = dcos * .5*(s[1:] + s[:-1])
|
||||
mask = (dp_piece > tol * s_tot)
|
||||
|
||||
mask = np.r_[mask, False]
|
||||
mask[1:] |= mask[:-1].copy()
|
||||
|
||||
|
||||
# -- Refine, if necessary
|
||||
|
||||
if mask.any():
|
||||
return _sample_function(func, x_2, y_2, mask, tol=tol, depth=depth+1,
|
||||
min_points=min_points, max_level=max_level,
|
||||
sample_transform=sample_transform)
|
||||
else:
|
||||
return x_2, y_2
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#plotter()
|
||||
x, y = sample_function(func, [a, b], tol=1e-6)
|
||||
xx = np.linspace(a, b, 300)
|
||||
plt.figure(figsize=((10,10)))
|
||||
plt.plot(x, y[0], '-',linewidth=1.5)
|
||||
plt.grid()
|
||||
plt.savefig("/tmp/plot.png", dpi=400)
|
||||
#weightss = np.empty_like(xx)
|
||||
#for i in range(len(xx)):
|
||||
# if i == 0:
|
||||
# weightss[i] = xx[i+1]-x[i]
|
||||
# if i == len(xx)-1:
|
||||
# weightss[i] = xx[-1]-xx[-2]
|
||||
# else:
|
||||
# weightss[i] = 0.5*(xx[i+1]-xx[i-1])
|
||||
#avg = average(abs(func(xx)))
|
||||
#plt.ylim(top=avg, bottom=-1.0*avg)
|
195
.local/bin/tools/plotter_.py
Normal file
195
.local/bin/tools/plotter_.py
Normal file
@ -0,0 +1,195 @@
|
||||
import matplotlib.pyplot as plt
|
||||
from numpy import *
|
||||
import sys
|
||||
import re
|
||||
|
||||
#limits of function:
|
||||
print(sys.argv)
|
||||
#put function here
|
||||
func=lambda x: 1/10*x-x**2/400
|
||||
a_s = sys.argv[2]
|
||||
b_s = sys.argv[3]
|
||||
if len(sys.argv) > 3:
|
||||
print("LONGER")
|
||||
#print('save_state: {}'.format(save_state))
|
||||
func_string = sys.argv[1]
|
||||
|
||||
a = float(re.sub("a=", "", a_s))
|
||||
b = float(re.sub("b=", "", b_s))
|
||||
N= 1000
|
||||
|
||||
def plotter():
|
||||
x = linspace(a,b, N)
|
||||
plt.figure(figsize=(10,10))
|
||||
plt.plot(x,func(x), label=func_string)
|
||||
#plt.plot(x,g(x), label='g(x)')
|
||||
plt.legend(loc='best')
|
||||
plt.grid()
|
||||
plt.savefig("/tmp/plot.png", dpi=150)
|
||||
|
||||
# License: Creative Commons Zero (almost public domain) http://scpyce.org/cc0
|
||||
|
||||
import numpy as np
|
||||
|
||||
def sample_function(func, points, tol=0.05, min_points=16, max_level=16,
|
||||
sample_transform=None):
|
||||
"""
|
||||
Sample a 1D function to given tolerance by adaptive subdivision.
|
||||
|
||||
The result of sampling is a set of points that, if plotted,
|
||||
produces a smooth curve with also sharp features of the function
|
||||
resolved.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
func : callable
|
||||
Function func(x) of a single argument. It is assumed to be vectorized.
|
||||
points : array-like, 1D
|
||||
Initial points to sample, sorted in ascending order.
|
||||
These will determine also the bounds of sampling.
|
||||
tol : float, optional
|
||||
Tolerance to sample to. The condition is roughly that the total
|
||||
length of the curve on the (x, y) plane is computed up to this
|
||||
tolerance.
|
||||
min_point : int, optional
|
||||
Minimum number of points to sample.
|
||||
max_level : int, optional
|
||||
Maximum subdivision depth.
|
||||
sample_transform : callable, optional
|
||||
Function w = g(x, y). The x-samples are generated so that w
|
||||
is sampled.
|
||||
|
||||
Returns
|
||||
-------
|
||||
x : ndarray
|
||||
X-coordinates
|
||||
y : ndarray
|
||||
Corresponding values of func(x)
|
||||
|
||||
Notes
|
||||
-----
|
||||
This routine is useful in computing functions that are expensive
|
||||
to compute, and have sharp features --- it makes more sense to
|
||||
adaptively dedicate more sampling points for the sharp features
|
||||
than the smooth parts.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> def func(x):
|
||||
... '''Function with a sharp peak on a smooth background'''
|
||||
... a = 0.001
|
||||
... return x + a**2/(a**2 + x**2)
|
||||
...
|
||||
>>> x, y = sample_function(func, [-1, 1], tol=1e-3)
|
||||
|
||||
>>> import matplotlib.pyplot as plt
|
||||
>>> xx = np.linspace(-1, 1, 12000)
|
||||
>>> plt.plot(xx, func(xx), '-', x, y[0], '.')
|
||||
>>> plt.show()
|
||||
|
||||
"""
|
||||
return _sample_function(func, points, values=None, mask=None, depth=0,
|
||||
tol=tol, min_points=min_points, max_level=max_level,
|
||||
sample_transform=sample_transform)
|
||||
|
||||
def _sample_function(func, points, values=None, mask=None, tol=0.05,
|
||||
depth=0, min_points=16, max_level=16,
|
||||
sample_transform=None):
|
||||
points = np.asarray(points)
|
||||
|
||||
if values is None:
|
||||
values = np.atleast_2d(func(points))
|
||||
|
||||
if mask is None:
|
||||
mask = Ellipsis
|
||||
|
||||
if depth > max_level:
|
||||
# recursion limit
|
||||
return points, values
|
||||
|
||||
x_a = points[...,:-1][mask]
|
||||
x_b = points[...,1:][mask]
|
||||
|
||||
x_c = .5*(x_a + x_b)
|
||||
y_c = np.atleast_2d(func(x_c))
|
||||
|
||||
x_2 = np.r_[points, x_c]
|
||||
y_2 = np.r_['-1', values, y_c]
|
||||
j = np.argsort(x_2)
|
||||
|
||||
x_2 = x_2[...,j]
|
||||
y_2 = y_2[...,j]
|
||||
|
||||
# -- Determine the intervals at which refinement is necessary
|
||||
|
||||
if len(x_2) < min_points:
|
||||
mask = np.ones([len(x_2)-1], dtype=bool)
|
||||
else:
|
||||
# represent the data as a path in N dimensions (scaled to unit box)
|
||||
if sample_transform is not None:
|
||||
y_2_val = sample_transform(x_2, y_2)
|
||||
else:
|
||||
y_2_val = y_2
|
||||
|
||||
p = np.r_['0',
|
||||
x_2[None,:],
|
||||
y_2_val.real.reshape(-1, y_2_val.shape[-1]),
|
||||
y_2_val.imag.reshape(-1, y_2_val.shape[-1])
|
||||
]
|
||||
|
||||
sz = (p.shape[0]-1)//2
|
||||
|
||||
xscale = x_2.ptp(axis=-1)
|
||||
yscale = abs(y_2_val.ptp(axis=-1)).ravel()
|
||||
|
||||
p[0] /= xscale
|
||||
p[1:sz+1] /= yscale[:,None]
|
||||
p[sz+1:] /= yscale[:,None]
|
||||
|
||||
# compute the length of each line segment in the path
|
||||
dp = np.diff(p, axis=-1)
|
||||
s = np.sqrt((dp**2).sum(axis=0))
|
||||
s_tot = s.sum()
|
||||
|
||||
# compute the angle between consecutive line segments
|
||||
dp /= s
|
||||
dcos = np.arccos(np.clip((dp[:,1:] * dp[:,:-1]).sum(axis=0), -1, 1))
|
||||
|
||||
# determine where to subdivide: the condition is roughly that
|
||||
# the total length of the path (in the scaled data) is computed
|
||||
# to accuracy `tol`
|
||||
dp_piece = dcos * .5*(s[1:] + s[:-1])
|
||||
mask = (dp_piece > tol * s_tot)
|
||||
|
||||
mask = np.r_[mask, False]
|
||||
mask[1:] |= mask[:-1].copy()
|
||||
|
||||
|
||||
# -- Refine, if necessary
|
||||
|
||||
if mask.any():
|
||||
return _sample_function(func, x_2, y_2, mask, tol=tol, depth=depth+1,
|
||||
min_points=min_points, max_level=max_level,
|
||||
sample_transform=sample_transform)
|
||||
else:
|
||||
return x_2, y_2
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
#plotter()
|
||||
x, y = sample_function(func, [a, b], tol=1e-6)
|
||||
xx = np.linspace(a, b, 300)
|
||||
plt.figure(figsize=((10,10)))
|
||||
plt.plot(x, y[0], '-',linewidth=1.5)
|
||||
plt.grid()
|
||||
plt.savefig("/tmp/plot.png", dpi=400)
|
||||
#weightss = np.empty_like(xx)
|
||||
#for i in range(len(xx)):
|
||||
# if i == 0:
|
||||
# weightss[i] = xx[i+1]-x[i]
|
||||
# if i == len(xx)-1:
|
||||
# weightss[i] = xx[-1]-xx[-2]
|
||||
# else:
|
||||
# weightss[i] = 0.5*(xx[i+1]-xx[i-1])
|
||||
#avg = average(abs(func(xx)))
|
||||
#plt.ylim(top=avg, bottom=-1.0*avg)
|
6
.local/bin/tools/podentr
Executable file
6
.local/bin/tools/podentr
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
# entr command to run `queueandnotify` when newsboat queue is changed
|
||||
|
||||
[ "$(pgrep -x $(basename $0) | wc -l)" -gt 2 ] && exit
|
||||
|
||||
echo ~/.local/share/newsboat/queue | entr -p queueandnotify 2>/dev/null
|
19
.local/bin/tools/pw
Executable file
19
.local/bin/tools/pw
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
passmenu2
|
||||
#group=$(pass list | sed 's/\x1B\[[0-9;]\+[A-Za-z]//g' | grep -Ev "Password|mutt-wizard" | grep -v ' .──' | sed -E 's/├──|└──| //' | sed 's/ //' | dmenu -l 20 -p 'choose group:')
|
||||
#
|
||||
#if [ -n "$group" ]
|
||||
#then
|
||||
# account=$(pass list "$group" | sed 1d | sed -E 's/├──|└──| //'| sed 's/ //' | dmenu -l 20 -p "choose account from $group:")
|
||||
#
|
||||
# if [ -n "$account" ]
|
||||
# then
|
||||
# temp="$group/$account"
|
||||
# echo "$temp"
|
||||
# pass -c "$temp" > $HOME/.cache/passstring
|
||||
# sed -e "s/^/\"/" -e "s/$/\"/" $HOME/.cache/passstring | xargs notify-send "Password"
|
||||
# rm $HOME/.cache/passstring
|
||||
# sleep 45
|
||||
# notify-send "Password" "password cleared from clipboard"
|
||||
# fi
|
||||
#fi
|
11
.local/bin/tools/qndl
Executable file
11
.local/bin/tools/qndl
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# $1 is a url; $2 is a command
|
||||
[ -z "$1" ] && exit
|
||||
base="$(basename "$1")"
|
||||
notify-send "⏳ Queuing $base..."
|
||||
cmd="$2"
|
||||
[ -z "$cmd" ] && cmd="youtube-dl --add-metadata"
|
||||
idnum="$(tsp $cmd "$1")"
|
||||
realname="$(echo "$base" | sed "s/?\(source\|dest\).*//;s/%20/ /g")"
|
||||
tsp -D "$idnum" mv "$base" "$realname"
|
||||
tsp -D "$idnum" notify-send "👍 $realname done."
|
13
.local/bin/tools/queueandnotify
Executable file
13
.local/bin/tools/queueandnotify
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Podboat sucks. This script replaces it.
|
||||
# It reads the newsboat queue, queuing downloads with taskspooler.
|
||||
# It also removes the junk from extentions.
|
||||
queuefile="$HOME/.local/share/newsboat/queue"
|
||||
|
||||
while read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
url="$(echo "$line" | awk '{print $1}')"
|
||||
qndl "$url" "curl -LO"
|
||||
done < "$queuefile"
|
||||
|
||||
echo > "$queuefile"
|
5
.local/bin/tools/refbar
Executable file
5
.local/bin/tools/refbar
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Refresh the dwmbar.
|
||||
# Send SIGTRAP signal to dwmbar script, which will handle it with a trap.
|
||||
pkill -SIGTRAP dwmbar
|
3
.local/bin/tools/restart
Executable file
3
.local/bin/tools/restart
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
pkill $1
|
||||
setsid $1
|
43
.local/bin/tools/ripper
Executable file
43
.local/bin/tools/ripper
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/zsh
|
||||
|
||||
#needed if run as cronjob
|
||||
export XDG_VIDEOS_DIR=$HOME/vids
|
||||
|
||||
DLARCHIVE=$XDG_VIDEOS_DIR/.downloaded
|
||||
DLLOC=$XDG_VIDEOS_DIR
|
||||
CHANNELSFILE=$XDG_VIDEOS_DIR/.channels
|
||||
|
||||
|
||||
#STILL NOT WORKING
|
||||
# Required to display notifications if run as a cronjob:
|
||||
export XAUTHORITY="/home/alex/.cache/xdg_run/Xauthority" # This line will break some DMs.
|
||||
export DISPLAY=:0.0
|
||||
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
|
||||
|
||||
range="now-40years"
|
||||
notify-send "Channel Ripper" "Scanning for new Videos to download"
|
||||
echo "Scanning for new Videos to download"
|
||||
grep 'youtube' "$CHANNELSFILE" | sed "s/$/\/videos/" |xargs -L1 lynx --dump --nonumbers -listonly $1 | grep "youtube.com/watch?v=" | grep -v "&list" > /tmp/todownload
|
||||
grep 'youtube' "$DLARCHIVE" | sed 's/youtube /https:\/\/www\.youtube\.com\/watch?v=/' > /tmp/alreadydownloaded
|
||||
|
||||
grep 'bitchute' "$CHANNELSFILE" | xargs -L1 lynx --dump --nonumbers -listonly $1 | grep 'bitchute\.com\/video' | sort -u >> /tmp/todownload
|
||||
grep 'bitchute' "$DLARCHIVE" | sed 's/bitchute /https:\/\/www\.bitchute\.com\/video\//' >> /tmp/alreadydownloaded
|
||||
|
||||
number=$(grep -vf /tmp/alreadydownloaded /tmp/todownload | sort -u | wc -l)
|
||||
|
||||
if [ $number -gt 0 ]; then
|
||||
[ $number -eq 1 ] && ( notify-send "Channel Ripper" "1 new video available for download, downloading now." ) || ( notify-send "Channel Ripper" "$number new videos available for download, downloading now." )
|
||||
echo "$number new videos for download available, downloading now."
|
||||
grep -vf /tmp/alreadydownloaded /tmp/todownload | sort -u | xargs -L1 youtube-dl --get-filename -o "'%(uploader)s' '%(title)s'" $1 | xargs -L1 notify-send
|
||||
grep -vf /tmp/alreadydownloaded /tmp/todownload | sort -u | grep 'youtube' | xargs -r -L1 youtube-dl --hls-prefer-native -i --download-archive $DLARCHIVE --dateafter $range -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' --add-metadata -o "$DLLOC/%(uploader)s/%(upload_date)s-%(title)s.%(ext)s"
|
||||
grep -vf /tmp/alreadydownloaded /tmp/todownload | sort -u | grep 'bitchute' | xargs -r -L1 youtube-dl --hls-prefer-native -i --download-archive $DLARCHIVE -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' --add-metadata -o "$DLLOC/%(uploader)s/%(title)s.%(ext)s"
|
||||
notify-send "Channel Ripper" "Finished downloading"
|
||||
fi
|
||||
|
||||
if [ $number -eq 0 ]; then
|
||||
echo "No new Videos"
|
||||
notify-send "Channel Ripper" "No new Videos"
|
||||
fi
|
||||
|
||||
rm -f /tmp/alreadydownloaded
|
||||
rm -f /tmp/todownload
|
4
.local/bin/tools/rotdir
Executable file
4
.local/bin/tools/rotdir
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
[ -z "$1" ] && echo "usage: rotdir regex 2>&1" && exit 1
|
||||
base="$(basename $1)"
|
||||
ls "$PWD" | awk "BEGIN { lines = \"\"; m = 0; } /^$base$/ { m = 1; } { if (!m) { if (lines) { lines = lines\"\n\"; } lines = lines\"\"\$0; } else { print \$0; } } END { print lines; }"
|
9
.local/bin/tools/rssadd
Executable file
9
.local/bin/tools/rssadd
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null &&
|
||||
notify-send "That doesn't look like a full URL." && exit
|
||||
RSSFILE="$HOME/.config/newsboat/urls"
|
||||
if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then
|
||||
notify-send "You already have this RSS feed."
|
||||
else
|
||||
echo "$1" >> "$RSSFILE" && notify-send "RSS feed added."
|
||||
fi
|
3
.local/bin/tools/score
Executable file
3
.local/bin/tools/score
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
categories=$(( $(cat $1 | grep -oE '[0-9]*$' | wc -l ) - 1 ))
|
||||
grep -oE '[0-9]*$' $1 | head -n $categories | paste -sd+ | bc
|
1
.local/bin/tools/search
Executable file
1
.local/bin/tools/search
Executable file
@ -0,0 +1 @@
|
||||
find -iname "*$1*"
|
4
.local/bin/tools/setbg
Executable file
4
.local/bin/tools/setbg
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Sets the background. If given an argument, will set file as background.
|
||||
[ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed."
|
||||
xwallpaper --zoom ~/.config/wall.png
|
26
.local/bin/tools/shortcuts
Executable file
26
.local/bin/tools/shortcuts
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# Output locations. Unactivated progs should go to /dev/null.
|
||||
shell_shortcuts="$HOME/.config/shortcutrc"
|
||||
ranger_shortcuts="/dev/null"
|
||||
qute_shortcuts="/dev/null"
|
||||
fish_shortcuts="/dev/null"
|
||||
vifm_shortcuts="$HOME/.config/vifm/vifmshortcuts"
|
||||
|
||||
# Remove, prepare files
|
||||
rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null
|
||||
printf "# vim: filetype=sh\\n" > "$fish_shortcuts"
|
||||
printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
|
||||
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
|
||||
|
||||
# Format the `bmdirs` file in the correct syntax and sent it to all three configs.
|
||||
sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \
|
||||
>(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \
|
||||
>(awk '{print "map g" $1, ":cd", $2 "<CR>\nmap t" $1, "<tab>:cd", $2 "<CR><tab>\nmap M" $1, "<tab>:cd", $2 "<CR><tab>:mo<CR>\nmap Y" $1, "<tab>:cd", $2 "<CR><tab>:co<CR>" }' >> "$vifm_shortcuts") \
|
||||
>(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \
|
||||
| awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts"
|
||||
|
||||
# Format the `configs` file in the correct syntax and sent it to both configs.
|
||||
sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \
|
||||
>(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \
|
||||
>(awk '{print "map", $1, ":e", $2 "<CR>" }' >> "$vifm_shortcuts") \
|
||||
| awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts"
|
4
.local/bin/tools/startanki
Executable file
4
.local/bin/tools/startanki
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
anki &
|
||||
sleep 2
|
||||
hover center
|
2
.local/bin/tools/startzoom
Executable file
2
.local/bin/tools/startzoom
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
sh /opt/zoom/zoom.sh
|
3
.local/bin/tools/temp_bt
Executable file
3
.local/bin/tools/temp_bt
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
bluetoothctl power on
|
||||
bluetoothctl scan on
|
14
.local/bin/tools/texclear
Executable file
14
.local/bin/tools/texclear
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Clears the build files of a LaTeX/XeLaTeX build.
|
||||
# I have vim run this file whenever I exit a .tex file.
|
||||
|
||||
case "$1" in
|
||||
*.tex)
|
||||
file=$(readlink -f "$1")
|
||||
dir=$(dirname "$file")
|
||||
base="${file%.*}"
|
||||
find "$dir" -maxdepth 1 -type f -regextype gnu-awk -regex "^$base\\.(4tc|xref|tmp|pyc|pyo|fls|vrb|fdb_latexmk|bak|swp|aux|log|synctex\\(busy\\)|lof|lot|maf|idx|mtc|mtc0|nav|out|snm|toc|bcf|run\\.xml|synctex\\.gz|blg|bbl)" -delete ;;
|
||||
*) printf "Give .tex file as argument.\\n" ;;
|
||||
esac
|
||||
|
23
.local/bin/tools/timer
Executable file
23
.local/bin/tools/timer
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
turns=15
|
||||
if [[ -n $1 ]];then
|
||||
turns=$1
|
||||
fi
|
||||
echo "Starting!"
|
||||
let "i=1"
|
||||
notify-send "Timer" "Starting, $turns minutes to go"
|
||||
for ((turn=1; turn<=$turns; turn++));
|
||||
do
|
||||
clear
|
||||
echo "turn $turn"
|
||||
echo "###########"
|
||||
sleep 2
|
||||
for seconds in {1..60}
|
||||
do
|
||||
echo "$seconds secs. passed"
|
||||
sleep 1
|
||||
done
|
||||
notify-send "Timer" "Switch\n($i/$turns done)"
|
||||
let "i=i+1"
|
||||
done
|
||||
clear
|
2
.local/bin/tools/toprim
Executable file
2
.local/bin/tools/toprim
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
xclip -o -selection "primary" | xclip -i -selection 'clipboard'
|
9
.local/bin/tools/transadd
Executable file
9
.local/bin/tools/transadd
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Mimeapp script for adding torrent to transmission-daemon, but will also start the daemon first if not running.
|
||||
|
||||
# transmission-daemon sometimes fails to take remote requests in its first moments.
|
||||
|
||||
pgrep -x transmission-da || (transmission-daemon && notify-send "Starting transmission daemon..." && sleep 3 && pkill -RTMIN+7 i3blocks)
|
||||
|
||||
transmission-remote -a "$@" && notify-send "🔽 Torrent added."
|
13
.local/bin/tools/vifmimg
Executable file
13
.local/bin/tools/vifmimg
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
[ -z "$FIFO_UEBERZUG" ] && exit
|
||||
|
||||
readonly ID_PREVIEW="preview"
|
||||
|
||||
if [ "$1" = "draw" ]; then
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="${PWD}/$6") > "$FIFO_UEBERZUG"
|
||||
elif [ "$1" = "videopreview" ]; then
|
||||
[ ! -f "/tmp/$6.png" ] && ffmpegthumbnailer -i "${PWD}/$6" -o "/tmp/$6.png" -s 0 -q 10 &&
|
||||
declare -p -A cmd=([action]=add [identifier]="$ID_PREVIEW" [x]="$2" [y]="$3" [max_width]="$4" [max_height]="$5" [path]="/tmp/$6.png") > "$FIFO_UEBERZUG"
|
||||
else
|
||||
declare -p -A cmd=([action]=remove [identifier]="$ID_PREVIEW") > "$FIFO_UEBERZUG"
|
||||
fi
|
15
.local/bin/tools/vu
Executable file
15
.local/bin/tools/vu
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
export FIFO_UEBERZUG="/tmp/vifm-ueberzug-${PPID}"
|
||||
|
||||
cleanup() {
|
||||
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||
pkill -P $$ 2>/dev/null
|
||||
}
|
||||
|
||||
rm "$FIFO_UEBERZUG" 2>/dev/null
|
||||
mkfifo "$FIFO_UEBERZUG"
|
||||
trap cleanup EXIT
|
||||
tail --follow "$FIFO_UEBERZUG" | ueberzug layer --silent --parser bash &
|
||||
|
||||
vifm
|
||||
cleanup
|
11
.local/bin/tools/wv
Executable file
11
.local/bin/tools/wv
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
alldata="/tmp/allfiles"
|
||||
videos="/tmp/videos"
|
||||
du -a ~/vids/* --time | sort -u | awk '!($1="")' | sort -bg | awk '!($1="")' | awk '!($1="")' | sed 's/^ //' | tac > $alldata
|
||||
touch $videos
|
||||
while read line; do
|
||||
[ -f "$line" ] && echo $line >> $videos
|
||||
done <$alldata
|
||||
cat $videos | dmenu -i -l 30 -p "Choose a video to watch:" | sed 's/^/\"/' | sed 's/$/\"/' | xargs -r xdg-open
|
||||
rm "$alldata"
|
||||
rm "$videos"
|
Reference in New Issue
Block a user