diff options
author | Adam Carpenter <atc@53hor.net> | 2020-05-10 21:13:46 -0400 |
---|---|---|
committer | Adam Carpenter <atc@53hor.net> | 2020-05-10 21:13:46 -0400 |
commit | b184782970853b3c479f6c4ad833a36a3aea7afa (patch) | |
tree | 318233a807c61414a2696b5300adf3cec6e700e5 | |
download | scripts-b184782970853b3c479f6c4ad833a36a3aea7afa.tar.xz scripts-b184782970853b3c479f6c4ad833a36a3aea7afa.zip |
mega update
-rwxr-xr-x | compiz-install.sh | 8 | ||||
-rwxr-xr-x | dmenu-ssid.sh | 12 | ||||
-rwxr-xr-x | do_gen_base64key | 6 | ||||
-rwxr-xr-x | do_gen_favicon | 19 | ||||
-rwxr-xr-x | do_gen_gif | 21 | ||||
-rwxr-xr-x | do_gen_meme | 12 | ||||
-rwxr-xr-x | do_split_cert | 3 | ||||
-rwxr-xr-x | dwm-fkeys.sh | 18 | ||||
-rwxr-xr-x | dwm-launch.sh | 19 | ||||
-rwxr-xr-x | dwm-status.sh | 12 | ||||
-rwxr-xr-x | gen_favicon | 2 | ||||
-rwxr-xr-x | giffeinate | 22 | ||||
-rwxr-xr-x | git-create | 30 | ||||
-rwxr-xr-x | i3blocks-audio.sh | 17 | ||||
-rwxr-xr-x | i3blocks-battery.sh | 32 | ||||
-rwxr-xr-x | i3blocks-cpuload.sh | 17 | ||||
-rwxr-xr-x | i3blocks-cputemp.sh | 14 | ||||
-rwxr-xr-x | i3blocks-date.sh | 4 | ||||
-rwxr-xr-x | i3blocks-disk.sh | 4 | ||||
-rwxr-xr-x | i3blocks-memory.sh | 4 | ||||
-rwxr-xr-x | i3blocks-news.sh | 5 | ||||
-rwxr-xr-x | i3blocks-title.sh | 4 | ||||
-rwxr-xr-x | i3blocks-updates.sh | 5 | ||||
-rwxr-xr-x | i3blocks-uptime.sh | 4 | ||||
-rwxr-xr-x | mounter | 20 | ||||
-rwxr-xr-x | oldi3status.sh | 56 | ||||
-rwxr-xr-x | open-chats.sh | 7 | ||||
-rwxr-xr-x | open-with-mutt | 3 | ||||
-rwxr-xr-x | ripper | 21 | ||||
-rwxr-xr-x | slock-fortune.sh | 3 | ||||
-rwxr-xr-x | status.sh | 8 | ||||
-rwxr-xr-x | themer.sh | 26 | ||||
-rwxr-xr-x | umounter | 21 | ||||
-rwxr-xr-x | yt | 34 |
34 files changed, 493 insertions, 0 deletions
diff --git a/compiz-install.sh b/compiz-install.sh new file mode 100755 index 0000000..6625de6 --- /dev/null +++ b/compiz-install.sh @@ -0,0 +1,8 @@ +cd /tmp +mkdir aur +cd aur +wget https://aur.archlinux.org/cgit/aur.git/snapshot/compiz-core.tar.gz +tar xzvf compiz-core.tar.gz +cd compiz-core +makepkg -rs +sudo pacman -U compiz*.xz diff --git a/dmenu-ssid.sh b/dmenu-ssid.sh new file mode 100755 index 0000000..fdffc02 --- /dev/null +++ b/dmenu-ssid.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +prompt=$(ifconfig | egrep -o '"(.*)"') +ssids=$(ifconfig wlan0 scan | cut -c 1-32 | awk 'NF' ) + + + +ssid=$( +dmenu -c -l 10 -p "$prompt" << EOF +$ssids +EOF +) diff --git a/do_gen_base64key b/do_gen_base64key new file mode 100755 index 0000000..fd4eab5 --- /dev/null +++ b/do_gen_base64key @@ -0,0 +1,6 @@ +#!/bin/sh +#$key=$(dd status=none if=/dev/urandom bs=512 count=4) +# base64 -w 0 +#echo "$key" | xclip -o +dd status=none if=/dev/urandom bs=512 count=4 | base64 -w 0 | xclip -i +echo Copied. diff --git a/do_gen_favicon b/do_gen_favicon new file mode 100755 index 0000000..a7bbc66 --- /dev/null +++ b/do_gen_favicon @@ -0,0 +1,19 @@ +#!/bin/sh + +SIZES="16 32 64 128 256" + +[[ -z $1 ]] && exit 1; +temp_dir=$(mktemp -d /tmp/favicon.XXXXXXXXXX) + +for size in $SIZES +do + convert "$1" \ + -depth 8 \ + -background transparent \ + -flatten \ + -resize \ + "${size}x${size}" \ + "$temp_dir/$size.png" +done + +convert "$temp_dir/*" favicon.ico diff --git a/do_gen_gif b/do_gen_gif new file mode 100755 index 0000000..bcd3b0c --- /dev/null +++ b/do_gen_gif @@ -0,0 +1,21 @@ +#!/bin/sh + +# Turn video files on STDIN into GIFs. + +FPS=${FPS:-10} +SCALE=${SCALE:-480} + +while [ $1 ] +do + BASENAME=$(echo $1 | cut -d'.' -f1) + FRAMEDIR=/tmp/$BASENAME-frames-$(date +%s) + + mkdir -p $FRAMEDIR + echo Writing frames... + ffmpeg -loglevel quiet -i $1 -vf scale=-1:$SCALE,fps=$FPS $FRAMEDIR/%05d.png + echo Creating GIF... + convert -loop 0 $FRAMEDIR/*.png $BASENAME.gif + rm -r $FRAMEDIR + echo Done. + shift +done diff --git a/do_gen_meme b/do_gen_meme new file mode 100755 index 0000000..258dba8 --- /dev/null +++ b/do_gen_meme @@ -0,0 +1,12 @@ +#!/bin/sh + +# Construct a memebot query from a list of memes and entered text. + +meme=$(dmenu -l 10 -p "Which meme?" < ~/.local/bin/.memes) +echo Top text? +read top +echo Bottom text? +read bottom +echo "$top,$bottom | $meme" | xclip -i +echo Copied. + diff --git a/do_split_cert b/do_split_cert new file mode 100755 index 0000000..0c58142 --- /dev/null +++ b/do_split_cert @@ -0,0 +1,3 @@ +#!/bin/sh +openssl pkcs12 -in "$1" -nocerts -out "$1.pem" -nodes +openssl pkcs12 -in "$1" -nokeys -out "$1.crt" diff --git a/dwm-fkeys.sh b/dwm-fkeys.sh new file mode 100755 index 0000000..c656161 --- /dev/null +++ b/dwm-fkeys.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +choice=$( +dmenu -l 12 -i -b -p [Fn]: << EOF +F1: File Manager [Sleep] +F2: Wifi Scanner +F3: Browser +F4: Email +F5: Brightness Down +F6: Brightness Up +F7: Unused [Blank Screen] +F8: Mounter [Unmounter] +F9: Unused +F10: Unused [Vol Mute] +F11: Unused [Vol Down] +F12: Unused [Vol Up] +EOF +) diff --git a/dwm-launch.sh b/dwm-launch.sh new file mode 100755 index 0000000..62e4eba --- /dev/null +++ b/dwm-launch.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +compton -cCGb +feh --bg-fill /var/wallpaper +xrdb ~/.Xresources +xautolock -locker ~/source/scripts/slock-fortune.sh & +~/source/scripts/dwm-status.sh & + +logfile="/var/log/dwm.log" + +while true; do + + if [ -O $logfile ]; then + dwm 2> $logfile + else + dwm 2>&1 > /dev/null + fi + +done diff --git a/dwm-status.sh b/dwm-status.sh new file mode 100755 index 0000000..52ad773 --- /dev/null +++ b/dwm-status.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +while true +do + date=$(date "+%a %b %d %I:%M %p") + batt=$(acpiconf -i 0 | egrep -o "([0-9]+%)") + disk=$(df -H | awk '{ if ($6 == "/") print $4 }') + #ssid=$(ifconfig | egrep -o '*ssid (.*) ') + idle=$(top -n | egrep -o '[0-9]+\.[0-9]% idle') + xsetroot -name "$ssid $idle $disk free $batt charged $date" + sleep 5 +done diff --git a/gen_favicon b/gen_favicon new file mode 100755 index 0000000..b65950a --- /dev/null +++ b/gen_favicon @@ -0,0 +1,2 @@ +convert -define icon:auto-resize=72,64,48,32,16 logo.png -thumbnail "72x72>" \ + -background transparent -gravity center -extent 64x64 favicon.ico diff --git a/giffeinate b/giffeinate new file mode 100755 index 0000000..8e59600 --- /dev/null +++ b/giffeinate @@ -0,0 +1,22 @@ +#!/bin/sh + +# Turn video files on STDIN into animated GIFs. + +FPS=${FPS:-10} +SCALE=${SCALE:-480} + +while [ $1 ] +do + BASENAME=$(echo $1 | cut -d'.' -f1) + FRAMEDIR=/tmp/$BASENAME-frames-$(date +%s) + + mkdir -p $FRAMEDIR + echo Writing frames... + ffmpeg -loglevel quiet -i $1 -vf scale=-1:$SCALE,fps=$FPS $FRAMEDIR/%05d.png + echo Creating GIF... + convert -loop 0 $FRAMEDIR/*.png $BASENAME.gif + rm -r $FRAMEDIR + echo Done. + shift +done + diff --git a/git-create b/git-create new file mode 100755 index 0000000..af9bb86 --- /dev/null +++ b/git-create @@ -0,0 +1,30 @@ +#!/bin/sh + +# create a repo of provided name on macon and make it the upstream +name=$1 +[[ ! $(echo "$name" | grep ".git" -) ]] && name="$1.git" + +description=$2 + +echo "'$name': '$description'" +echo "Create repo?" +read choice +[[ ! $choice == "y" ]] && exit 1 + +ssh git@53hor.net << EOF + cd /srv/git + git init --bare /srv/git/"$name" + cd "$name" + rm description + echo "$description" > description +EOF + +echo "Mark for export (make clone-able)?" +read choice +[[ $choice == "y" ]] && ssh git@53hor.net touch /srv/git/"$name"/git-daemon-export-ok + +echo "Clone repo locally?" +read choice +[[ ! $choice == "y" ]] && exit 1 + +git clone git@53hor.net:/srv/git/"$name" diff --git a/i3blocks-audio.sh b/i3blocks-audio.sh new file mode 100755 index 0000000..84f883d --- /dev/null +++ b/i3blocks-audio.sh @@ -0,0 +1,17 @@ +#!/bin/sh +low=25 +mid=50 +high=75 +icon_low= +icon_mid= +icon_high= +icon_mute= + +[ $(pulsemixer --get-mute) -eq 1 ] && printf "$icon_mute\n" && exit + +volume=$(pulsemixer --get-volume | cut -d' ' -f1) +icon= +[ $volume -lt $low ] && icon=$icon_low +[ $volume -ge $low ] && [ $volume -lt $high ] && icon=$icon_mid +[ $volume -ge $high ] && icon=$icon_high +printf "%s %s%%\n" $icon $volume diff --git a/i3blocks-battery.sh b/i3blocks-battery.sh new file mode 100755 index 0000000..33e6a74 --- /dev/null +++ b/i3blocks-battery.sh @@ -0,0 +1,32 @@ +#!/bin/sh +base="/sys/class/power_supply/BAT0/" +low=25 +med=50 +high=75 +icon_charging_high= +icon_charging_low= +icon_charging_med= +icon_charging_dry= +icon_high= +icon_low= +icon_med= +icon_dry= + +full=$(< $base/energy_full_design) +now=$(< $base/energy_now) +stat=$(< $base/status) +percent=$(echo "result = $now / $full * 100; scale=0; result / 1" | bc -l) + +if [ "$stat" = "Discharging" ]; then + [ $percent -lt $low ] && printf $icon_dry + [ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_low + [ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_med + [ $percent -ge $high ] && printf $icon_high +else + [ $percent -lt $low ] && printf $icon_charging_dry + [ $percent -ge $low ] && [ $percent -lt $med ] && printf $icon_charging_low + [ $percent -ge $med ] && [ $percent -lt $high ] && printf $icon_charging_med + [ $percent -ge $high ] && printf $icon_charging_high +fi + +printf " %s%%\n" $percent diff --git a/i3blocks-cpuload.sh b/i3blocks-cpuload.sh new file mode 100755 index 0000000..6d3773f --- /dev/null +++ b/i3blocks-cpuload.sh @@ -0,0 +1,17 @@ +#!/bin/sh +cpu_count=4 +low=25 +high=75 +icon= +icon_low= +icon_mid= +icon_high= + +avg_load=$(uptime | cut -d, -f4 | cut -d: -f2) +percent=$(echo "result = $avg_load / $cpu_count * 100; scale=0; result / 1" | bc -l) + +printf $icon +[ $percent -lt $low ] && printf $icon_low +[ $percent -ge $low ] && [ $percent -lt $high ] && printf $icon_mid +[ $percent -ge $high ] && printf $icon_high +printf " %s%%\n" $percent diff --git a/i3blocks-cputemp.sh b/i3blocks-cputemp.sh new file mode 100755 index 0000000..94a9a2b --- /dev/null +++ b/i3blocks-cputemp.sh @@ -0,0 +1,14 @@ +#!/bin/sh +kelvins=$(cat /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input) +low=122 # 50C +high=176 # 80C +icon_low= +icon_mid= +icon_high= + +fahrenheit=$(expr $(expr $(expr $(expr $kelvins \* 9) / 5) / 1000) + 32) +[ $fahrenheit -lt $low ] && printf $icon_low +[ $fahrenheit -ge $low ] && [ $fahrenheit -lt $high ] && printf $icon_mid +[ $fahrenheit -ge $high ] && printf $icon_high + +printf " %s ℉\n" $fahrenheit diff --git a/i3blocks-date.sh b/i3blocks-date.sh new file mode 100755 index 0000000..80bb4dd --- /dev/null +++ b/i3blocks-date.sh @@ -0,0 +1,4 @@ +#!/bin/sh +icon= + +printf "$icon %s\n" "$(date '+%a %b %e %l:%M %p')" diff --git a/i3blocks-disk.sh b/i3blocks-disk.sh new file mode 100755 index 0000000..fba0cf6 --- /dev/null +++ b/i3blocks-disk.sh @@ -0,0 +1,4 @@ +#!/bin/sh +icon= + +printf "$icon %s\n" $(df -h | awk '$6=="/" { print $5 }') diff --git a/i3blocks-memory.sh b/i3blocks-memory.sh new file mode 100755 index 0000000..f37dc4c --- /dev/null +++ b/i3blocks-memory.sh @@ -0,0 +1,4 @@ +#!/bin/sh +icon= + +printf "$icon %s\n" "$(free -h | awk 'FNR==2 { print $3 }')" diff --git a/i3blocks-news.sh b/i3blocks-news.sh new file mode 100755 index 0000000..024043a --- /dev/null +++ b/i3blocks-news.sh @@ -0,0 +1,5 @@ +#!/bin/sh +icon= + +unread=$(newsboat -x print-unread | cut -d' ' -f1) +[ $unread -gt 0 ] && printf "$icon %s\n" $unread diff --git a/i3blocks-title.sh b/i3blocks-title.sh new file mode 100755 index 0000000..cce4fc4 --- /dev/null +++ b/i3blocks-title.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +name=$(xdotool getactivewindow getwindowname) +[ -n "$name" ] && printf "%s\n" "$(xdotool getactivewindow getwindowname)" diff --git a/i3blocks-updates.sh b/i3blocks-updates.sh new file mode 100755 index 0000000..1c1e825 --- /dev/null +++ b/i3blocks-updates.sh @@ -0,0 +1,5 @@ +#!/bin/sh +icon= + +packages="$(pacman -Qu | wc -l)" +[ $packages -gt 0 ] && printf "$icon %s\n" $packages diff --git a/i3blocks-uptime.sh b/i3blocks-uptime.sh new file mode 100755 index 0000000..3be3b2a --- /dev/null +++ b/i3blocks-uptime.sh @@ -0,0 +1,4 @@ +#!/bin/sh +icon= + +printf "$icon %s\n" "$(uptime -p | cut -d, -f1,2)" @@ -0,0 +1,20 @@ +#!/bin/sh + +# Get list of possible partitions to mount. Only select partitions that have +# not been mounted and display their name and size as dmenu options. +parts=$( + lsblk -nlpo NAME,SIZE,TYPE,MOUNTPOINT | grep "part $" | cut -f 1,4 -d' ' +) +[[ -z $parts ]] && exit 1 + +# Prompt for partition to mount. +choice=$( + echo "$parts" | dmenu -i -p "Mount which partition?" | cut -f 1 -d' ' +) +[[ -z $choice ]] && exit 1 + +# Create a mount directory if none exists. Use UUID for unique name. +mntdir="/mnt/$(lsblk -n "$choice" -o UUID | cut -f 1 -d' ')" +sudo mkdir -p "$mntdir" +sudo mount "$choice" "$mntdir" + diff --git a/oldi3status.sh b/oldi3status.sh new file mode 100755 index 0000000..e1cb415 --- /dev/null +++ b/oldi3status.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Adam's custom i3status script. + +# Configuration variables. +ticker_length=5 # Ticker length in words. + +# Echo the text the ticker should scroll over. No newlines! +init_ticker() { + echo $(fortune | tr -d '\b\r\\' | tr -s '\n\t\v\f' ' ' | tr -s '"' "'") +} + +# Cut up text for ticker tape. +gen_ticker() { + echo $( + echo $text | cut -d' ' -f$word_index-$(( + $word_index + $ticker_length - 1 + )) + ) +} + +# Prints out valid JSON for i3status using given parameters. +printer() { + printf "\"full_text\":\"%s\"," "$1" + printf "\"align\":\"%s\"," "$2" + printf "\"min_width\":%d}," $3 +} + +# Main loop. +i3status | ( + read line && \ + echo "$line" && \ + read line && \ + echo "$line" && \ + read line && \ + echo "$line" && \ + while : +do + # Get i3status line. + read line + + # If ticker text is empty, re-initialize text and word index. Then generate + # ticker text. + [[ -z "$ticker_text" ]] && word_index=1 && text=$(init_ticker) + ticker_text=$(gen_ticker) && ((word_index += 1)) + + # Print i3status header string. + printf ",[{" + + # Print ticker tape JSON. + printer "$ticker_text" "left" 250 + + # Print the rest of the status string. + echo "${line#,\[}" + #printf "%s" $line + +done) diff --git a/open-chats.sh b/open-chats.sh new file mode 100755 index 0000000..063d9ac --- /dev/null +++ b/open-chats.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +while [ -n "$1" ]; do + [ "$1" = "-d" ] && surf "discord.com/app" & + [ "$1" = "-m" ] && surf "messenger.com" & + shift +done diff --git a/open-with-mutt b/open-with-mutt new file mode 100755 index 0000000..162c4cf --- /dev/null +++ b/open-with-mutt @@ -0,0 +1,3 @@ +#!/bin/sh +exec urxvt -e mutt -F ~/.muttrc "$@" + @@ -0,0 +1,21 @@ +#!/bin/sh + +# Magically makes things work. +sudo modprobe sg + +# Make sure scratch disk is available to rip to. +mountpoint /scratch || mount /scratch || exit 1 +echo "Mounted!" + +# Rip discs until told otherwise. +while : +do + outdir=$(mktemp -d /scratch/makemkvcon.XXXXX) + makemkvcon -r mkv disc:0 all $outdir >> $outdir/makemkvcon.log || exit 2 + eject + echo "Rip another? (Y/n)" + read confirm + [[ $confirm == "n" ]] && exit 0 + sleep 3; +done + diff --git a/slock-fortune.sh b/slock-fortune.sh new file mode 100755 index 0000000..3b93b50 --- /dev/null +++ b/slock-fortune.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +slock -m "$(fortune /usr/share/games/fortune/)" diff --git a/status.sh b/status.sh new file mode 100755 index 0000000..aa23534 --- /dev/null +++ b/status.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +date=$(date "+%a %b %d %I:%M %p") +batt=$(acpi -b | awk -F ', ' '{ print $2 }') +disk=$(df -H | awk '{ if ($6 == "/") print $4 }') +#ssid=$(ifconfig | egrep -o '*ssid (.*) ') +#idle=$(top -n | egrep -o '[0-9]+\.[0-9]% idle') +echo "$ssid $idle $disk free | $batt charged | $date" diff --git a/themer.sh b/themer.sh new file mode 100755 index 0000000..c8b01a0 --- /dev/null +++ b/themer.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +add_theme() { + INDIR="$1" + [ -z "$INDIR" ] && INDIR=$HOME/pictures/wallpapers + OUTDIR=$HOME/.local/share/wallpapers + [ ! -d "$INDIR" ] && exit 1 + [ ! -d "$OUTDIR" ] && mkdir -p "$OUTDIR" + for INFILE in $(sxiv -rot "$INDIR"); do + OUTFILE="$OUTDIR"/$(basename "$INFILE") + convert -verbose "$INFILE" -geometry 1920x1080^ -gravity center -crop 1920x1080+0+0 "$OUTFILE" + wpg -a "$OUTFILE" + done + wait +} + +set_theme() { + THEME=$(sxiv -rot $HOME/.config/wpg/wallpapers) + [ -z "$THEME" ] && exit 4 + wpg -s "$THEME" & + convert -verbose -background black -vignette 100x65000 "$THEME" $HOME/.local/share/wallpapers/lock.png & +} + +[ "$1" = "-a" ] && add_theme "$2" +set_theme +wait diff --git a/umounter b/umounter new file mode 100755 index 0000000..3c1822f --- /dev/null +++ b/umounter @@ -0,0 +1,21 @@ +#!/bin/sh + +# Get list of possible partitions to unmount. Only select partitions that have +# been mounted and display their name and size as dmenu options. +parts=$( + lsblk -nlpo NAME,SIZE,TYPE,MOUNTPOINT | grep "part .+$" | cut -f 1,4 -d' ' +) +[[ -z $parts ]] && exit 1 +exit + +# Prompt for partition to mount. +choice=$( + echo "$parts" | dmenu -i -p "Mount which partition?" | cut -f 1 -d' ' +) +[[ -z $choice ]] && exit 1 + +# Create a mount directory if none exists. Use UUID for unique name. +mntdir="/mnt/$(lsblk -n "$choice" -o UUID | cut -f 1 -d' ')" +sudo mkdir -p "$mntdir" +sudo mount "$choice" "$mntdir" + @@ -0,0 +1,34 @@ +#!/bin/sh + +# Do things with a YouTube URL. + +read url +printf "$url" +test -z $url && exit +title="$(youtube-dl -e "$url")" + +choice=$(dmenu -i -p "$title" << EOF +Watch +Listen +Download video +Download audio +EOF +) + +case $choice in + "Watch") + mpv "$url" --no-terminal & + ;; + "Listen") + mpv "$url" --no-terminal --no-video & + ;; + "Download Video") + youtube-dl "$url" --add-metadata + ;; + "Download Audio") + youtube-dl "$url" -x --audio-format flac --audio-quality 0 + ;; + *) + exit +esac + |