From 82df70eff06e7b44ee84283070d7f801f7fc1d92 Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sat, 6 Nov 2021 20:25:45 -0400 Subject: initial commit --- .local/bin/alarm | 17 +++++++++++ .local/bin/backups/borg-offsite | 25 ++++++++++++++++ .local/bin/backups/borg-onsite | 25 ++++++++++++++++ .local/bin/bgscript | 4 +++ .local/bin/cmus/toggle-mode | 14 +++++++++ .local/bin/cmus/toggle-shuf | 7 +++++ .local/bin/compile | 14 +++++++++ .local/bin/cryptusb/create-cryptusb | 34 +++++++++++++++++++++ .local/bin/cryptusb/handle-cryptusb | 8 +++++ .local/bin/cryptusb/mount-cryptusb | 5 ++++ .local/bin/cryptusb/sync-cryptusb | 6 ++++ .local/bin/cryptusb/umount-cryptusb | 5 ++++ .local/bin/dmenu/mount-device | 27 +++++++++++++++++ .local/bin/dmenu/unicode-select | 9 ++++++ .local/bin/dmenu/unmount-device | 19 ++++++++++++ .local/bin/exiti3 | 4 +++ .local/bin/ffmpeg-convert | 60 +++++++++++++++++++++++++++++++++++++ .local/bin/get-pkgs | 8 +++++ .local/bin/kbremaps | 7 +++++ .local/bin/kill-steam | 3 ++ .local/bin/lock | 7 +++++ .local/bin/mount-media | 6 ++++ .local/bin/pdf-preview | 8 +++++ .local/bin/screenshot | 8 +++++ .local/bin/signal-vol | 4 +++ .local/bin/statusbar/bar-calcurse | 15 ++++++++++ .local/bin/statusbar/bar-cmus | 25 ++++++++++++++++ .local/bin/statusbar/bar-cpu | 7 +++++ .local/bin/statusbar/bar-gpu | 6 ++++ .local/bin/statusbar/bar-ipv4 | 9 ++++++ .local/bin/statusbar/bar-memory | 8 +++++ .local/bin/statusbar/bar-storage | 7 +++++ .local/bin/statusbar/bar-time | 7 +++++ .local/bin/statusbar/bar-volume | 13 ++++++++ .local/bin/stop-alarm | 5 ++++ .local/bin/sync-music | 4 +++ .local/bin/theme/get-gradient | 13 ++++++++ .local/bin/theme/gradient.py | 24 +++++++++++++++ .local/bin/volctl | 12 ++++++++ .local/bin/who-depends | 13 ++++++++ .local/bin/windowshot | 9 ++++++ .local/bin/yt-fix | 42 ++++++++++++++++++++++++++ 42 files changed, 553 insertions(+) create mode 100755 .local/bin/alarm create mode 100755 .local/bin/backups/borg-offsite create mode 100755 .local/bin/backups/borg-onsite create mode 100755 .local/bin/bgscript create mode 100755 .local/bin/cmus/toggle-mode create mode 100755 .local/bin/cmus/toggle-shuf create mode 100755 .local/bin/compile create mode 100755 .local/bin/cryptusb/create-cryptusb create mode 100755 .local/bin/cryptusb/handle-cryptusb create mode 100755 .local/bin/cryptusb/mount-cryptusb create mode 100755 .local/bin/cryptusb/sync-cryptusb create mode 100755 .local/bin/cryptusb/umount-cryptusb create mode 100755 .local/bin/dmenu/mount-device create mode 100755 .local/bin/dmenu/unicode-select create mode 100755 .local/bin/dmenu/unmount-device create mode 100755 .local/bin/exiti3 create mode 100755 .local/bin/ffmpeg-convert create mode 100755 .local/bin/get-pkgs create mode 100755 .local/bin/kbremaps create mode 100755 .local/bin/kill-steam create mode 100755 .local/bin/lock create mode 100755 .local/bin/mount-media create mode 100755 .local/bin/pdf-preview create mode 100755 .local/bin/screenshot create mode 100755 .local/bin/signal-vol create mode 100755 .local/bin/statusbar/bar-calcurse create mode 100755 .local/bin/statusbar/bar-cmus create mode 100755 .local/bin/statusbar/bar-cpu create mode 100755 .local/bin/statusbar/bar-gpu create mode 100755 .local/bin/statusbar/bar-ipv4 create mode 100755 .local/bin/statusbar/bar-memory create mode 100755 .local/bin/statusbar/bar-storage create mode 100755 .local/bin/statusbar/bar-time create mode 100755 .local/bin/statusbar/bar-volume create mode 100755 .local/bin/stop-alarm create mode 100755 .local/bin/sync-music create mode 100755 .local/bin/theme/get-gradient create mode 100755 .local/bin/theme/gradient.py create mode 100755 .local/bin/volctl create mode 100755 .local/bin/who-depends create mode 100755 .local/bin/windowshot create mode 100755 .local/bin/yt-fix (limited to '.local/bin') diff --git a/.local/bin/alarm b/.local/bin/alarm new file mode 100755 index 0000000..2909ecf --- /dev/null +++ b/.local/bin/alarm @@ -0,0 +1,17 @@ +#!/bin/sh + +[ $1 = "-h" -o $1 = "--help" ] && echo "usage: alarm time sound_file" && exit 0 +[ $# != 2 ] && echo "usage: alarm time sound_file" && exit 1 + +echo "alarm set for $1" +echo "$(basename "$2") is the alarm tone" + +while [ $(date +%H:%M) != "$1" ] +do + sleep 1 +done + +amixer -q sset Master 100% unmute +pkill -RTMIN+10 i3blocks +mpv --loop=inf $2 + diff --git a/.local/bin/backups/borg-offsite b/.local/bin/backups/borg-offsite new file mode 100755 index 0000000..dfc9c01 --- /dev/null +++ b/.local/bin/backups/borg-offsite @@ -0,0 +1,25 @@ +#!/bin/sh +# Full system backup with Borg + +# Backup root partition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + --exclude '/dev/*' \ + --exclude '/proc/*' \ + --exclude '/sys/*' \ + --exclude '/tmp/*' \ + --exclude '/mnt/*' \ + --exclude '/media/*' \ + "/mnt/offsite-backup/titan::root-{now:%Y-%m-%d}" / + +# Backup boot parition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + "/mnt/offsite-backup/titan::boot-{now:%Y-%m-%d}" /boot + +# Backup home partition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + "/mnt/offsite-backup/titan::home-{now:%Y-%m-%d}" /home + +# Backup var partition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + "/mnt/offsite-backup/titan::var-{now:%Y-%m-%d}" /var + diff --git a/.local/bin/backups/borg-onsite b/.local/bin/backups/borg-onsite new file mode 100755 index 0000000..658c425 --- /dev/null +++ b/.local/bin/backups/borg-onsite @@ -0,0 +1,25 @@ +#!/bin/sh +# Full system backup with Borg + +# Backup root partition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + --exclude '/dev/*' \ + --exclude '/proc/*' \ + --exclude '/sys/*' \ + --exclude '/tmp/*' \ + --exclude '/mnt/*' \ + --exclude '/media/*' \ + "/mnt/onsite-backup/titan::root-{now:%Y-%m-%d}" / + +# Backup boot parition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + "/mnt/onsite-backup/titan::boot-{now:%Y-%m-%d}" /boot + +# Backup home partition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + "/mnt/onsite-backup/titan::home-{now:%Y-%m-%d}" /home + +# Backup var partition +sudo borg create --verbose --list --stats --show-rc --exclude-caches --one-file-system \ + "/mnt/onsite-backup/titan::var-{now:%Y-%m-%d}" /var + diff --git a/.local/bin/bgscript b/.local/bin/bgscript new file mode 100755 index 0000000..4ec7706 --- /dev/null +++ b/.local/bin/bgscript @@ -0,0 +1,4 @@ +#!/bin/sh + +#feh --no-fehbg --recursive --randomize --bg-scale ~/pictures/wallpapers +feh --no-fehbg --bg-scale ~/pictures/wallpapers/miscbest/4.jpg diff --git a/.local/bin/cmus/toggle-mode b/.local/bin/cmus/toggle-mode new file mode 100755 index 0000000..e73edc6 --- /dev/null +++ b/.local/bin/cmus/toggle-mode @@ -0,0 +1,14 @@ +#!/bin/sh +# Toggles the cmus aaa mode (all,album,artist) + +cmus-remote -C "toggle aaa_mode" +mode=$(cmus-remote -Q | grep "aaa_mode" | cut -d ' ' -f 3) +artist=$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3-) +album=$(cmus-remote -Q | grep "tag album" | cut -d ' ' -f 3-) + +[ "$mode" = "all" ] && dunstctl close-all && notify-send "Playing from full library" \ + && exit +[ "$mode" = "artist" ] && dunstctl close-all && notify-send "Playing by artist: $artist" \ + && exit +[ "$mode" = "album" ] && dunstctl close-all && notify-send "Playing from album: $album" \ + && exit diff --git a/.local/bin/cmus/toggle-shuf b/.local/bin/cmus/toggle-shuf new file mode 100755 index 0000000..57c2606 --- /dev/null +++ b/.local/bin/cmus/toggle-shuf @@ -0,0 +1,7 @@ +#!/bin/sh +# Toggle and report status of shuffle mode in cmus + +cmus-remote --shuffle +status=$(cmus-remote -Q | grep shuffle | cut -d ' ' -f 3) +dunstctl close-all +[ "$status" = "true" ] && notify-send "Shuffle on" || notify-send "Shuffle off" diff --git a/.local/bin/compile b/.local/bin/compile new file mode 100755 index 0000000..837766b --- /dev/null +++ b/.local/bin/compile @@ -0,0 +1,14 @@ +#!/bin/sh + +# Script for automatic compilation (or interpretation) of various file types +# The filename needs to be passed to this script as the only argument +file="$1" +base="${file%.*}" +ext="${file##*.}" + +case $ext in + mom) groff -mom -Tpdf "$file" > "$base.pdf" ;; + ms) groff -me -Tpdf "$file" > "$base.pdf" ;; + me) groff -me -Tpdf "$file" > "$base.pdf" ;; + py) python3 "$file" ;; +esac diff --git a/.local/bin/cryptusb/create-cryptusb b/.local/bin/cryptusb/create-cryptusb new file mode 100755 index 0000000..e0f49fe --- /dev/null +++ b/.local/bin/cryptusb/create-cryptusb @@ -0,0 +1,34 @@ +#!/bin/sh +# Prompts for and creates a LUKS encrypted partition on a device + +# Get disks connected to the system that are hotpluggable (USBs) +devices="$(lsblk -lp -o NAME,SIZE,HOTPLUG,TYPE | grep "1 disk" | awk '{print $1,"-",$2}')" +[ "$devices" = "" ] && echo "no devices available" && exit 0 + +# Prompt for device selection from the user +select=$(echo "$devices" | dmenu -i -p "Select a device") +[ "$select" = "" ] && echo "no device selected" && exit 0 + +# Get confirmation since this is a potentially dangerous operation +yn=$(echo "No\nYes" | dmenu -i -p "Create encrypted partition on $select") +[ "$yn" != "Yes" ] && exit 0 + +# Get device path from selection string +usb=$(echo $select | cut -d ' ' -f 1) +echo $usb + +# Create LUKS partition on selected device (user will be promted for password to encrypt) +sudo cryptsetup --type luks2 luksFormat "$usb" + +# Open device and create filesystem on partition +echo "creating filesystem" +map_name="crypt-create" +sudo cryptsetup open "$usb" "$map_name" +sudo mkfs.ext4 "/dev/mapper/$map_name" + +# Close device after creating filesystem +sudo cryptsetup close "$map_name" + +echo "done" + + diff --git a/.local/bin/cryptusb/handle-cryptusb b/.local/bin/cryptusb/handle-cryptusb new file mode 100755 index 0000000..63d6ef4 --- /dev/null +++ b/.local/bin/cryptusb/handle-cryptusb @@ -0,0 +1,8 @@ +#!/bin/sh +# Single script for easy handling of encrypted USB +# Calls mount, sync, and umount scripts to automatically handle what is commonly +# run for encrypted USBs + +mount-cryptusb && notify-send "Encrypted USB mounted" +sync-cryptusb && notify-send "Encrypted USB synced" +umount-cryptusb && notify-send "Encrypted USB unmounted" diff --git a/.local/bin/cryptusb/mount-cryptusb b/.local/bin/cryptusb/mount-cryptusb new file mode 100755 index 0000000..882734c --- /dev/null +++ b/.local/bin/cryptusb/mount-cryptusb @@ -0,0 +1,5 @@ +#!/bin/sh +# Mounts LUKS encrypted USB + +sudo cryptsetup open /dev/sdc cryptusb +sudo mount /dev/mapper/cryptusb /mnt/cryptusb diff --git a/.local/bin/cryptusb/sync-cryptusb b/.local/bin/cryptusb/sync-cryptusb new file mode 100755 index 0000000..e9d3f1a --- /dev/null +++ b/.local/bin/cryptusb/sync-cryptusb @@ -0,0 +1,6 @@ +#!/bin/sh +# Syncs important files to encrypted USB + +rsync -avP --exclude=".steam*" --exclude="virtual_machines*" --exclude="media*" \ + --exclude="*.iso" --exclude="*.qcow2" \ + $HOME/ /mnt/cryptusb/$USER@$(hostname)/ diff --git a/.local/bin/cryptusb/umount-cryptusb b/.local/bin/cryptusb/umount-cryptusb new file mode 100755 index 0000000..c3c4b93 --- /dev/null +++ b/.local/bin/cryptusb/umount-cryptusb @@ -0,0 +1,5 @@ +#!/bin/sh +# Unmounts LUKS encrypted USB + +sudo umount /mnt/cryptusb +sudo cryptsetup close cryptusb diff --git a/.local/bin/dmenu/mount-device b/.local/bin/dmenu/mount-device new file mode 100755 index 0000000..e325a65 --- /dev/null +++ b/.local/bin/dmenu/mount-device @@ -0,0 +1,27 @@ +#!/bin/sh +# Script for mounting block devices + +# Set askpass program for authentication +export SUDO_ASKPASS=/usr/bin/ssh-askpass + +# Check for and get device to mount from user +devs="$(lsblk -lp | grep "part $" | awk '{print $1,"-",$4}')" +[ "$devs" = "" ] && exit 0 +dev="$(echo $devs | dmenu -i -p "Select device" | cut -d ' ' -f 1)" +[ "$dev" = "" ] && exit 0 + +# Attempt to mount without mountpoint for devices in /etc/fstab +sudo -A mount "$dev" 2>/dev/null && exit 0 + +# Get mountpoint from user +mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")" +[ "$mntpnt" = "" ] && exit 1 + +# If selected mountpoint does not exist ask to create it +# If user decides not to create non-existent drive, exit +[ ! -d $mntpnt ] && create="$(echo "No\nYes" | \ + dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \ + ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0) + +sudo -A mount $dev $mntpnt && pgrep -x dunst && notify-send "$dev mounted to $mntpnt" + diff --git a/.local/bin/dmenu/unicode-select b/.local/bin/dmenu/unicode-select new file mode 100755 index 0000000..f42cd6e --- /dev/null +++ b/.local/bin/dmenu/unicode-select @@ -0,0 +1,9 @@ +#!/bin/sh +# Select unicode character via dmenu and copy to clipboard + +line="$(cat ~/.local/share/unicode_list | dmenu -i -l 10)" +grep "$line" ~/.local/src/unicode_list | tr -d [:print:] | + xclip -r -selection "clipboard" && + notify-send "$(xclip -selection "clipboard" -o) copied to clipboard" + + diff --git a/.local/bin/dmenu/unmount-device b/.local/bin/dmenu/unmount-device new file mode 100755 index 0000000..75cb10f --- /dev/null +++ b/.local/bin/dmenu/unmount-device @@ -0,0 +1,19 @@ +#!/bin/sh +# Script for unmounting filesystems + +# Set askpass program for authentication +export SUDO_ASKPASS=/usr/bin/ssh-askpass + +# Get list of unmountable filesystems excluding critical ones (/, /home, /boot, etc...) +exclude="\(/\|/boot\|/boot/efi\|/var\|/tmp\|/home\)$" +parts="$(lsblk -lp | grep "part /" | grep -v "$exclude" | awk '{print $7,"-",$4}')" +[ "$parts" = "" ] && exit 0 + +# Get filesystem to unmount from user +select="$(echo "$parts" | dmenu -i -p "Select filesystem to unmount" | cut -d ' ' -f 1)" +[ "$select" = "" ] && exit 0 +dev="$(lsblk -lp | grep "$select" | awk '{print $1}')" + +# Unmount the filesystem +sudo -A umount $select && pgrep -x dunst && notify-send "Unmounted $select ($dev)" \ + || notify-send "Error: unable to unmount $select" "Are you in it?" diff --git a/.local/bin/exiti3 b/.local/bin/exiti3 new file mode 100755 index 0000000..0fe76bf --- /dev/null +++ b/.local/bin/exiti3 @@ -0,0 +1,4 @@ +#!/bin/sh +read -p "Exit i3 [Y]/n?" exit +[ "$exit" = "Y" ] && i3-msg exit + diff --git a/.local/bin/ffmpeg-convert b/.local/bin/ffmpeg-convert new file mode 100755 index 0000000..171a97b --- /dev/null +++ b/.local/bin/ffmpeg-convert @@ -0,0 +1,60 @@ +#!/bin/sh + +# Converts audio/video files to a different specified container format with ffmpeg +# Depends on the youtube-filename-fixer script for cleaining up YouTube filenames + +usage() { + echo "usage: ffmpeg-convert [options] container video_codec audio_codec files" + echo "\npositional parameters" + echo "\tcontainer\textension of the container that is being converted to" + echo "\tvideo_codec\tvideo codec of the output file" + echo "\taudio_codec\taudio codec of the output file" + echo "\noptions" + echo "\t-d\tdelete original files after conversion" + echo "\t-h\tshow this help and exit" +} +stdin() { + while read -r infile + do + outfile="$(echo $infile | rev | cut -d '.' -f 2 | rev)$container" + echo "converting $infile -> $outfile..." + ffmpeg -nostdin -loglevel 16 -i "$infile" -c:v $video -c:a $audio "$outfile" + [ $delete -eq 1 ] && rm -v "$infile" + done +} +cli() { + for infile in $@ + do + outfile="$(echo $infile | rev | cut -d '.' -f 2 | rev)$container" + echo "converting $infile -> $outfile..." + ffmpeg -nostdin -loglevel 16 -i "$infile" -c:v $video -c:a $audio "$outfile" + [ $delete -eq 1 ] && rm -v "$infile" + done +} + +options=$(getopt -o 'dhs' -- "$@") +eval set -- "$options" +delete=0 +stdin=0 +while true +do + case $1 in + '-h') usage ; exit 0 ;; + '-d') delete=1; shift; continue ;; + '-s') stdin=1; shift; continue ;; + '--') shift; break;; + *) echo "internal error"; exit 1 ;; + esac +done +[ $# -ge 3 ] || (usage && exit 1) + +# Set variables specified on command line +container="$1"; shift; video="$1"; shift; audio="$1"; shift; + +# Prepend a dot to the container name if not specified already +[ "${container#.}" = "$container" ] && container=".$container" + +# If there is only one file argument and it is "-" +[ $stdin -eq 1 ] && stdin || cli $@ + + diff --git a/.local/bin/get-pkgs b/.local/bin/get-pkgs new file mode 100755 index 0000000..19e64f3 --- /dev/null +++ b/.local/bin/get-pkgs @@ -0,0 +1,8 @@ +#!/bin/sh +# Creates files containing lists of installed and manually installed packages +# in cache directory + +pkgdir="$HOME/.cache/packages" +apt list --installed | tail -n+2 | cut -d '/' -f 1 > $pkgdir/installed +apt list --manual-installed | tail -n+2 | + cut -d '/' -f 1 > $pkgdir/manual-installed diff --git a/.local/bin/kbremaps b/.local/bin/kbremaps new file mode 100755 index 0000000..b914b7f --- /dev/null +++ b/.local/bin/kbremaps @@ -0,0 +1,7 @@ +#!/bin/sh +# Script for keyboard changes + +# Change autorepeat rate +xset r rate 300 50 +# Remap caps lock and escape +setxkbmap -option caps:swapescape diff --git a/.local/bin/kill-steam b/.local/bin/kill-steam new file mode 100755 index 0000000..5572ae7 --- /dev/null +++ b/.local/bin/kill-steam @@ -0,0 +1,3 @@ +#!/bin/sh + +pkill -f steam diff --git a/.local/bin/lock b/.local/bin/lock new file mode 100755 index 0000000..223ac59 --- /dev/null +++ b/.local/bin/lock @@ -0,0 +1,7 @@ +#!/bin/sh +# Locks the screen with a blurred screenshot of the current window as the lock image +# Also pauses any music that is playing + +maim | convert - -paint 5 ~/.cache/lock.png +[ "$(cmus-remote -Q | head -1 | cut -d ' ' -f 2)" != "playing" ] || cmus-remote --pause +i3lock -u -e -i ~/.cache/lock.png diff --git a/.local/bin/mount-media b/.local/bin/mount-media new file mode 100755 index 0000000..e748941 --- /dev/null +++ b/.local/bin/mount-media @@ -0,0 +1,6 @@ +#!/bin/sh +# Uses sshfs to locally mount media directories +# Check if the media computer is reachable and if so mount the media +ping -W 0.01 -c 1 prometheus >/dev/null && \ + sshfs sisko@prometheus:/mnt/raid/media/ $HOME/media/prometheus/ + diff --git a/.local/bin/pdf-preview b/.local/bin/pdf-preview new file mode 100755 index 0000000..1587f36 --- /dev/null +++ b/.local/bin/pdf-preview @@ -0,0 +1,8 @@ +#!/bin/sh + +# Typically called from vim +# Displays a pdf preview of an in-progress groff document +# Takes the filename as the only argument +# The pdf file is expected to have the same name as the groff document + +zathura "${1%.*}.pdf" & diff --git a/.local/bin/screenshot b/.local/bin/screenshot new file mode 100755 index 0000000..3f24f70 --- /dev/null +++ b/.local/bin/screenshot @@ -0,0 +1,8 @@ +#!/bin/sh +# Take screenshot with interactive area selection +# Saves screenshot with timestamp in directory named after the date + +time=$(date +%b-%d-%Y-%T.%N) +day=$(date +%b-%d-%Y) +[ -d ~/pictures/screenshots/$day ] || mkdir ~/pictures/screenshots/$day +maim -s > ~/pictures/screenshots/$day/$time.png && notify-send "Screenshot Taken" diff --git a/.local/bin/signal-vol b/.local/bin/signal-vol new file mode 100755 index 0000000..e5739f6 --- /dev/null +++ b/.local/bin/signal-vol @@ -0,0 +1,4 @@ +#!/bin/sh +# Signals the dwmblocks volume block to update + +pkill -RTMIN+10 dwmblocks diff --git a/.local/bin/statusbar/bar-calcurse b/.local/bin/statusbar/bar-calcurse new file mode 100755 index 0000000..dca82f3 --- /dev/null +++ b/.local/bin/statusbar/bar-calcurse @@ -0,0 +1,15 @@ +#!/bin/sh + +#i3blocks calcurse module + +case $BUTTON in + 3)notify-send -t 5000 "$(calcurse -D ~/.config/calcurse/ -c ~/.config/calcurse/apts -a)";; + 1)notify-send -t 20000 "$(calcurse -D ~/.config/calcurse/ -c ~/.config/calcurse/apts -r7)";; + 2)notify-send -t 5000 "$(calcurse -D ~/.config/calcurse/ -t)" +esac + +name="$(calcurse -D ~/.config/calcurse/ -c ~/.config/calcurse/apts -n | grep "\[" | sed "s/\s*\[/\[/" | cut -d ' ' -f 2-)" +[ "$name" = "" ] && echo "Nothing Scheduled" && exit 0 +time="$(grep "$name" ~/.config/calcurse/apts | head -1 | cut -d ' ' -f 3)" +[ ${time%%:*} -gt 12 ] && time="$((${time%%:*}-12)):${time##*:} PM" || time="$time AM" +echo "$name @ $time" diff --git a/.local/bin/statusbar/bar-cmus b/.local/bin/statusbar/bar-cmus new file mode 100755 index 0000000..947f950 --- /dev/null +++ b/.local/bin/statusbar/bar-cmus @@ -0,0 +1,25 @@ +#!/bin/sh + +case $BUTTON in + 1)notify-send "$(cmus-remote -Q | grep position | awk '{ printf "%02i:%02i", $2/60, $2%60}')/$(cmus-remote -Q | grep duration | awk '{ printf "%02i:%02i\n", $2/60, $2%60} ') ($(cmus-remote -Q | grep status | cut -d ' ' -f 2-)) +Artist: $(cmus-remote -Q | grep "tag artist " | cut -d ' ' -f 3-) +Album: $(cmus-remote -Q | grep "tag album " | cut -d ' ' -f 3-) +Track: $(cmus-remote -Q | grep "tag title " | cut -d ' ' -f 3-) +Genre: $(cmus-remote -Q | grep "tag genre " | cut -d ' ' -f 3-) +Mode: $(cmus-remote -Q | grep "aaa_mode" | cut -d ' ' -f 3) +Format: $(cmus-remote -Q | grep file | rev | cut -d '.' -f 1 | rev) +Shuffle: $(cmus-remote -Q | grep "set shuffle " | cut -d ' ' -f 3-) +Repeat: $(cmus-remote -Q | grep "set repeat_current " | cut -d ' ' -f 3-)";; + + 3)urxvt -e vim ~/.local/bin/statusbar/cmus;; + 4)cmus-remote --next;; + 5)cmus-remote --prev;; +esac + +pgrep -x cmus >/dev/null || exit 0 + +status="$(cmus-remote -Q | grep status | cut -d ' ' -f 2)" +artist="$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3- | tr -d "\n")" +track="$(cmus-remote -Q | grep "tag title" | cut -d ' ' -f 3- | tr -d "\n")" +echo -n "$artist - $track" +[ "$status" = "playing" ] || echo -n " [P]" diff --git a/.local/bin/statusbar/bar-cpu b/.local/bin/statusbar/bar-cpu new file mode 100755 index 0000000..c21fe20 --- /dev/null +++ b/.local/bin/statusbar/bar-cpu @@ -0,0 +1,7 @@ +#!/bin/sh +case $BUTTON in + 1) notify-send "$(ps axc -o cmd:15,%cpu --sort=-%cpu | head -6)";; + 3) urxvt -e vim ~/.local/bin/statusbar/cpu +esac +mpstat 1 1 | awk '/Average/ { printf "%.2f% ",100-$12 }' +temp="$(sensors | awk '/Tctl/ { print $2 } ')"; echo -n ${temp#+} diff --git a/.local/bin/statusbar/bar-gpu b/.local/bin/statusbar/bar-gpu new file mode 100755 index 0000000..5351a2f --- /dev/null +++ b/.local/bin/statusbar/bar-gpu @@ -0,0 +1,6 @@ +#!/bin/sh + +temp="$(sensors | awk '/edge/ { print $2 } ')" +fan="$(sensors | awk '/fan1/ { print $2 } ')" +power="$(sensors | awk '/power1/ { print $2 } ')" +echo -n "${temp#+} $fan RPM" diff --git a/.local/bin/statusbar/bar-ipv4 b/.local/bin/statusbar/bar-ipv4 new file mode 100755 index 0000000..4e51eca --- /dev/null +++ b/.local/bin/statusbar/bar-ipv4 @@ -0,0 +1,9 @@ +#!/bin/sh + +case $BUTTON in + 1)notify-send --expire-time=60000 "IP Addresses" "$(ip a | awk '/\/24|\/64/ {if($5=="temporary")print $2 " " $5;else print $2;}')";; + 3)urxvt -e ~/.local/bin/statusbar/ipv4 +esac +ip a | awk '/\/24/ { print $2 }' | cut -d '/' -f 1 + + diff --git a/.local/bin/statusbar/bar-memory b/.local/bin/statusbar/bar-memory new file mode 100755 index 0000000..1e98cca --- /dev/null +++ b/.local/bin/statusbar/bar-memory @@ -0,0 +1,8 @@ +#!/bin/sh + +case $BUTTON in + 1)notify-send "$(ps axc -o cmd:15,%mem --sort=-%mem | head -6)";; + 3)urxvt -e vim ~/.local/bin/statusbar/memory +esac +free --si -h | grep Mem | awk '{ print $3 "/" $2 }' + diff --git a/.local/bin/statusbar/bar-storage b/.local/bin/statusbar/bar-storage new file mode 100755 index 0000000..d7b5fcf --- /dev/null +++ b/.local/bin/statusbar/bar-storage @@ -0,0 +1,7 @@ +#!/bin/sh + +case $BUTTON in + 1)notify-send "$(df -H | grep "Filesystem\|/dev/sd")";; + 3)urxvt -e vim ~/.local/bin/statusbar/storage +esac +df -H | awk '/\/home/ { print $4 }' diff --git a/.local/bin/statusbar/bar-time b/.local/bin/statusbar/bar-time new file mode 100755 index 0000000..f61a268 --- /dev/null +++ b/.local/bin/statusbar/bar-time @@ -0,0 +1,7 @@ +#!/bin/sh + +case $BUTTON in + 1)notify-send "$(ncal -hb)";; + 3)urxvt -e vim ~/.local/bin/statusbar/time +esac +date +"%r %A %D" diff --git a/.local/bin/statusbar/bar-volume b/.local/bin/statusbar/bar-volume new file mode 100755 index 0000000..d9bcc9d --- /dev/null +++ b/.local/bin/statusbar/bar-volume @@ -0,0 +1,13 @@ +#!/bin/sh +# i3blocks volume module + +case $BUTTON in + 1)urxvt -e alsamixer;; + 3)urxvt -e vim ~/.local/bin/statusbar/volume;; + 4)amixer -q sset Master 1%+ unmute;; + 5)amixer -q sset Master 1%- unmute;; +esac + +stats=$(amixer sget Master | grep "Front Left:" | cut -d ' ' -f 7,8 | tr -d '[]') +[ "${stats##* }" = "on" ] && echo -n "${stats%% *}" || echo -n "${stats%% *}" + diff --git a/.local/bin/stop-alarm b/.local/bin/stop-alarm new file mode 100755 index 0000000..4607b11 --- /dev/null +++ b/.local/bin/stop-alarm @@ -0,0 +1,5 @@ +#!/bin/sh + +pkill mpv +amixer -q sset Master 50% +pkill -RTMIN+10 i3blocks diff --git a/.local/bin/sync-music b/.local/bin/sync-music new file mode 100755 index 0000000..4619a23 --- /dev/null +++ b/.local/bin/sync-music @@ -0,0 +1,4 @@ +#!/bin/sh +# Sync music from media computer to local computer + +rsync -av sisko@prometheus:/mnt/raid/media/music/ $HOME/media/music/ diff --git a/.local/bin/theme/get-gradient b/.local/bin/theme/get-gradient new file mode 100755 index 0000000..91f9391 --- /dev/null +++ b/.local/bin/theme/get-gradient @@ -0,0 +1,13 @@ +#!/bin/sh +# Gets and sets a color gradient for cava + +start="$1" +end="$2" +colors=$(~/.local/bin/theme/gradient.py $start $end 7) + +num=1 +path="$HOME/.config/cava/config" +for color in $colors; do + sed -i "s/gradient_color_$num.*$/gradient_color_$num = '$color'/" $path + num=$((num+1)) +done diff --git a/.local/bin/theme/gradient.py b/.local/bin/theme/gradient.py new file mode 100755 index 0000000..f95bb07 --- /dev/null +++ b/.local/bin/theme/gradient.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 +# Gets a color gradient based on input color and number +# Depends on python3-colour + +import colour,sys + +if len(sys.argv) != 4: + print("arg error") + sys.exit(1) + +start = sys.argv[1] +end = sys.argv[2] +num = int(sys.argv[3]) + +grad = colour.color_scale(colour.hex2hsl(start),colour.hex2hsl(end),num) +grad_hex = [] +for hsl in grad: + grad_hex.append(colour.hsl2hex(hsl)) + +for color in grad_hex: + sys.stdout.write(color + "\n") + + + diff --git a/.local/bin/volctl b/.local/bin/volctl new file mode 100755 index 0000000..faa8de6 --- /dev/null +++ b/.local/bin/volctl @@ -0,0 +1,12 @@ +#!/bin/sh +# Script for volume control +# +# Accepts either a number and a +,- operator (volctl 5 +) or "toggle" (volctl toggle) + +# If the lone argument is "toggle", toggle mute/unmute +[ "$1" = "toggle" ] && amixer -q sset Master toggle && signal-vol && exit + +num=$1 +dir=$2 + +amixer -q sset Master $num%$dir unmute && signal-vol diff --git a/.local/bin/who-depends b/.local/bin/who-depends new file mode 100755 index 0000000..d1fb0c2 --- /dev/null +++ b/.local/bin/who-depends @@ -0,0 +1,13 @@ +#!/bin/sh + +# Script that takes a package as an argument and returns installed packages +# that are dependent on it + +[ $# -eq 1 ] || echo "usage: who-depends package" +apt list --installed | tail -n+2 | cut -d '/' -f 1 > /tmp/whodepends +pkg="$1" +deps_all=$(apt-cache rdepends $pkg | tail -n+3 | sed "s/^\s*//") +for dep in $deps_all +do + grep -lq "$dep" /tmp/whodepends && echo "$dep" +done diff --git a/.local/bin/windowshot b/.local/bin/windowshot new file mode 100755 index 0000000..a7b143b --- /dev/null +++ b/.local/bin/windowshot @@ -0,0 +1,9 @@ +#!/bin/sh +# Take screenshot of current window +# Saves screenshot with timestamp in directory named after the date + +time=$(date +%b-%d-%Y-%T.%N) +day=$(date +%b-%d-%Y) +[ -d "~/pictures/screenshots/$day" ] || mkdir -p ~/pictures/screenshots/$day +maim > ~/pictures/screenshots/$day/$time.png && notify-send "Screenshot Taken" + diff --git a/.local/bin/yt-fix b/.local/bin/yt-fix new file mode 100755 index 0000000..69e771a --- /dev/null +++ b/.local/bin/yt-fix @@ -0,0 +1,42 @@ +#!/bin/sh + +# Takes files downloaded through youtube-dl and cleans up their filenames + +stdin() { + while read -r infile + do + ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" + ext_length=${#ext} + remove=$((12+$ext_length)) + filename="$(echo $infile | rev | cut -c $remove- | rev)" + mv "$infile" "$filename$ext" + done +} + +cli() { + for infile in "$@" + do + ext=".$(echo $infile | rev | cut -d '.' -f 1 | rev)" + ext_length=${#ext} + remove=$((12+$ext_length)) + filename="$(echo $infile | rev | cut -c $remove- | rev)" + mv "$infile" "$filename$ext" + done +} + +options=$(getopt -o 'hsx' -- "$@") +eval set -- "$options" +read_stdin=0 +noext=0 +while true +do + case "$1" in + '-h') echo "usage: yt-fix [options] [files]\n\th\tprint this help and exit\n\tx\tdo not include extension in output\n\ts\tread from stdin"; exit 0;; + '-s') read_stdin=1; shift; continue;; + '-x') noext=1; shift; continue;; + '--') shift; break;; + esac +done + +[ $read_stdin -eq 0 ] && cli "$@" || stdin + -- cgit v1.2.3