bin

git clone git://git.codymlewis.com/bin.git
Log | Files | Refs

commit 3494606c6e2e0969efcacc33ad926870bb88bcfe
Author: Cody Lewis <cody@codymlewis.com>
Date:   Wed, 24 Jun 2020 14:46:36 +1000

Initial commit

Diffstat:
Afzfmpc | 11+++++++++++
Agb | 11+++++++++++
Aget-pass | 8++++++++
Alinkhandler | 20++++++++++++++++++++
Alitman | 4++++
Amd2pdf | 6++++++
Anew-pass | 7+++++++
Apdfmerge | 20++++++++++++++++++++
Apowermenu | 16++++++++++++++++
Astatusbar/battery | 19+++++++++++++++++++
Astatusbar/volume | 20++++++++++++++++++++
Awl | 31+++++++++++++++++++++++++++++++
Axrs | 26++++++++++++++++++++++++++
13 files changed, 199 insertions(+), 0 deletions(-)

diff --git a/fzfmpc b/fzfmpc @@ -0,0 +1,11 @@ +#!/bin/bash + +artist="$(mpc list Artist | fzf)" + +[[ $artist = "" ]] && exit + +title="$(mpc list Title Artist "$artist" | fzf)" + +[[ $title = "" ]] && exit + +mpc searchplay Artist "$artist" Title "$title" diff --git a/gb b/gb @@ -0,0 +1,11 @@ +#!/bin/sh + +case $1 in + on) + bluetoothctl power on + bluetoothctl connect D8:55:75:2A:EE:AC + ;; + off) + bluetoothctl power off + ;; +esac diff --git a/get-pass b/get-pass @@ -0,0 +1,8 @@ +#!/bin/sh + +a=$(ls "$HOME/.password-store" | rofi -dmenu -p "What website do you want a password for") +[ $(ls "$HOME/.password-store/$a" | wc -l) = 1 ] && + b=$(ls "$HOME/.password-store/$a" | sed 's/\.gpg//') || + b=$(ls "$HOME/.password-store/$a" | sed 's/\.gpg//' | rofi -dmenu "Which account do you want a password for") + +(tpm show "$a/$b" | xsel -p) && (echo "$a" | xsel -b) && notify-send "Password for $a/$b copied to clipboard" diff --git a/linkhandler b/linkhandler @@ -0,0 +1,20 @@ +#!/bin/sh + +[ -z "$1" ] && { "$BROWSER"; exit; } + + +case "$1" in + *mkv|*webm|*mp4|*hooktube.com*|*bitchute.com*|*mp3|*flac|*opus|*mp3?source) + mpv -quiet "$1" >/dev/null 2>&1 ;; + *youtube.com/watch*|*youtube.com/playlist*|*youtu.be*) + q=$(printf "480\n720\nMax" | fzf) + ([ "$q" = Max ] && + mpv --ytdl-format='bestvideo+bestaudio' "$1") || + mpv --ytdl-format="bestvideo[height<=$q]+bestaudio[ext=m4a]" "$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 & ;; + *) + if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1" + else setsid -f "$BROWSER" "$1" >/dev/null 2>&1; fi ;; +esac diff --git a/litman b/litman @@ -0,0 +1,4 @@ +#!/bin/sh + +cd "$HOME/Desktop/University/Research/Manager" && + ./manager.py diff --git a/md2pdf b/md2pdf @@ -0,0 +1,6 @@ +#!/bin/bash + +[ $# -lt 1 ] && printf "Usage: md2pdf <filename>\n" && exit + +o=${1/\.md/.pdf} +pandoc -o "$o" "$1" && zathura "$o" diff --git a/new-pass b/new-pass @@ -0,0 +1,7 @@ +#!/bin/sh + +[ $# = 3 ] && + a=$(pwgen -1 $1) && + echo "$a" | tpm insert "$2/$3" && + echo "$a" | xsel || + echo "Usage: new-pass <passlen> <website> <username>" diff --git a/pdfmerge b/pdfmerge @@ -0,0 +1,20 @@ +#!/bin/bash + +a=$(echo "$@" | sed 's/\s/%20/g' | sed 's/.pdf%20/.pdf /g') + +rm combine.pdf +touch combine.pdf + +echo "" | ps2pdf -sPAPERSIZE=a4 - /tmp/blank.pdf + +for file in $a; do + mv combine.pdf /tmp/temp.pdf + gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH /tmp/temp.pdf "${file//\%20/ }" + pages=$(pdfinfo combine.pdf | awk '/Pages:/{ print $2 }') + if [ `expr $pages % 2` -eq 1 ]; then + mv combine.pdf /tmp/temp.pdf + gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combine.pdf -dBATCH /tmp/temp.pdf /tmp/blank.pdf + fi +done + +rm /tmp/temp.pdf diff --git a/powermenu b/powermenu @@ -0,0 +1,16 @@ +#!/bin/bash +# A power handling script using rofi + +PWR_OPT=$(echo -e "Cancel\nExit WM\nShutdown\nReboot" | rofi -dmenu -i -p "What would you like to do?" -l 4) + +case $PWR_OPT in + "Exit WM") + xsetroot -name "fsignal:1" + ;; + "Shutdown") + shutdown -h now + ;; + "Reboot") + reboot + ;; +esac diff --git a/statusbar/battery b/statusbar/battery @@ -0,0 +1,19 @@ +#!/bin/sh + +cap=$(cat /sys/class/power_supply/BAT0/capacity) +if grep 'Discharging' /sys/class/power_supply/BAT0/status > /dev/null; then + if [ "$cap" -lt 20 ]; then + baticon="" + elif [ "$cap" -lt 40 ]; then + baticon="" + elif [ "$cap" -lt 60 ]; then + baticon="" + elif [ "$cap" -lt 80 ]; then + baticon="" + else + baticon="" + fi +else + baticon="" +fi +printf "%s %s " "$baticon" "$cap" diff --git a/statusbar/volume b/statusbar/volume @@ -0,0 +1,20 @@ +#!/bin/sh + +case $BLOCK_BUTTON in + 1) setsid "$TERMINAL" -e pulsemixer & ;; +esac + +vol=$(amixer get Master | awk -F'[][]' 'END{ print $2 }' | sed 's/%//g') +is_muted=$(amixer get Master | grep 'off') +if [ "$is_muted" ]; then + printf " " +else + if [ "$vol" -gt 50 ]; then + vol=" $vol" + elif [ "$vol" -gt 0 ]; then + vol=" $vol" + else + vol=" $vol" + fi + printf "%s " "$vol" +fi diff --git a/wl b/wl @@ -0,0 +1,31 @@ +#!/bin/sh + +action="$1" +shift + +wl_file="$HOME/.watch_later" + +case "$action" in + dl) + olddir=$(pwd) + cd "$HOME/Videos" || exit + youtube-dl "$@" -ic --add-metadata -f 'best' -a "$wl_file" + cd "$olddir" || exit + ;; + v) + q=$(printf "480\n720\nMax" | fzf) + ([ "$q" = Max ] && + ytdl="best") || + ytdl="best[height<=$q]" + mpv --ytdl-format="$ytdl" --playlist="$wl_file" + ;; + add) + echo "$@" >> "$wl_file" + ;; + clear) + echo '' > "$wl_file" + ;; + ls) + cat "$wl_file" + ;; +esac diff --git a/xrs b/xrs @@ -0,0 +1,26 @@ +#!/bin/sh + +primary="eDP1" + +other_mons="$(xrandr | awk '/\sconnected\s[^p]/{ print $1 }')" + +mon="$(printf "%s" "$other_mons" | rofi -dmenu -p 'Which monitor')" + +dir=$(printf "Right\nLeft\nMirror\nAbove\nBelow\nOff" | rofi -dmenu -p 'Which direction') + +case "$dir" in + "Right") + xrandr --output "$mon" --auto --right-of "$primary" ;; + "Left") + xrandr --output "$mon" --auto --left-of "$primary" ;; + "Mirror") + xrandr --output "$mon" --auto --same-as "$primary" ;; + "Above") + xrandr --output "$mon" --auto --above "$primary" ;; + "Below") + xrandr --output "$mon" --auto --below "$primary" ;; + "Off") + xrandr --output "$mon" --off ;; +esac + +xwallpaper --center "$HOME/.config/wallpaper.png"