dgy
/
hexagons
Archived
1
0
Fork 0

y lo baje con varios tragos de BINo

This commit is contained in:
deadguy 2019-04-22 13:17:15 -03:00
parent b0c0c8d234
commit 7d9c09fa26
Signed by: dgy
GPG Key ID: 37CA55B52CF63730
21 changed files with 262 additions and 77 deletions

37
bin/actualizar Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euf -o pipefail
trap 'rm /tmp/{pacmanupdates,aurupdates} 2>/dev/null' INT TERM QUIT EXIT
# how long between checks
interval=${1:-72000}
# check internet connection
connection() {
ping -q -c 1 1.1.1.1 > /dev/null || exit
}
checker() {
while true; do
nb_pac=$(checkupdates | tee /tmp/pacmanupdates | wc -l)
nb_aur=$(yay -Qua | tee /tmp/aurupdates | wc -l)
if ((nb_pac>0 || nb_aur>0)); then
((nb_aur>0)) && nb_aur="+ ${nb_aur}" && cat /tmp/aurupdates >> /tmp/pacmanupdates
((nb_aur==0)) && unset nb_aur
notify-send " You have ${nb_pac} ${nb_aur} updates"
fi
sleep "$interval"
done
}
waiter() {
if ! connection ; then
sleep 30 && waiter
else
checker
fi
}
waiter

38
bin/brillo Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euf -o pipefail
# You can call this script like this:
# $ brillo up
# $ brillo down
# Script inspired by these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
# https://gitlab.com/Poplan/dotfiles/blob/master/scripts/brightness.sh
function get_brightness {
xbacklight -get | cut -d '.' -f 1
}
function send_notification {
icon="/home/deadguy/.local/share/icons/ArchLabs-Light/24x24/actions/contrast.svg"
brightness=$(get_brightness)
# Make the bar with the special character ─ (it's not dash -)
# https://en.wikipedia.org/wiki/Box-drawing_character
bar=$(seq -s "─" 0 $((brightness / 5)) | sed 's/[0-9]//g')
# Send the notification
dunstify -i "$icon" -r 5555 -u low " $bar"
}
case $1 in
up)
# increase the backlight by 5%
xbacklight -inc 5
send_notification
;;
down)
# decrease the backlight by 5%
xbacklight -dec 5
send_notification
;;
esac

3
bin/chotagram Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
ffmpeg -i $1 -r 29.97 -vf scale=1280:-1 -vf format=yuv420p -vf crop=710:720:0:0 -c:v libx264 -c:a aac -b:a 128k $1_cropped.mp4

37
bin/compilar Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# This script will compile or run another finishing operation on a document. I
# have this script run via vim.
#
# Compiles .tex. groff (.mom, .ms), .rmd, .md.
# Opens .sent files as sent presentations.
# Runs scripts based on extention or shebang
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
cd "$dir" || exit
textype() { \
command="pdflatex"
( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
$command --output-directory="$dir" "$base" &&
grep -i addbibresource "$file" >/dev/null &&
biber --input-directory "$dir" "$base" &&
$command --output-directory="$dir" "$base" &&
$command --output-directory="$dir" "$base"
}
case "$file" in
*\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;;
*\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;;
*\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
*\.tex) textype "$file" ;;
*\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
*config.h) sudo make install ;;
*\.c) cc "$file" -o "$base" && "$base" ;;
*\.py) python "$file" ;;
*\.go) go run "$file" ;;
*\.sent) setsid sent "$file" 2>/dev/null & ;;
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac

25
bin/correo Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euf -o pipefail
# how long between checks
interval=${1:-600}
# check internet connection
connection() {
ping -q -c 1 1.1.1.1 > /dev/null || exit
}
checker() {
mailsync
sleep "$interval"
}
waiter() {
if ! connection ; then
sleep 30 && waiter
else
checker
fi
}
waiter

3
bin/corte Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
kill -9 "$(cat ~/.recordingpid)"

4
bin/disco Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
mpv --cdrom-device=/dev/sr0 cdda://

4
bin/fecha Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
notify-send -u low -t 5000 " $(date +'%A %d de %B %H:%M')"

View File

@ -34,7 +34,15 @@ screencast() { \
echo $! > /tmp/recordingpid
}
jack() {
jacka() { \
ffmpeg -y \
-thread_queue_size 4096 \
-f pulse -i 1 \
-ac 2 -channel_layout stereo -async 1 \
-c:a flac "$HOME/Video/Tape/$(date '+%y%m%d-%H%M-%S').flac"
}
jackv() {
ffmpeg -y \
-thread_queue_size 4096 \
-f jack -i ffmpeg \
@ -85,7 +93,8 @@ asktoend() { \
case "$1" in
screencast) screencast;;
jack) jack;;
jacka) jacka;;
jackv) jackv;;
audio) audio;;
video) video;;
kill) killrecording;;

19
bin/mailsync Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env sh
# Sync mail and give notification if there is new mail.
notify() { notify-send-headless "<span weight='bold'>You've got mail</span>" " $2 new mail(s) in $1." ;}
# Run mbsync. You can feed this script different settings.
mbsync -a "$@"
# Check all accounts/mailboxes for new mail. Notify if there is new content.
for account in "$HOME/.local/share/mail/"*
do
acc="$(echo "$account" | sed "s/.*\///")"
newcount=$(find "$HOME/.local/share/mail/$acc/INBOX/new/" "$HOME/.local/share/mail/$acc/Inbox/new/" "$HOME/.local/share/mail/$acc/inbox/new/" -type f -newer "$HOME/.config/mutt/bin/.mailsynclastrun" 2> /dev/null | wc -l)
[ "$newcount" -gt "0" ] && notify "$acc" "$newcount" &
done
notmuch new 2>/dev/null
#Create a touch file that indicates the time of the last run of mailsync
touch "$HOME/.config/mutt/bin/.mailsynclastrun"

4
bin/pantallazo Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
maim -u ~/Pictures/scrot/"$(date +%s)".png && notify-send -u low -t 3000 'Screen captured'

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -euf -o pipefail
maim -d 5 -q -u ~/Pictures/scrot/"$(date +%s)".png && notify-send "Screen captured"

View File

@ -1,36 +0,0 @@
#!/bin/bash
c() {
filename="$HOME/Music/Tape/$(date +%s)"
param "$1"
}
jack() {
ffmpeg -y \
-thread_queue_size 4096 \
-f pulse -i 1 \
-ac 2 -channel_layout stereo -async 1 \
-c:a flac "$filename".flac
}
pulse() {
ffmpeg -y \
-thread_queue_size 4096 \
-f pulse -i default \
-ac 2 -channel_layout stereo -async 1 \
-c:a aac -b:a 128k "$filename".mp4
}
param() {
case $1 in
j) jack ;;
p) pulse ;;
*) echo -e "Invalid parameter. Add one of the following:\\n\"j\" for JACK (make sure it's on first).\\n\"p\" for pulseaudio" ;;
esac ;}
c "$1"
#-f alsa -ac 2 -i pulse \
#-f pulse -i default \
#-ac 2 -channel_layout stereo -async 1 \
# -f jack -i ffmpeg

View File

@ -1,6 +1,6 @@
#!/bin/bash
if command -v tmux >/dev/null 2>&1; then
test -z "$TMUX" && (tmux new -A -s λ)
test -z "$TMUX" && (tmux new -A -s " " )
fi

55
bin/volumen Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -euf -o pipefail
# You can call this script like this:
# $ volumen up
# $ volumen down
# $ volumen mute
# Script modified from these wonderful people:
# https://github.com/dastorm/volume-notification-dunst/blob/master/volume.sh
# https://gist.github.com/sebastiencs/5d7227f388d93374cebdf72e783fbd6a
# https://gitlab.com/Poplan/dotfiles/blob/master/scripts/volume.sh
function get_volume {
amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
}
function is_mute {
amixer get Master | grep '%' | grep -oE '[^ ]+$' | grep off > /dev/null
}
function send_notification {
iconSound="/home/deadguy/.local/share/icons/ArchLabs-Light/24x24/actions/audio-volume-high.svg"
iconMuted="/home/deadguy/.local/share/icons/ArchLabs-Light/24x24/actions/audio-volume-muted.svg"
if is_mute ; then
dunstify -i $iconMuted -r 2593 -u low "mute"
else
volume=$(get_volume)
# Make the bar with the special character ─ (it's not dash -)
# https://en.wikipedia.org/wiki/Box-drawing_character
bar=$(seq --separator="─" 0 "$((volume / 5))" | sed 's/[0-9]//g')
# Send the notification
dunstify -i $iconSound -r 2593 -u low " $bar"
fi
}
case $1 in
up)
# set the volume on (if it was muted)
amixer -q set Master on > /dev/null
# up the volume (+ 5%)
amixer -q sset Master 5%+ > /dev/null
send_notification
;;
down)
amixer -q set Master on > /dev/null
amixer -q sset Master 5%- > /dev/null
send_notification
;;
mute)
# toggle mute
amixer -q set Master 1+ toggle > /dev/null
send_notification
;;
esac

View File

@ -1,34 +0,0 @@
#!/bin/bash
# Feed script a url.
# Opens the url with xdg-open unless it is an image,
ext="${1##*.}"
mpvFiles="mkv mp4 gif webm"
fehFiles="png jpg jpeg jpe"
wgetFiles="mp3 flac opus mp3?source=feed pdf"
# List of sites that will be opened in mpv.
vidsites="youtube.com
\\|hooktube.com
\\|bitchute.com
\\|vimeo.com
\\|dailymotion.com
"
ext="${1##*.}"
mpvFiles="mkv mp4 gif webm"
fehFiles="png jpg jpeg jpe"
wgetFiles="mp3 flac opus mp3?source=feed pdf"
if echo "$fehFiles" | grep -w "$ext" > /dev/null; then
setsid nohup sxiv "$1" >/dev/null & disown
elif echo "$mpvFiles" | grep -w "$ext" > /dev/null; then
setsid nohup mpv -quiet "$1" > /dev/null & disown
elif echo "$wgetFiles" | grep -w "$ext" > /dev/null; then
wget "$1" >/dev/null & disown
elif echo "$@" | grep "$vidsites">/dev/null; then
setsid nohup mpv -quiet "$1" > /dev/null & disown
else
setsid nohup "$BROWSER" "$1" 2>/dev/null & disown
fi

4
bin/winclass Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
xprop | grep WM_CLASS

4
bin/ytaudio Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
youtube-dl --add-metadata -icw --no-cache-dir --no-call-home --restrict-filenames --extract-audio --audio-format mp3 --audio-quality 0 --prefer-ffmpeg -o "%(title)s.%(ext)s"

4
bin/ytdl Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
youtube-dl --add-metadata -ic --no-call-home

5
bin/ytplaylist Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
# Description: download all videos from a playlist in a separate directory.
set -euf -o pipefail
youtube-dl -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'

4
bin/ytwatch Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail
youtube-viewer -C -D -W -f -7 --results=10